Help with i2c lcd node


I have been trying ti display data to lcd using the node-red-contrib-lcd20x4-i2c node. It seems to auto detect the i2c address and the screen initialise.
I am struggling to try to display something by using an inject node with change node trying to change the payload to msg.payload.msgs, but got all confused.
Would appreciate a simple example to display "hello world"

This is all the description I can find:
This node will accept an object msg.payload.msgs. If the object passed does not contain 4 lines, the difference is filled with blank lines.

Line data structure:
msg must be a string.
If msg is more than 20 characters the node will handle scrolling.
pos (position) is optional and must be a number with any value between 1-20. This value is used for offsetting text, but you can also insert spaces in to msg instead of supplying pos.
If pos is not supplied it will default to 1.
center is optional and must be a boolean value passed as a string
If pos and center are both set, center will override pos.

If there is an error it will be logged to Node-RED and display an error on the LCD screen.

Object format:

msg.payload = {
msgs: [
msg: "string",
pos: number,
center: "boolean"
msg: "string",
pos: number,
center: "boolean"
msg: "string",
pos: number,
center: "boolean"
msg: "string",
pos: number,
center: "boolean"


Try this out and see if it does anything
(Connect the output of the inject node to your LCD node)

[{"id":"abf6c8da.45ec38","type":"inject","z":"ad22efea.cbfb2","name":"","topic":"","payload":" { \"msgs\": [ { \"msg\": \"Hello World\" }]}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":200,"wires":[["8128fb15.752488"]]},{"id":"8128fb15.752488","type":"debug","z":"ad22efea.cbfb2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":480,"y":200,"wires":[]}]


Hi @cymplecy,
Thanks for that, it works! I tried all sorts of combinations for hrs and had even tried :
{msgs:[{"msg":"hello world"}]} in a change node before but had an error, obviously msgs needs to be "msgs".

Great this forum, and kudos to the gurus. Just make learning so much easier and quicker.

So much to learn...




Hi @kenkoknz
i think i am struggling with the same problem like you did. Can you paste your working flow for me? What display are you using?

Thanks for your help,

regards Thomas


Guys I had the same time wasted when the first time I configured it.. so feel half happy, it's a common problem with this module.
It is just because the author haven't posted an adeguate example to clear it. Honestly I don't like when this happens, and unfortunately it happens quite often on Github..add an example like the following one is nothing, very easy, and saves hours of time and bad words ((

You need to buid a function which returns a msg.payload with the object msgs,
for example:

var yes-I-want-to-write-LCD=true;
var external-string="fourth line start at 1 and not centered";
if (yes-I-want-to-write-LCD===true) {msg={payload:{msgs: [{msg: "text in first line", pos: 1, center: false},{msg: "second line centered", pos: 1, center: true},{msg: "third line shifted by 2", pos: 3, center: false},{msg:external-string }]}}};
return msg;

I think you can guess now


Often, to original authors, things seem obvious that are not at all obvious to others coming along. The best action would be for you to amend the docs appropriately and submit a Pull Request. Documentation is often better to be written by the users than the author.


True, and something for the open-source community to think about.:slightly_smiling_face: