I think Node Red has broad applications in robotics and I was wondering if anyone can recommend some good motor shields that play nice with Node Red. Currently I am using Arduino over serial which works but it would be nice to have a more direct solution to control servos, steppers and motors.
Well you could control motors direct from a Pi which will run Node-RED. To be honest though, I never try using the Pi GPIO, I've always found it much better to use an Arduino with custom code and a simple serial interface.
There are several ways to control an Arduino from a Pi running NR - including Firmata which is possibly the simplest. You load the Firmata sketch onto your Arduino and use the node. It is all documented here in the docs:
If you really must control the motor direct from a Pi, you will need to take care as the Pi GPIO is unbuffered and it is pretty easy to blow the Pi. So take care how you wire things.
Arduino may be the answer in the end. With firmata, I can control a servo with no additional motor shield. For robotics, Arduino gives you the option of running your 'firmware' program so Node Red just needs to send a message like 'go to x, y position'. Then Arduino handles the PID to accelerate and then decelerate to arrive at the desired position. Also, Arduino has no shortage of motor shields and controllers.
In a discussion regarding solar motor control, this came up
Is this something that is in the direction you are looking for?
One approach I'm playing around is having a python program running on a Pi to do the heavy lifting of controlling H-bridges, steppers etc and use MQTT to receive commands and publish sensor updates to Node-RED
I found this I2C motor driver that I might try out:
The Arduino library it uses gives some hints on what messages to send it with an I2C node in Node Red.
I will have to buy a couple of them and see how well they work. It should be easy to daisy chain as many as you want.
This just showed up in my email.
Adafruit just came out with a very cool robotics hat for the Pi:
It is very cool!
- 4x analog or digital servo control, with precision 16-bit timers.
- 2 x bi-directional brushed DC motor control, 1 Amp current-limited each, with 8-bit PWM speed control (or one stepper).
- 4 x high-current “Darlington” 500mA drive outputs with kick-back diode protection. For solenoids, relays, large LEDs, or one uni-polar stepper.
- 4 x capacitive touch input sensors with alligator pads.
- 8 x signal pins, which can be used as digital in/out or analog inputs.
- 1 x NeoPixel driver with 5V level shifter – this is connected to the seesaw chip, not the Raspberry Pi, so you won’t be giving up pin 18. It can drive over 100 pixels.
- 1 x Class D, 4-8 ohm speaker, 3W-max audio amplifier – this is connected to the I2S pins on the Raspberry Pi for high-quality digital audio. Works on any Pi, even Zeros that don’t have an audio jack!
- Built-in USB to serial converter. The USB port on the HAT can be used to update the seesaw firmware on the Crickit with the drag-n-drop bootloader, or you can plug into your computer; it will also act as a USB converter for logging into the console and running command lines on the Pi.
It uses a python library but since I2C is used, I could see easy integration with Node Red.
I just made a prototype for controlling a window blind with nodered.
Hardware = esp32 board + stepper + TB6560
Software = simple MQTT messaging
It was for a demo project for my students and I was hurry so it's not finished at all and needs improvement but it works well (sorry I have no photos right now).
Improvements : hardware is not adapted : a shield with a A4988 driver would be more practical and compact. An absolute positionning system would be welcome for initialisation and cumulate user direct interaction and remote control (I think about a magnetic sensor).
Ya, when you get a chance, I would love to see pictures and flows.
On your esp32 board, did you just use Arduino IDE to program it?
For flows it's nothing more than an MQTT Publish (I just input the value from an inject or Slider from UI-Dashboard). The ESP32 (programmed with Arduino) just get the value from MQTT and apply it.
Some photos :