New GPIO nodes for Arduino, Raspberry Pi, and lots of others including i2c support

1,817 views
Skip to first unread message

Luis Montes

unread,
Mar 13, 2015, 7:44:35 PM3/13/15
to node...@googlegroups.com
I thought it would be fun to try a different approach to what we currently have for hardware support in node-red.

The open source Johnny-Five project has had a flurry of activity in the last year to get new types of hardware supported.  This started with the nodebots movement and node-serialport connecting to Arduinos, but now includes support for new hardware in the form of IO plugins.

It makes sense to leverage the nodebots community and use the IO plugins directly in node-red.

So, I've created node-red-contrib-gpio which is a new set of input and outputs similar to the existing Arduino nodes and now including i2c support.

More information about the new nodes is here:  https://github.com/monteslu/node-red-contrib-gpio

Currently supported hardware:
Arduino/Firmata
Raspberry Pi
BeagleBone Black
Galileo/Edison
Blend Micro
LightBlue Bean
Electirc Imp
Spark Core

 Others can be added very easily.


A copule more things of note:

The johnny-five developers are currently planning SPI support, so as soon as that get finished I'll add support for it in these nodes.


Also, these nodes aren't strictly required to connect to local hardware.  I've included the ability to connect to remote hardware via TCP sockets or MQTT connections.  More info on how that works is here:  blog.iceddev.com/2014-12-05-remotebots-cutting-the-cord-with-remote-io.html
i2c.png
in_out.png

Dave C-J

unread,
Mar 14, 2015, 5:24:59 AM3/14/15
to node...@googlegroups.com
+1 - Great idea

Andrew Lindsay

unread,
Mar 14, 2015, 8:52:41 AM3/14/15
to node...@googlegroups.com
Nice, was looking for an I2C node for a particular device I'm using but in the end I'm using exec to run a command line application due to the complex nature of the device and the volume of data being passed to it. I'd still like to try a direct I2C node without having to go through the extra steps of calling the executable each time.

Cheers

Andrew

austin sandford

unread,
Mar 14, 2015, 7:01:21 PM3/14/15
to node...@googlegroups.com
Very nice. I've installed it on a Galileo v1 and is much faster to build with than Intels IoT stuff (blinking LED takes seconds to create and deploy)

One question tho', how do I access the serial pins?

Thanks once again, great stuff (installed it on my Pi2 as well)

Luis Montes

unread,
Mar 14, 2015, 11:43:25 PM3/14/15
to node...@googlegroups.com
Thanks for giving it a shot.  I didn't actually test it on Galileo, but good to see that the theory it would work turned out well :)

I'm not really all that familiar with Galileo.  Are there certain pins that have serial functionality?  Is it possible that those pins will show a serial device in the /dev filesystem when something is attached?

--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

austin sandford

unread,
Mar 15, 2015, 3:50:08 PM3/15/15
to node...@googlegroups.com
It shouldbehave like an Arduino, so serial on pins 0 and 1, but they might be available under /dev as serial devices.

Luis Montes

unread,
Mar 16, 2015, 1:25:23 PM3/16/15
to node...@googlegroups.com
StandardFirmata on the Arduino typically uses a serial device as input, but doesn't do anything special for pins 0 and 1 that it exposes with firmata calls as far as I know.  I think you'll need custom sketch to attach something else to the board if you want it to communicate from it to another device over the serial pins. There is however i2c support available that you may or may not be able to use from these nodes to achieve something similar depending on your use case.

Dave C-J

unread,
Mar 16, 2015, 3:30:27 PM3/16/15
to node...@googlegroups.com
Downstream serial support on the client is subject to discussion and work in progress... but has been there a while...

see

and

Luis Montes

unread,
Mar 30, 2015, 9:10:25 PM3/30/15
to node...@googlegroups.com
If you're using this with a raspberry pi, you now have i2c support available, just make sure to install the latest raspi-io

I made a flow to show how to use this http://flows.nodered.org/flow/f8c7a94454f79d3cfdc5
It uses an inexpensive mpu6050 accelerometer/gyro/temperature sensor.

--

denni...@gmail.com

unread,
Apr 8, 2015, 7:41:47 PM4/8/15
to node...@googlegroups.com
Hi Luis,

This looks really cool but I'm struggling to understand how to make it work. I'm hoping you might be able to point out where I'm going wrong. 
I'm using an Edison with the Sparkfun GPIO board and can turn on an LED manually using `echo 1 > /sys/classes/gpio/gpio14/value`. However nothing seems to happen when using this module - say injecting a 1 or 0 into a gpio out on the same pin (the /sys/classes/gpio/gpio14/value stays the same).

