Hacker News new | ask | show | jobs
by willemmerson 1275 days ago
It's not completely related but I've been thinking that having a router connected via wireguard might be a good way to do IoT deployments.

Generally IoT devices make an outbound connection to a server and use MQTTS for bi-directional data flow, because of the difficulty of inbound connections due to firewalls, NAT etc. But this has some downsides in that you have to run an MQTT server, each device is doing it's own TLS (which uses a lot of ram and increases firmware size on an ESP32), and MQTT doesn't really have end-to-end message confirmation.

It seems like a better way would be for each esp32 device to be in a wireshark network and to be running it's own HTTP webserver (which is easy to do with the SDK). Therefore any device can be sent a message from the server using a simple POST request to its ip address, and can send messages to the server using the servers HTTP api. It's much easier to test HTTP api's than mess about with MQTT, and individual devices don't need to do SSL because all data between the devices and server is encrypted by wireguard.

I suspect there's something I've overlooked, I think addressing individual devices could be difficult if you only know their IP addresses.

3 comments

That's an interesting idea, you'd probably be able to know ip addresses via wireguard. Protocols like CoAP or SenML can be used to keep payloads small.

MQTT, aside from being pubsub, has more functionality that is especially useful in IoT though: robust sessions with LW&T to monitor onlineness, and retained topics to deliver messages as devices come online again

HTTP, well, at least an implementation that allows for easy testing/human readable messages isn't particularly lightweight. I know for ESPHome, they chose to use a socket-based protobuf-esque protocol to communicate with Home Assistant. They claim it's even more lightweight and reliable than MQTT, which certainly seems reasonable given MQTT (as light as it is) has tons of functionality that isn't needed.
If your network setup (be it wireguard or whatever) is such that you're okay with plain HTTP vs HTTPS, you should also be fine to use plain MQTT vs MQTTS, right?

I agree that it's easier to test HTTP but lots of IoT stuff plays nicely with mqtt.