Node-red-contrib-lcd20x4-i2c Example Prob

Hi,
I currently use a LCD Display 4x20 I2C.
I loaded the driver and a sample flow. The thing actually works.
Now I want to display several data from a BME280 (temperature, humidity, etc.) (per line). The problem arises when I control the funtions flow with 3 different payloads. One alone works without problems.
Does anyone have a hint for me?

Many thanks

Thoralf

// Line Number  Msg String      Start Position  Centered
// 1            Date/Time       Ignored         true
// 2            "Test line 2."  2               false
// 3            "Test line 3."  3               false
// 4            "Test line 4."  4               false

//var sString01 = "Test line 1.";
var sString01 = msg.payload.Zeile1;
var sString02 = msg.payload.Zeile2;
var sString03 = msg.payload.Zeile3;
var sString04 = "Test line 4.";
var iPos01 = 1;
var iPos02 = 2;
var iPos03 = 3;
var iPos04 = 4;
var bCenter01 = true;
var bCenter02 = false;
var bCenter03 = false;
var bCenter04 = false;

msg.payload = {
	msgs:[
		{
			msg:sString01,
			pos:iPos01,
			center:bCenter01
		},
		{
			msg:sString02,
			pos:iPos02,
			center:bCenter02
		},
		{
			msg:sString03,
			pos:iPos03,
			center:bCenter03
		},
		{
			msg:sString04,
			pos:iPos04,
			center:bCenter04
		}
	]
};

return msg;

I wondered the same thing and worked it out as below. May not be the most elegant but it works. This is what I am using with OpenWeathermap.org as a small weather forecast screen. The "moment" node expects milliseconds where as OWM outputs "seconds" hence the conversion node for sunset. Hope the helps someone, took me a while to figure out :slight_smile:

[{"id":"85f380c9.e053d8","type":"LCD20x4-I2C","z":"f7ec13e8.052da","name":"LCD2004","speed":"3","size":"20x4","address":"0x27","x":775,"y":103,"wires":[]},{"id":"a98430c6.88ced","type":"function","z":"f7ec13e8.052da","name":"Message","func":"// Line Number  Msg String      Start Position  Centered\n// 1            Date/Time       Ignored         true\n// 2            \"Test line 2.\"  2               false\n// 3            \"Test line 3.\"  3               false\n// 4            \"Test line 4.\"  4               false\n\n//var sString01 = \"Test line 1.\";\nvar sString01 = msg.payload1;\nvar sString02 = msg.payload2;\nvar sString03 = msg.payload3;\nvar sString04 = msg.payload4;\nvar iPos01 = 1;\nvar iPos02 = 1;\nvar iPos03 = 1;\nvar iPos04 = 1;\nvar bCenter01 = false;\nvar bCenter02 = false;\nvar bCenter03 = false;\nvar bCenter04 = false;\n\nmsg.payload = {\n\tmsgs:[\n\t\t{\n\t\t\tmsg:sString01,\n\t\t\tpos:iPos01,\n\t\t\tcenter:bCenter01\n\t\t},\n\t\t{\n\t\t\tmsg:sString02,\n\t\t\tpos:iPos02,\n\t\t\tcenter:bCenter02\n\t\t},\n\t\t{\n\t\t\tmsg:sString03,\n\t\t\tpos:iPos03,\n\t\t\tcenter:bCenter03\n\t\t},\n\t\t{\n\t\t\tmsg:sString04,\n\t\t\tpos:iPos04,\n\t\t\tcenter:bCenter04\n\t\t}\n\t]\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":615,"y":103,"wires":[["85f380c9.e053d8"]]},{"id":"8787a85d.339ae","type":"inject","z":"f7ec13e8.052da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":115,"y":103,"wires":[["7bf13a26.c9e3dc"]]},{"id":"7bf13a26.c9e3dc","type":"moment","z":"f7ec13e8.052da","name":"Clock","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Melbourne","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd DD-MM HH:mm:ss","locale":"en_US","output":"payload","outputType":"msg","outTz":"Australia/Melbourne","x":270,"y":100,"wires":[["ce4981d9.5db538"]]},{"id":"ce4981d9.5db538","type":"change","z":"f7ec13e8.052da","name":"","rules":[{"t":"set","p":"payload1","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload2","pt":"msg","to":"payloadtempminc","tot":"flow"},{"t":"set","p":"payload3","pt":"msg","to":"payloadtempc","tot":"flow"},{"t":"set","p":"payload4","pt":"msg","to":"payloaddetail","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":455,"y":103,"wires":[["a98430c6.88ced"]]},{"id":"5f430fb8.9228b","type":"openweathermap in","z":"f7ec13e8.052da","name":"my city","wtype":"current","lon":"","lat":"","city":"mycity","country":"Australia","language":"en","x":55,"y":183,"wires":[["e3979798.7065a","1c44c37d.6e1415","5ef3b14f.d61b3","8e51c6b3.55a28"]]},{"id":"5ef3b14f.d61b3","type":"change","z":"f7ec13e8.052da","name":"Line 4","rules":[{"t":"set","p":"payload.ss","pt":"msg","to":"sunset","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"msg.payload.detail & \" SS:\" & msg.payload.ss","tot":"jsonata"},{"t":"move","p":"payload","pt":"msg","to":"payloaddetail","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":215,"y":243,"wires":[[]]},{"id":"e3979798.7065a","type":"change","z":"f7ec13e8.052da","name":"Line 3","rules":[{"t":"set","p":"payload.tempc","pt":"msg","to":"$string(\"Now:\" & msg.payload.tempc & \" Wind:\" & msg.payload.windspeed)","tot":"jsonata"},{"t":"set","p":"payloadtempc","pt":"flow","to":"payload.tempc","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":215,"y":203,"wires":[[]]},{"id":"1c44c37d.6e1415","type":"change","z":"f7ec13e8.052da","name":"Line 2","rules":[{"t":"set","p":"payload.temp_minc","pt":"msg","to":"$string(\"Min:\" & msg.payload.temp_minc & \" Max:\" & msg.payload.temp_maxc)","tot":"jsonata"},{"t":"set","p":"payloadtempminc","pt":"flow","to":"payload.temp_minc","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":215,"y":163,"wires":[[]]},{"id":"68317a58.eee4fc","type":"moment","z":"f7ec13e8.052da","name":"AU Time","topic":"","input":"payload","inputType":"msg","inTz":"ETC/utc","adjAmount":0,"adjType":"days","adjDir":"add","format":"hh:mm","locale":"en_US","output":"sunset","outputType":"flow","outTz":"Australia/Melbourne","x":300,"y":300,"wires":[[]]},{"id":"8e51c6b3.55a28","type":"change","z":"f7ec13e8.052da","name":"secs 2 mill","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.sunset","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"(msg.payload)*1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":135,"y":283,"wires":[["68317a58.eee4fc"]]}]

Hi @pinie_pinie ,
I was reading your post because I am battling to get the same lcd to work.
I noted you wrote "I loaded the driver". Which driver did you load? I cannot find references to a driver anywhere.
I am using this simple test code and nothing show up on the LCD.

msg.payload = {
    msgs: [
        {
            msg: "string 1",
            pos: 1,
            center: false
        },
        {
            msg: "string 2",
            pos: 1,
            center: false
        },
        {
            msg: "string 3",
            pos: 1,
            center: false
        },
        {
            msg: "string 4",
            pos: 1,
            center: false
        }
    ]
};
return msg;
[{"id":"68620dec.471824","type":"function","z":"d03db583.ed3bf8","name":"","func":"msg.payload = {\n    msgs: [\n        {\n            msg: \"string 1\",\n            pos: 1,\n            center: false\n        },\n        {\n            msg: \"string 2\",\n            pos: 1,\n            center: false\n        },\n        {\n            msg: \"string 3\",\n            pos: 1,\n            center: false\n        },\n        {\n            msg: \"string 4\",\n            pos: 1,\n            center: false\n        }\n    ]\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":620,"wires":[["37c3b15c.e271ae","89628ca2.37b84"]]},{"id":"49c51228.b9a06c","type":"inject","z":"d03db583.ed3bf8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":450,"y":620,"wires":[["68620dec.471824"]]},{"id":"37c3b15c.e271ae","type":"debug","z":"d03db583.ed3bf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":920,"y":580,"wires":[]},{"id":"89628ca2.37b84","type":"LCD20x4-I2C","z":"d03db583.ed3bf8","name":"","speed":"3","size":"20x4","address":"0x27","x":950,"y":520,"wires":[]}]

Any hint?
Thanks

Hello,

I'm not the specialist either, but maybe a few experiences.
By driver I meant loading the node for the LCD via the palette. Since you made it seem.
Important: Which I2C address does your display have? This must be set accordingly in the node. There is a contrast regulator on my display (you can turn it with a screwdriver). If it is not set correctly, you will not see anything on the display.
In your flow you always describe the same line (always the 1)
Take a look at my flow (above) I address each line individually.
Maybe my hints will help you.

pine_pinie

@pinie_pinie ,
thanks for your directions.
I have tested the LCD on I2C from a Python script and it is working. I had to adjust the contrast :slightly_smiling_face:
I tested your script, slightly modified because I don't have the weather service in place.
This the modified flow:

[{"id":"e419e96c.307c98","type":"debug","z":"6d534d3c.fd93f4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1050,"y":1120,"wires":[]},{"id":"66ca2d4d.960954","type":"LCD20x4-I2C","z":"6d534d3c.fd93f4","name":"LCD2004","speed":"3","size":"20x4","address":"0x27","x":1120,"y":1020,"wires":[]},{"id":"1f0d7.525e9f29b","type":"function","z":"6d534d3c.fd93f4","name":"Message","func":"// Line Number  Msg String      Start Position  Centered\n// 1            Date/Time       Ignored         true\n// 2            \"Test line 2.\"  2               false\n// 3            \"Test line 3.\"  3               false\n// 4            \"Test line 4.\"  4               false\n\n//var sString01 = \"Test line 1.\";\nvar sString01 = \"msg.payload1\";\nvar sString02 = \"msg.payload2\";\nvar sString03 = \"msg.payload3\";\nvar sString04 = \"msg.payload4\";\nvar iPos01 = 1;\nvar iPos02 = 1;\nvar iPos03 = 1;\nvar iPos04 = 1;\nvar bCenter01 = false;\nvar bCenter02 = false;\nvar bCenter03 = false;\nvar bCenter04 = false;\n\nmsg.payload = {\n\tmsgs:[\n\t\t{\n\t\t\tmsg:sString01,\n\t\t\tpos:iPos01,\n\t\t\tcenter:bCenter01\n\t\t},\n\t\t{\n\t\t\tmsg:sString02,\n\t\t\tpos:iPos02,\n\t\t\tcenter:bCenter02\n\t\t},\n\t\t{\n\t\t\tmsg:sString03,\n\t\t\tpos:iPos03,\n\t\t\tcenter:bCenter03\n\t\t},\n\t\t{\n\t\t\tmsg:sString04,\n\t\t\tpos:iPos04,\n\t\t\tcenter:bCenter04\n\t\t}\n\t]\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":1020,"wires":[["66ca2d4d.960954","e419e96c.307c98"]]},{"id":"3bfbf6bb.24348a","type":"inject","z":"6d534d3c.fd93f4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":330,"y":1020,"wires":[["63b32ab1.2eaf24"]]},{"id":"63b32ab1.2eaf24","type":"moment","z":"6d534d3c.fd93f4","name":"Clock","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Melbourne","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd DD-MM HH:mm:ss","locale":"en_US","output":"payload","outputType":"msg","outTz":"Australia/Melbourne","x":495,"y":1017,"wires":[["9197b194.2ceb9"]]},{"id":"9197b194.2ceb9","type":"change","z":"6d534d3c.fd93f4","name":"","rules":[{"t":"set","p":"payload1","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload2","pt":"msg","to":"payloadtempminc","tot":"flow"},{"t":"set","p":"payload3","pt":"msg","to":"payloadtempc","tot":"flow"},{"t":"set","p":"payload4","pt":"msg","to":"payloaddetail","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":1020,"wires":[["1f0d7.525e9f29b"]]}]

Basically I just replaced the data with a string.
The lcd is still not showing the content! I am going crazy with this!
I am very lost, don't know what to do next. I wonder if the LCD node is working on my Raspberry
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian

Did you install python-smbus as it tells you to in the node's description?

Hi @zenofmud ,
yes I did. I have other devices running on I2C (different addresses).

pi@raspberrypi:~ $ sudo apt-get install python-smbus
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-smbus is already the newest version (4.1-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.