Iteration 4-Emma Nolan
MQTT architecture
MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol that is widely used for connecting devices and applications in the Internet of Things (IoT) and other scenarios where low bandwidth and low power consumption are important. Here's an overview of the MQTT architecture that we are using:
Client:
Clients are devices or systems that send or receive messages. They could be IoT devices, sensors, servers, or any system capable of communication.
Clients either send data (publish messages) or receive data (subscribe to topics). In our case the Client is the Cloudboard, but it is also a master/publisher and its subscriber/slaves are the microbits. Which then sends these values towards beebotte which will then be displayed in the app on our phones.
Master (or Publisher):
The master is like the leader in the relationship. It initiates commands, controls operations, and directs activities. This entity usually has more authority and responsibility compared to the slave. The cloud board for us sends data to the mircrobit such as below and also asks for a value to be returned as well.
sendToNode("i1", 0, 0, 0)
sendToNode("i2", input.temperature(), 1, 0)
sendToNode("i3", 0, 2, 0)
sendToNode("i4", 0, 3, 0)
sendToNode("i5", 0, 4, 0)
sendToNode("i6", 0, 4, 0)
sendToNode("i7", 0, 4, 0)
Slave (or Subscriber):
The slave follows the master's instructions. It performs tasks, receives commands, and executes operations. It typically has less authority and autonomy compared to the master. This waits from input form the master or the cloud and then sends a random value towards the cloud when it is rolled.
Broker (or Server):
The broker is a server that acts as a middleman between clients. It receives messages from clients and forwards them to the right recipients based on the message's topic.
Brokers manage subscriptions, ensure message delivery, and maintain network integrity. We are using bebotte to handle all this.
Topic:
Topics categorize messages in MQTT. Clients subscribe to topics to receive relevant messages or publish messages to specific topics.
Topics help organize communication and ensure messages reach the intended recipients. One of the topic we are using is "USVSensorPod/temp". In Beebotte, "topics" refer to channels through which data is organized and communicated.
Quality of Service (QoS):
QoS 0 (At most once): Messages are sent at most once, with no confirmation. Simple and light on resources, but delivery isn't guaranteed.
QoS 1 (At least once): Messages are guaranteed to arrive, but duplicates may occur.
QoS 2 (Exactly once): Messages are guaranteed to arrive exactly once, ensuring reliable delivery.
In our situation the micro:bit radio communication and Beebotte, the QoS level is similar to QoS 0. where messages are sent at most once, with no confirmation.
In essence, MQTT provides a flexible and efficient way for devices and systems to communicate in IoT networks, allowing for reliable data exchange while minimizing bandwidth and power consumption.
IotMQTTPanel:
IoT MQTT Panel is a versatile and user-friendly application used for monitoring and controlling IoT (Internet of Things) devices via the MQTT protocol.
MQTT Protocol Support:
IoT MQTT Panel supports the MQTT protocol, which is widely used for efficient, lightweight messaging between IoT devices and servers.
Real-time Monitoring:
It allows users to monitor real-time data from MQTT-enabled devices. This includes sensor readings, device statuses, and other relevant information.
Dashboard Customization:
Users can create customizable dashboards to visualize data from multiple IoT devices simultaneously. This enables easy monitoring and analysis of various parameters.
Data Logging and Visualization:
The application provides features for logging historical data and visualizing it through charts, graphs, or other graphical representations. This helps users analyze trends and patterns over time.
Code:
Cloud:
WiFi and MQTT Setup:
Connects to a WiFi network (JACKDlaptop with password 12345678).
Establishes MQTT (Message Queuing Telemetry Transport) connection with Beebotte,
using specific credentials and a topic (USVSensorPod/temp).
Configures the microcontroller's radio communication group to channel 9.
This is the channel the Microbit and the cloud board will communicate on.
Once all the connects are made successfully the microbit on the cloud board will
displays a heart icon on the LED matrix of the microcontroller. It will clear the screen once the connect is
successful.
Forever:
The code is sending data packets to different the different microbits identified as "i1" through "i7". Which
stands for Input 1 and input 2 and so on/
On radio received:
name represents the unique identifier (ID) associated with a Microbit or a device that sent the radio message.
value represents the data value sent by that particular Microbit.
When a radio message is received:
The received data (name and value) is sent over MQTT using the microIoT_SendMessage function. It's structured as a JSON object with the name as a key and the value as its corresponding value. Additionally, a boolean field ispublic is added to the JSON object with a value of true. This message is sent to the MQTT topic topic_0.
An LED located at coordinates (4, 4) on the LED matrix is toggled. This action serves as a visual indicator that a radio message has been received.
microIoT.microIoT_MQTT_Event:
When an MQTT message is received on this topic_1, the function defined within function (message) will be called, and the received message will be passed to it.
Parsing JSON Message:
The parseJsonMessage function is responsible for parsing and extracting data from the received JSON-formatted message.
value from it, and then sends this data via radio communication. It recieves the message/input from the
beebotte server. This will be then send to the Microbit with the corresponding ID such output 1 etc etc.
In Summary this is the process
IotApp on our phone -> Beebottee sever -> Cloud board (Master) -> Microbit (Slave).
Slave:
This sets up an event handler to execute a function whenever a radio message is received.
The function takes two parameters: name and value, representing the identifier
and the data value sent via radio.
The statement checks the value of name to determine the action to take based on the received data.
If name is equal to \"o3\" (including the quotes), it toggles the LED at coordinates (4, 4).
If name is equal to "i3", it toggles the LED at coordinates (3, 4)
and sends a radio message with the identifier "i3" and the value obtained from the roll rotation input.
radio.setGroup(9):
This line sets the radio communication group to channel 9. It ensures that the microcontroller
communicates on the same frequency as other devices within the same group.
Vidoe evidence:
IFFT:
IFTTT stands for "If This, Then That." It's a popular web-based service that allows users to
create chains of simple conditional statements. Each one triggers an action based on changes
that occur within other web services, such as Gmail, Facebook, Instagram, or numerous
IoT (Internet of Things) devices and services.
To test it we used a button A to trigger our IFTTT event which will send out a email.
IFTTT IDEAS
Social Media:
IFTTT to monitor your social media activity, such as the number of likes or comments on your posts. Use this data to that triggers when a social media engagement reaches a certain level. Send this information to the micro:bit, which can display a corresponding mood indicator using LEDs. For example, a happy face for each like on a post or a follow.
Work Reminder:
Use IFTTT to sync with a calendar with the micro:bit. It will trigger a reminders for upcoming assignments or project deadlines. When a reminder is triggered, it will send a notification to the micro:bit, which can display the assignment details or countdown to the deadline, or the date it is due.
Fitness Tracker:
Connect IFTTT to a any health app to track your daily activity levels, such as steps taken or calories burned.It will trigger when you reach certain fitness milestones or goals such as a increase of steps in a day.Send this information to a micro:bit, which can display celebratory animations to encourage you to keep moving.
New songs released:
Use IFTTT to monitor music streaming service such as spotify for new song releases or playlist updates. Triggers when a favorite artist releases a new album or when a specific song is added. Send this information to your micro:bit, which can play the newly released song.
Heartbeat:
Use IFTTT to monitor your heart rate. Have triggers when your heart rate exceeds a certain threshold or when it drops below a certain level during (relaxation). The micro:bit to respond to the received threshold data by controlling the a lamp. When the heart rate exceeds the upper threshold, instruct the micro:bit to turn on the lamp or change its color to indicate this higher heart rate state. Similarly, when the heart rate drops below the lower threshold during relaxation, the micro:bit will change then colour of the lamp to a more its colour to a more soothing tone. As well as play some songs that could clam down the user such as using the user favourite song by also connect IFTTT to spotify.


.jpg)
.jpg)







Comments
Post a Comment