# MQTT with Arduino Nano + NodeRed

**URL:** <https://discourse.nodered.org/t/mqtt-with-arduino-nano-nodered/37351>\
**Category:** General\
**Created:** [11 December 2020 13:22 UTC](https://discourse.nodered.org/t/mqtt-with-arduino-nano-nodered/37351 "2020-12-11T13:22:03Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 December 2020 15:39 UTC](https://discourse.nodered.org/t/mqtt-with-arduino-nano-nodered/37351/21 "2020-12-12T15:39:24Z")

</div>

I think the guts is written in C++ or C. I can't actually find the source though.

---

<div class="post-metadata">

**Author:** ![Hypnos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hypnos/32/7566_2.png) [@Hypnos](https://discourse.nodered.org/u/Hypnos)\
**Post date:** [12 December 2020 19:14 UTC](https://discourse.nodered.org/t/mqtt-with-arduino-nano-nodered/37351/22 "2020-12-12T19:14:54Z")

</div>

Maybe the Arduino Nano is not the ideally solution for your Problem.

The ESP (Esp8266 or ESP32) have Build in WLAN and MQTT libraries existing for them. The downside of this is that the ESP has higher power consumption and may less IO Ports. But there are some which has running the ESP8266 on battery's (deep sleep, etc...) and also Port Multiplexers exists.

I'm using Esp8266 for sensors/actors (connected via I2C or other) which are power connected and communicating direct over MQTT a Mosquito Broker to Node-RED.

For battery powered sensors (I2C) I also have Arduino Nano. They have a 868MHz module where they send its data to a client (RaspberryPi with also a 868MHz module), where a software receives the data from the sensors and send it to Node-RED (is running on the same RaspberryPi). This sensors should be working more than a year without the need of battery changing. There exists also other solutions (433MHz, Lora,...).

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [12 December 2020 19:45 UTC](https://discourse.nodered.org/t/mqtt-with-arduino-nano-nodered/37351/23 "2020-12-12T19:45:48Z")

</div>

@Hypnos please read the whole thread. This has been recommended several times already. But @PizzaProgram has the specific requirement that the connection has to be wired and shielded at that.

---

<div class="post-metadata">

**Author:** ![PizzaProgram](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pizzaprogram/32/19431_2.png) [@PizzaProgram](https://discourse.nodered.org/u/PizzaProgram)\
**Post date:** [23 December 2020 09:13 UTC](https://discourse.nodered.org/t/mqtt-with-arduino-nano-nodered/37351/24 "2020-12-23T09:13:40Z")

</div>

@knolleary  
@JGKK  
Thank you for both of you about the recommendations! That gave me an idea to search with other keywords, and came up with +2 more possibilities. To summarise:

1. There is [Serial2Mqtt](https://github.com/vortex314/serial2mqtt) and [Mqtt2Serial](https://github.com/vortex314/mqtt2serial)

- PRO: easy to give names to the boards (devices) so no error possible to address a wrong one.
- PRO: Can work with Serial-ETH IP too.

- CON: the gateway is not auto-searching ports.
- CON: No failsafe mechanisms. (If serial disconnects, no serial parity etc.)
- CON: only C++ examples

1. [SerialToTCP](https://github.com/RoanBrand/ArduinoSerialToTCPBridgeClient)

- PRO: Seems to have better error-handling and fail safety. (CRC32, Timeout, ...)
- PRO: downloadable .INO example
- CON: only 1 man developed it, last time 2017
- CON: not too much documentation
- CON: not sure how to handle multiple boards with it.

1. [Ardulink has an MQTT gateway](http://www.ardulink.org/how-ardulink-mqtt-works/#comment-309) too!

- PRO: Seems to be a well tested "ready-to-use" solution
- PRO: Works with AtTiny85 boards too
- PRO: Unique Serialnumber can be added to each board (But no auto-check)

- CON: Too much JAVA spec, but pure step-by-step real use-case examples. Trying to put infos together how to make it work.
- CON: serial com has Zero safety protocol.
- CON: not enough infos yet. (will edit later)

1. And found an extremely robust 1wire protocol called [PJON](https://www.pjon.org) that can use a Nano board as gateway.  
**It has a [gRPC](https://github.com/Halytskyi/PJON-gRPC/tree/master/server) subproject, and there is a ready-to-use [gRPC Node](https://flows.nodered.org/node/node-red-contrib-grpc) already.**  
_I know it's not MQTT, but on this example video it seems to work very well!_

- PRO: the PJON protocol gives a very very stable wiring possibility up to 2000m ([See...](https://youtu.be/GWlhKD5lz5w))
- PRO: up to 256 devices on 1 wire
- 
- PRO: [gRPC](https://en.wikipedia.org/wiki/GRPC) is well tested too
- PRO: Unique Serialnumber and also worldwide MAC can be added to each board and can be addressed by those !!!
- PRO: AtTiny85 support

- CON: only 3KB/sec transfer rate, (but that's fine for IO ports + sensors)
- CON: Need some Arduino boards to sacrifice to work as gateways only, not as actors. (But they are cheap 😃 )
- CON: lot's of infos to learn.

> **[Halytskyi/PJON-gRPC](https://github.com/Halytskyi/PJON-gRPC)**
>
> gRPC server-client for PJON bus. Contribute to Halytskyi/PJON-gRPC development by creating an account on GitHub.

See also: 2 router setup to speed up communication [example (link)](https://github.com/Halytskyi/PJON-gRPC/tree/master/examples/devices/two_routers).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 February 2021 09:14 UTC](https://discourse.nodered.org/t/mqtt-with-arduino-nano-nodered/37351/25 "2021-02-21T09:14:02Z")

</div>

Closed on 21 February 2021 09:14 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/mqtt-with-arduino-nano-nodered/37351.md?page=1)
