1

For a university project I need to have a couple of "things" that collect data and which we will then be able to view and manipulate.

At the moment each of the devices will consist of a few sensors, connected to an Arduino MKR1010. The arduino might lose connection to wifi intermitently, when the devices are taken outside away from home wifi.

My plan was to use MQTT with a server hosted on a Raspberry Pi, which would be subscribed to the topics containing the data. Whenever the arduino regains connection to wifi, it will publish an updated reading to the Pi. The data would most likely just be integers, and we would only need to send a message every minute or so (when connected to wifi).

We are not experienced with web development or network engineering so I was going to use node-red to create a web page to view data. My question is if MQTT is a good choice for this sort of application?

1
  • MQTT broker would be good for passing messages ... collect data and which we will then be able to view and manipulate ... it would make more sense to send the data to a database server of some kind
    – jsotola
    Feb 16, 2021 at 23:56

2 Answers 2

3

MQTT is a good choice for you to send the sensor data to the central server. It is light weight and scalable. You can consume the data directly from a web interface or store it in a database. You can use node-red for creating streaming pipelines and visualizations

3

MQTT is a great choice if the application requires the following:

  • Transmission of data between devices or from device to a server
  • Reliability of data transfer
  • Capability to scale
  • Compatibility with low-power devices
  • Robust for unreliable Internet connections

It sounds like your application has these requirements and that MQTT would be a sufficient solution.

The arduino might lose connection to wifi intermitently, when the devices are taken outside away from home wifi.

MQTT uses different packets to accomplish different tasks, such as connecting to the server.

According to the documentation, "If the Server does not receive a CONNECT packet within a reasonable amount of time after the Network Connection is established, the Server SHOULD close the Network Connection."

None of the data will be sent when there is no ACK acknowledgment of the connection. Then, via the CONNECT packets, the client will also reconnect automatically to the server when back in wifi range.

You can adjust the quality of service (QoS) to three different levels in MQTT to ensure that all of your data is received by the server:

  • QoS 0 "At most Once" is the default and provides no assurance that the message is received by the server.
  • QoS 1 "At least Once" continues to send the message until receipt is acknowledged. There is a possibility of duplicate messages being sent
  • QoS 2 "Exactly Once" ensures that a message is sent without the risk of duplicates.

The data would most likely just be integers

MQTT supports a maximum payload size of 256 MB and is more than sufficient to support transmission of integers.

we would only need to send a message every minute or so

MQTT is ideal for contexts when network bandwidth is at a premium. 1 message per minute is very low bandwidth considering you are only sending integers and assuming you are not sending 256MB of integers at a time.

Reference: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901234

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.