11

I'm working on a device that sense and collect information from the environment such as temperature, humidity, etc.

The device is not connected to any power source, but it has a battery, and a solar panel to charge it.

It's almost in a deep sleep state most of the time, and it only wake up when it need to sense and transfer data. This operation takes about 1-2 minutes, and then it goes to sleep again.

I'm not an expert in this area, but I think MQTT should be a good option if the device need to be accessible to receive messages from a topic all the time, but in my scenario it only read sensors, and send data to a server periodically.

Currently I'm sending the data through HTTP, but I'm wondering if it makes sense to implement MQTT? Should I get any advantage over HTTP for this scenario?

Helmar
  • 8,450
  • 6
  • 36
  • 84
zephrax
  • 119
  • 3

2 Answers2

9

You mention a solar panel and battery as part of the device, so you probably want to minimise the power usage during transmissions to make sure your device doesn't run out of power completely.

Therefore, you might want to consider CoAP, the Constrained Application Protocol, which is specifically designed for constrained devices in the Internet of Things.

In the paper Comparing the cost-efficiency of CoAP and HTTP in Web of Things applications, you can find some pretty compelling evidence that CoAP might get you some power savings here. In Appendix A (page 38), you can take a look at the expected battery life of devices in Table A.4. For a time interval of 120 seconds, as you're expecting in your use case:

tbat (HTTP), days — 2013

tbat (CoAP), days — 11013

Those calculations were run on a pair of carbon-zinc AA batteries, but you can clearly see that CoAP uses a lot less power, so it might be worth considering. Its 'push mode', as described in the paper, seems like exactly the sort of thing you plan to do.

Although you didn't specifically ask about CoAP, I think it's worth a mention, since Goufalite has already covered the essential differences between MQTT and HTTP. A good rule of thumb is: do you plan to communicate one-to-one, or one-to-many? If it's the former, HTTP and CoAP seem like better fits. If it's the latter, MQTT is probably more convenient.

Aurora0001
  • 18,520
  • 13
  • 55
  • 169
8

If you are storing data, simply stick with HTTP. HTTP is just a one way signal.

If your server or any other "thing" should react to a specific signal (low temperature,...) then use MQTT. Like this many devices can subscribe to your temperature signal and immediately react without using your server.

Goufalite
  • 3,776
  • 17
  • 33