Dumbing down my arduino to work with Node-Red

Hey All,
I'm a hobbyist and have been developing home automation for about 15 years. I started with just an Arduino and later paired it up with a Raspberry Pi. It's been incredibly slow and arduous but I've stuck with it.

I discovered Node-Red about a month ago and I've barely slept since :wink: What a revelation! OMG! I LOVE NodeRed!

So now my strategy is to dumb down my Arduino, which is doing primarily running PIR sensor and controlling 12V LED lights, and let NodeRed do most of the work. I love the idea of never writing a timer or chasing down syntax errors in Arduino ever again!

Basically all I need the Arduino to do is sense motion and trigger the LEDs and Node-red would do the rest. So my question now is what's the best path forward?

I've read about Firmata for Arduino which sounds interested but I've never used it.

But it seems like it'd be relatively easy to hand code the Arduino for this basic functionality.

What are the best practices here?

There are many options for the Arduino you could use things like ESPHome or ESPEasy and then send the data/commands back and forth using MQTT. It all depends on what is being done.

Take a gander thru the Share Your Projects section of the forum to see what people are doing and feel free to ask people questions.

You can install Mosquitto on the pi to act as the broker.

If you want to learn more about MQTT then see this tutorial MQTT Essentials - All Core Concepts explained

1 Like

How is your Arduino connected to the Pi?

A lot of people use sensors or relays connected to an ESP8266 instead of an Arduino, because the esp has Wifi and can be flashed with Tasmota as an easy alternative to the Arduino IDE.
Communication to Node-red on a Raspberry uses MQTT over the network.

1 Like

The Arduino and the Pi are connected via serial. I have Mosquitto running on the Pi connected to several esp8266 boards as well.

Wow TASMOTA looks interesting. For those reading this thread check out

If it is serial connected then you can just continue to use that and send data over serial. One simple "upgrade" would be to format the data as json strings as they will be easy to parse on the Node-RED side...

As also mentioned you could also use the the ESP8266 boards to send data directly over wifi (or from arduino to esp and then over wifi).

1 Like

I did this journey a few years ago and what i found worked best was to use an ethernet hat for the arduino (i temporarily migrated the stuff to a Mega so i had enough I/O for an ethernet shield)

I then implemented Nick Olearys excellent MQTT library for the Arduino and had it run in a tight loop on the Arduino and then started using variables on the Arduino to transfer the results of outputs from the Arduino sensors into the MQTT loop and across to Node Red.

As i became more familiar with NR and Arduino i then started taking whole roles/functions from the Arduinos (i had 4 of them) and moving them onto discrete ESP devices with their own copies of Tasmota running - i started with Temperature and Humidity sensing, then some light sensors and then finally relay actuators to enable motors, pumps and the like.

At first (as i had all the Home Automation logic built into one of the Arduinos) i was only using NR for a Browser based interface and then gradually started moving discrete functions across from the Arduino environment into NR.

Eventually i moved all the functionality across and was able to retire the arduinos - i only have a couple of custom ESP8266 boards left now - most of my stuff i try and do with Sonoff style devices flashed primarily with Tasmota.


1 Like

Great for the enthousiasm but be carefull not to go down the rabbithole. I think with the current project you can try firmate. The GPIO of the arduino will become available in Node Red and simple tasks like a PIR sensor you can program then from Node Red. I have several Firmata instances running. And ofcourse afterwards go to Tasmota for some remote(from the pi) microcontrollers.

Check this out: We created Node-RED for Microcontrollers! Should play nicely on your board(s) & connect the two worlds...

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