I have always used a local broker on a Raspberry Pi. I would like to be able to send and receive commands and data from a device on another LAN or WAN using MQTT.
So, what are my options? Do I just expose my Raspberry Pi broker to the WWW, or can I do this with a public broker, like HiveMQ?
Depending on your router capabilities you could setup VPN tunnels between the sites.
Exposing a server to the web is a different matter altogether. As a bare minimum you need to enable ssl and user/pass authentication. Ideally you would also restrict the range of IP addresses that you accept connections from. Checking for security advisories and keeping your system patched up to date is something that you'll have to do every day (even when you're on vacation). The easy option is to pay for a service that does this all for you.
I won't have access to the remote router.
So, if I pay for a MQTT broker service, it won't matter how the nodes are connected to the web? Do you have a recommendation for a low-volume provider (like, at most, a few kB per day).
Is there going to be a lot of traffic or is any of the traffic sensitive information?
I use MQTT at home to send sensor readings to my home RPi server and then it logs/displays the data using Node-Red but also pushes the data to dweet.io. From work I use Node-Red to read the dweets and display the results on a dashboard, essentially mirroring what I get on my home network but without opening or forwarding router ports.
As the data frequency/usage is light (about once per minute at most) and is not critical (just weather sensors) a free dweet.io account is fine for my needs.
Note free means no QOS or uptime guarantees. And no privacy. Anyone can publish/subscribe to any topic. HiveMQ also has a free public broker but I have not tried it.
SteveMann:
I never heard of Dweet.io before. It looks promising. Can you share your Node-Red flow. please?
I have not included my flow as it has other stuff that is sensitive to me like API keys and my dweet.io things GUID's but I have knocked up a simple example for you to get the idea.
You will need to add node-red-node-dweetio from the pallet menu and to simplify things I have not used the dashboard but routed to debug nodes instead but included a screen grab of the Dashboard output
To give a bit of background, my sensors either send data direct to MQTT over WiFi (indoors) or via LoRa (outdoors) to a gateway on my network that forwards to MQTT.
The sensors send the data in a JSON string (example below) that consists of...
D = Device (L3 in the example)
N = Packet number
T = Temperature
P = Pressure
A = Altitude
H = Humidity
L = LUX light level (not all sensors have this)
V = Battery voltage
RSSI, SNR & F_ERR are only relevant to LoRa packets
TIME = Time of sensor reading.
{"D":"L3","N":24,"T":20.67,"P":1008.08,"A":43.17,"H":57.52,"L":0,"V":3.91,"RSSI":-70,"SNR":9,"F_ERR":26801,"TIME":"Sat, 31 Aug 2019 08:34:53 GMT"}
To make charting the data more readable I pad out any missing values with a preset so for example the above L3 sensor does not have a LUX light level reader so I pad with 0.
Thanks, it does help.
So, if I understand, I could set up a dweet node in Node Red to send my local temperature every minute, and anyone with my-thing-name could receive it?
All kinds of possibilities come to mind.
I haven't done anything with LoRa yet, no projects yet, but it's definitely something for my bucket list.
SteveMann:
So, if I understand, I could set up a dweet node in Node Red to send my local temperature every minute, and anyone with my-thing-name could receive it?
Yes, I personally use a GUID number as my thing so it's less likely to conflict with other peoples things. As mentioned in my first reply you should not use dweet.io for sensitive data unless you pay for the private key and encrypt the data.
All kinds of possibilities come to mind.
Depending on what you want to do with the data you might also consider something like Cayenne of another IoT dashboard. I used to use Cayenne but gave it up and went down the dweet.io path when it stopped supporting IOS9.
I haven't done anything with LoRa yet, no projects yet, but it's definitely something for my bucket list.
My LoRa devices are LoRa32u4 II boards with BME280 and some also with MAX44009 sensors. Early days on testing but they lasted for about 4 months on a 18650 battery charge but I keep tweaking the code to improve battery life so have yet to get a final life expectancy.