I also get no result running the following with Node (I'd expect it to blink on and off every half-second):

var five = require("johnny-five");
var Edison = require("galileo-io");
var board = new five.Board({
  io: new Edison()
});

board.on("ready", function() {
  console.log("READY");
  var byte = 0;
  
  setInterval(function() {
    board.digitalWrite(14, (byte ^= 1));
  }, 500);
});


Cheers,
Dennis.

Luis Montes

unread,
Apr 9, 2015, 9:58:48 AM4/9/15
to node...@googlegroups.com
I haven't actually done any testing with galileo-io, but if something is preventing the johnny-five code from working, the same problem would be present in this node-red node.
Which sparkfun board are you using specifically?  It's possible that galileo-io only supports whatever is onboard, and not additional pins from a breakout board.  The galileo-io example uses pin 9, could you give that a shot?


--

Dennis

unread,
Apr 9, 2015, 9:36:39 PM4/9/15
to node...@googlegroups.com
Hi Luis, I'm using this board - https://learn.sparkfun.com/tutorials/sparkfun-blocks-for-intel-edison---gpio-block?_ga=1.28720700.1418046343.1428462829 . As far as I can tell there's no pin 9.

I think the problem is probably in johnny-five or the galileo-io modules. The documentation for galileo-io doesn't mention sparkfun gpio boards; but it looks like what it's doing should work. There's a few things I'm unclear on though so I'll contact the johnny-five dev as well.

Thanks!

-Dennis

You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/6S-I1IeJCrE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

Hans Jespersen

unread,
Apr 10, 2015, 2:05:01 PM4/10/15
to node...@googlegroups.com
I have both Johnny-Five and Cylon working using galileo-io with an Intel Edison with the Arduino breakout board and Grove Start Kit sensors.

I also have a Sparkfun Edison with the GPIO block (and a lot of the other goodies) but I have not yet hooked anything up to my GPIO block. Let me know if you want me to test for any differences between J5 or galileo-io on the two different breakout boards. I do remember seeing some talk about one of the sparkfun GPIO pins being stuck low but I can't remember which bulletin board it was on. I will post back if I find it

-hans

Hans Jespersen

unread,
Apr 10, 2015, 3:21:25 PM4/10/15
to node...@googlegroups.com
Looking at the mapping between the Arduino Shield PINs and the Native Edison PINs it's not clear if you need to use PIN 14 (GPIO) or PIN 44 (Linux) with galileo-io

http://www.emutexlabs.com/project/215-intel-edison-gpio-pin-multiplexing-guide

The yocto linux device drivers and the mraa libraries use the Edison pinouts.

Dennis

unread,
Apr 11, 2015, 8:45:32 AM4/11/15
to node...@googlegroups.com
Hi guys. After some looking I found the following table showing how the Edison pins are labelled in MRAA: 

http://iotdk.intel.com/docs/master/mraa/edison.html

This was the info I was missing. Tested and this works (my LED flashes!). It's not very bright but I'll investigate that with a multimeter.

Luis Montes

unread,
Apr 11, 2015, 4:03:11 PM4/11/15
to node...@googlegroups.com
Awesome.  Glad its working.

As for the dim LED, you might need to make sure you have the latest version of node-red-contrib-gpio
On an earlier version I was accidentally setting pin mode to PWM instead of Digital mode in some cases.  May or may not be the problem here, but worth a check.

You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

Hans Jespersen

unread,
Apr 12, 2015, 12:42:47 PM4/12/15
to node...@googlegroups.com
The dim led might just be because it's 3.3V. The other Edison breakout boards level shift to 5V.

Blue Collar Ingenuity

unread,
Dec 9, 2015, 11:12:06 AM12/9/15
to Node-RED

Hi Luis


The johnny-five developers are currently planning SPI support, so as soon as that get finished I'll add support for it in these nodes.

I know I'm getting a little ahead of myself. Arriving any day is a  MAX6675 Module + K Type Thermocouple and a bunch of NodeMcu Lua ESP8266 WIFI Internet Development Board
The goal is to use the thermocouple to report my woodstove temperature over wifi with MQTT to NR. That's the goal! 
One of the primary things I would like to learn is how to directly connect the module and thermocouple directly to my PI IO. I'm struggling to find instructions on SPI setup with NR. Is this possible? 
Jeff 

Julian Knight

unread,
Dec 9, 2015, 4:28:06 PM12/9/15
to Node-RED
What would be really cool (or hot actually!) would be the ability to power the whole thing from the heat output of the stove :)

Luis Montes

unread,
Dec 9, 2015, 4:36:18 PM12/9/15
to node...@googlegroups.com
SPI isn't yet supported with johnny-five and its IO classes including raspi-io.  The pi has hardware spi, so you could in theory write a script that can be called from the exec node.

As far as ESP integration with node robotics goes, there's a ton happening in that space.  Right now you can use the esp as a serial gateway to relay data from tcp or udp as described here: https://gist.github.com/ajfisher/5fe60fe7d8c49b3223f0  
node-red-contrib-gpio has support for that if you relay to something that can run firmata like an arduino uno.

Really looking forward to seeing an esp firmware that can speak firmata over mqtt with gpio access locally :)


--

Blue Collar Ingenuity

unread,
Dec 9, 2015, 5:07:54 PM12/9/15
to Node-RED
What would be really cool (or hot actually!) would be the ability to power the whole thing from the heat output of the stove :)

This has potential :)  

Message has been deleted

Swapan Sarkar

unread,
Jan 6, 2017, 11:27:31 PM1/6/17
to Node-RED
Any update on SPI support ?

Luis Montes

unread,
Jan 9, 2017, 11:57:31 AM1/9/17
to node...@googlegroups.com
Some very good news on this front.

Jeff Hoefs (@soundanalogous)  has been working on getting SPI into the firmata protocol:  https://github.com/firmata/protocol/pull/27  as well as the arduino implementation: https://github.com/firmata/arduino/pull/341

Firmata.js support will likely happen as soon as the protocol and arduino implementations are ready.  This is where using johnny-five really shines.  Since firmata.js is the basis of johnny-five IO adapters, the other IO adapters such as raspi-io and beaglebone, etc.  will have a target API to also expose SPI support.

And I'll get this into the gpio nodes as soon as it lands :)



--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack

---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/8cebba32-57a0-4620-9dde-63cbe208d447%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages