Nodered + LCD via i2c question

2,072 views
Skip to first unread message

Luca PERENCIN

unread,
Mar 15, 2016, 8:44:00 PM3/15/16
to Node-RED
Hi all, i'm just making some tests with  nodered + i2c + LCD display and i need some suggestions from you.
I have a classic lcd1602 display, but with piggyback i2c module, so i decided to use it in the "i2c way" and not in the standard way (using the pins directly)

For the first test, i have attached the display to an Arduino and fired some chars via i2c library just to test if was working, then i've tested the serial to i2c on the Arduino via the serial node on nodered (works well!) but it's a waste of resources to use an Arduino only to drive a LCD, so i have attached the i2c to the raspberry pins directly, and tested via python scripts.

At this point, i have a valid python script to use, so i tried to use an exec module to call the script and pass the payload to display, but i'm a bit stuck on the correct call of the script / directory. 
my syntax, on the exec module is like: 

(/usr/bin/)python2 ./python-i2c-lcd/display.py

but i'm still getting error:

/usr/bin/python2: can't open file './python-i2c-lcd/display.py': [Errno 2] No such file or directory 

My question is... there is a (more) efficent way to call this script? I think that a dedicated node will be the best, but, at the moment, i'm not skilled enought to build one.

Dave C-J

unread,
Mar 15, 2016, 10:43:30 PM3/15/16
to node...@googlegroups.com
When you use  ./python-i2c-lcd/display.py
 the ./ means "in the current directory" (effectively) - so that is relative to the place where Node-RED is running.... so you may want to actually point it to the absolute directory instead - eg 
   /usr/bin/python2  /home/my_userid/some_directory/python-i2c-lcd-display.py
modified as appropriate.

As for more efficient ways - it depends what else the .py script does... there are several similar examples we use to talk to the pi gpio that would be a good (or not bad) place to start from...

Luis Montes

unread,
Mar 15, 2016, 11:54:46 PM3/15/16
to node...@googlegroups.com
Just curious is it one of the i2c controllers listed here?  http://johnny-five.io/api/lcd/#parameters

If so, you can always use node-red-contrib-gpio and use the LCD api without having to drop into python at all :)
 

--
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+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Luca PERENCIN

unread,
Mar 16, 2016, 3:54:49 AM3/16/16
to Node-RED

Hi Dave.
Thanks for your reply.. It was, effectively, an absolute path problem!
Now the script is called correctly and the message displayed on the LCD
thanks again


Remind to self: stop "late night" test! :D

Luca PERENCIN

unread,
Mar 16, 2016, 3:57:10 AM3/16/16
to Node-RED
Hi Luis

Yes is a PCF8574A Controller, so i will try to install the relative node + plugin to test it
thanks!
Message has been deleted

Marko S

unread,
Mar 16, 2016, 11:11:40 AM3/16/16
to Node-RED
If you are gonna go with the direct GPIO route I'd be interested in how you will achieve it. So I could replicate it and display some MQTT data on the lcd :).

Dne sreda, 16. marec 2016 08.57.10 UTC+1 je oseba Luca PERENCIN napisala:

Dave C-J

unread,
Mar 16, 2016, 12:02:45 PM3/16/16
to node...@googlegroups.com
If you want direct gpio and have an HD44780 style LCD (typically cheap 1,2 or 4 lines by 16 or 20 chars) - then we have the node-red-node-pilcd node - http://flows.nodered.org/node/node-red-node-pilcd

Marko S

unread,
Mar 17, 2016, 11:28:59 AM3/17/16
to Node-RED
I'd preffer a i2c-lcd (the PCF variant which i have at hand). 

Dne sreda, 16. marec 2016 17.02.45 UTC+1 je oseba Dave C-J napisala:

Luca PERENCIN

unread,
Mar 17, 2016, 11:45:40 AM3/17/16
to node...@googlegroups.com
I'm experiencing some problems with the johnny-io module.
trying to send i2c request to local raspberry.
the gpio module crash the server, causing a restart loop. 
The only way to restart it is to manually delete (or maybe edit ) the flows_raspberrypi.json

i've to better investigate to understand what is really happening

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
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/AboTCK-otLU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.



--

------------------------
Luca PERENCIN
------------------------

Mark Setrem

unread,
Mar 17, 2016, 12:28:24 PM3/17/16
to Node-RED
Luis, the author of the node-red-contrib-gpio node often is on here.  
But it is probably better to open an issue on the github repository for the node.

Luis Montes

unread,
Mar 17, 2016, 12:36:13 PM3/17/16
to node...@googlegroups.com
On raspi, even though we're supposed to have non-sudo gpio access on latest rasbian, I've still had to run things as root.

I've successfully used i2c with node-red-contrib-gpio for oled screens. Some more details here:  https://github.com/rwaldron/johnny-five/wiki/Getting-started-with-Raspberry-Pi-node-red-and-IoT

Definitely open an issue though if you don't get this quickly sorted.  

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.

Luca PERENCIN

unread,
Mar 17, 2016, 1:11:55 PM3/17/16
to node...@googlegroups.com

OK, thanks Luis
I'm just going to replicate the same conditions to give a better  issue report

BTW, running things as root is not exactly what I like, but I will try to follow your tutorial. I'm setting up a new raspi ( ver 3 ) with a clean raspbian, so will be a good opportunity to test it.

Luca Perencin / via smartphone

Dave C-J

unread,
Mar 17, 2016, 1:36:56 PM3/17/16
to node...@googlegroups.com
Luis

wonder if there is a setcap equivalent that would allow it - much like the one for raw network to allow BLE without sudo...

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

Marko S

unread,
Mar 18, 2016, 8:43:35 AM3/18/16
to Node-RED
Luis would be really nice if you could also add a 16x2 or 20x4 i2c example to the wiki :D. For some of us which are noobs :D

Dne četrtek, 17. marec 2016 17.36.13 UTC+1 je oseba Luis Montes napisala:

Sumarsono -

unread,
Sep 18, 2016, 7:19:15 AM9/18/16
to Node-RED
I have 16x2 LCD with i2c backpack, too. Would be nice for me as noob, if there is a node for that.

Dave C-J

unread,
Sep 18, 2016, 9:46:17 AM9/18/16
to node...@googlegroups.com
well you could do worse than try to include this library below via settings.js (see global context section of http://nodered.org/docs/writing-functions#other-modules-and-functions

Bruce Richardson

unread,
Oct 26, 2016, 10:42:51 AM10/26/16
to Node-RED
good call, I just got this working. There was an issue with the i2c library it uses, but it just needed a later version in the package.json file. Hopefully the owner will update the github version. 

idb

unread,
Dec 6, 2016, 5:10:21 PM12/6/16
to Node-RED
Actually, I found https://github.com/craigmw/lcdi2c to be a better module. It also has custom characters. Works with node-red after including the library in global context.

Op woensdag 26 oktober 2016 16:42:51 UTC+2 schreef Bruce Richardson:

Justin Haury

unread,
Mar 9, 2017, 2:41:18 AM3/9/17
to Node-RED
You were able to get that node to show up in Node-Red as a node? Could you spare a few minutes and help an amateur out, how did you do that? Include the library in the global context? I have been unsuccessful in getting my LCD w/backpack to work.

I have read you can get NPM nodes to show up in NR too, is this how it is done?

Julian Knight

unread,
Mar 11, 2017, 1:01:53 PM3/11/17
to Node-RED
To use a node.js module in a Node-RED function you first have to add a require to the globals section of settings.js. That gives you access to the module in a global variable:

fs: require('fs')

Then in your function node, you have to create a specific reference to that global:

var fs = global.get('fs');

Now you can use the module as normal within the function node.
Reply all
Reply to author
Forward
0 new messages