Trying to send text to LCD over i2c contrib

So ok - sounds like that node just needs some serious debugging... but looking at it (for 30 seconds) - it looks like it just calls out to a python program anyway - so maybe you can do similar with an exec (or node-red-node-daemon) node to call one of the apps you have that does work...

No indication of that as a dependency... just the basic i2c-bus needed for all i2c stuff.

Yes, that is a workaround... if I had actual need to do so. This has mostly been a journey to see what all I can control directly from Node-Red for future projects.

I have dropped a issue post on the node-red-contrib-i2clcd-alt github page about the error the node tosses out.

As for node-red-contrib-lcd20x4-i2c well, no errors (when done right :innocent: ) so not sure what more that author could contribute.

I think I looked at a few others (for both LCD and OLED), but they where all clear they didn't work with newer Node-Red versions... I am suspecting the same might be the case here as well, even if there is no official declaration.

That's actually on my list of to-do's... figure out how nodes are actually made, and edited if need be.

well there are nodes and nodes... this is not a "normal" node... (well it is sort of... but...)

Well, I heard back from the author of node-red-contrib-i2clcd-alt - Github issue. No idea if he will go beyond "works for me" or not :stuck_out_tongue:

Meanwhile I found a THIRD contrib that does work!! - node-red-contrib-pcf8574-lcd (node) - Node-RED

[{"id":"a2844437.26c8a8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"d9e3bfca.d9957","type":"LCD-I2C","z":"a2844437.26c8a8","name":"","variant":"PCF8574AT","size":"20x4","x":380,"y":160,"wires":[]},{"id":"813f2af3.474838","type":"inject","z":"a2844437.26c8a8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"clear\":true,\"text\":\"Hello Gunner\",\"alignment\":\"left\"},{\"clear\":true,\"text\":\"I see you finally\",\"alignment\":\"left\"},{\"clear\":true,\"text\":\"got me working in\",\"alignment\":\"left\"},{\"clear\":false,\"text\":\"Node-Red.  Thanks :D\",\"alignment\":\"rignt\"}]","payloadType":"json","x":250,"y":160,"wires":[["d9e3bfca.d9957"]]}]

Guess I can call this topic solved...ish :blush: Now on to more blinking vLEDs!!!

3 Likes

Good on you.

Glad it all works.

And to bring this topic's initial start back to full MID circle...

tek79 came out with a V2 of his contrib - GitHub - tek79/node-red-contrib-i2clcd-alt at v2

[{"id":"1bac6e76.a8fcc2","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"52127114.471f9","type":"i2clcd-alt","z":"1bac6e76.a8fcc2","name":"i2clcd-alt","addr":"0x3f","bus":"1","numcols":"20","numrows":"4","x":680,"y":280,"wires":[[]]},{"id":"3bf9759f.b152ea","type":"inject","z":"1bac6e76.a8fcc2","name":"","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"line1","payload":"Hello node-red!","payloadType":"str","x":450,"y":240,"wires":[["52127114.471f9"]]},{"id":"a904459c.5e7ac8","type":"inject","z":"1bac6e76.a8fcc2","name":"","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"line2","payload":"from RPi","payloadType":"str","x":430,"y":320,"wires":[["52127114.471f9"]]}]

And it is working just fine so far :partying_face: (and I downgraded from bleeding edge node v16 to mere upper atmosphere v14)

It works nicely for sending data from MQTT sources, but the topic has to be line1...line4 so I either hardcode a subscription to it, or find a way of redirecting an existing susbscription's topic

More G :eyes: gleing

Well... that was easy

image

So if I am seeing that as right, you can delete the line1 nodes and just send test/time to the node.

Oh.... Ok. Sorry.

How abut rather then the two MQTT nodes, you just stick a change node in there and change the msg.topic to line1?

Expanding on that, why couldn't you have/put 4 MQTT nodes connected to that node:

line1 line2 line3 and line4

Then, further back in the flow you switch the messages depending on which line they are to the MQTT OUT nodes with the correct topic?

I am resistant to change :innocent: ... however in this case it makes sense, if I can get it working... so far my other method was straight forwardly intuitive. This change node has me in a twist.

This is what I am meaning - just so it is clearer.

[{"id":"58906ccc.1d740c","type":"comment","z":"32e66ed3.102772","name":"The flow which makes the message to be displayed.","info":"","x":340,"y":90,"wires":[]},{"id":"a0b7f0f5.908f78","type":"function","z":"32e66ed3.102772","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":180,"y":230,"wires":[["f5f07581.8824a"]]},{"id":"f5f07581.8824a","type":"switch","z":"32e66ed3.102772","name":"Which line?","property":"something","propertyType":"msg","rules":[{"t":"eq","v":"line1","vt":"str"},{"t":"eq","v":"line2","vt":"str"},{"t":"eq","v":"line3","vt":"str"},{"t":"eq","v":"line4","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":340,"y":230,"wires":[["c4801d37.0d8288"],["67dccc7.63bf2b4"],["b798472d.f3dca"],["ca69f0be.b19868"]]},{"id":"c4801d37.0d8288","type":"mqtt out","z":"32e66ed3.102772","name":"","topic":"line1","qos":"","retain":"","broker":"8941f4c3.0f151","x":510,"y":190,"wires":[]},{"id":"67dccc7.63bf2b4","type":"mqtt out","z":"32e66ed3.102772","name":"","topic":"line2","qos":"","retain":"","broker":"8941f4c3.0f151","x":510,"y":230,"wires":[]},{"id":"b798472d.f3dca","type":"mqtt out","z":"32e66ed3.102772","name":"","topic":"line3","qos":"","retain":"","broker":"8941f4c3.0f151","x":510,"y":270,"wires":[]},{"id":"ca69f0be.b19868","type":"mqtt out","z":"32e66ed3.102772","name":"","topic":"line4","qos":"","retain":"","broker":"8941f4c3.0f151","x":510,"y":310,"wires":[]},{"id":"b9b19385.bdf368","type":"mqtt in","z":"32e66ed3.102772","name":"","topic":"line1","qos":"2","datatype":"auto","broker":"8941f4c3.0f151","x":640,"y":190,"wires":[["b5c06505.4cc888"]]},{"id":"e3c4f7a.258a908","type":"mqtt in","z":"32e66ed3.102772","name":"","topic":"line2","qos":"2","datatype":"auto","broker":"8941f4c3.0f151","x":640,"y":230,"wires":[["b5c06505.4cc888"]]},{"id":"8eb444ad.69f8c8","type":"mqtt in","z":"32e66ed3.102772","name":"","topic":"line3","qos":"2","datatype":"auto","broker":"8941f4c3.0f151","x":640,"y":270,"wires":[["b5c06505.4cc888"]]},{"id":"c4bee0c0.4327e","type":"mqtt in","z":"32e66ed3.102772","name":"","topic":"line4","qos":"2","datatype":"auto","broker":"8941f4c3.0f151","x":640,"y":310,"wires":[["b5c06505.4cc888"]]},{"id":"b5c06505.4cc888","type":"function","z":"32e66ed3.102772","name":"i2clcd node","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":830,"y":250,"wires":[[]]},{"id":"8941f4c3.0f151","type":"mqtt-broker","name":"Local","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

And still does... this seems to be the way, but not working :frowning:

image

Of course I am trying to change from a subtopic to a topic... arrgg... I think my MQTT in to MQTT out is just fine :innocent:

Ummm.. That is msg.test not msg.topic. Won't work if it needs to be msg.topic points to the line.

Back to the example you posted with the 3 MQTT nodes.

The test/time MQTT IN node.

Connect it. hang on.

This is what I mean.

[{"id":"cc81e201.bcfe5","type":"mqtt in","z":"fe5670ff.ea94e","name":"","topic":"test/time","qos":"2","datatype":"auto","broker":"8941f4c3.0f151","x":700,"y":530,"wires":[["8cc8dade.f5a8a"]]},{"id":"8cc8dade.f5a8a","type":"change","z":"fe5670ff.ea94e","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"line1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":530,"wires":[["c1f11dc4.d81da8"]]},{"id":"c1f11dc4.d81da8","type":"function","z":"fe5670ff.ea94e","name":"i2clcd node (shown only for clarity)","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1100,"y":530,"wires":[[]]},{"id":"8941f4c3.0f151","type":"mqtt-broker","name":"Local","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

1 Like

Ah ha!! Now that works... Thanks for the clarity.

image

No problems.

What creates the message sent to test/time?

Just my other example (with the switch node and 3 MQTT nodes) would (could?) work better from that part of the flow.

I'd better shut up. I get it you have it working and are excited. That's good.

But I think you need to look at the part of the flow (if it is a flow) that makes the message and publishes it to test/time and get rid of it and put something like what I showed you.

But only a suggestion.

(I'm going off line for a while so if you don't hear back, it isn't I don't want to talk)

As I have only been at this a week or so, time is from a timestamp node conversion, as is the RPi CPU Temp, and just being published to all my testing subscribers (devices and apps)

I also have a publish for an LED on the RPi and a Relay on an Wemos D1 Mini... but they have no place on my LCD... at this time :thinking:

Ok. Looking good.

So here's a different look at what you have there.

The test/time node: Set its topic to line1.... To say.
The test/CPU node: Set its topic to line2. Then you are setting which line on the display is used there.

If/when you get other things/messages you just use (for instance) line3 and line4 as topics.

Oh! Sorry... And you need to have the MQTT IN nodes with those topics all joined together as per my example before.

Do you understand what I mean?

They are just logic states (0/1) so I plan on setting up a preset message for the other lines on the display...

I also need to clean up the CPU temperature as published (the code was copied from somewhere) as it really just needs to be the value, not all the rest as I can add that onto each specific subscriber if/as needed.

Already got rid of the unnecessary comma in the date/time so now there is room for double digit time. I have a few more days and months to fix the day and month from same.

Having Lots of fun !! :grin:

Right now all of this is just to get me familiar with all the different nodes and MQTT itself.

And the key factor of this particular topic was to help answer another members LCD question and to get yet another device to join my test group.

Mission accomplished :sunglasses:

Ok,

I think you don't quite get me. No problems.

Yeah, ok they (the other messages) are just logic states.

But making the message and displaying it are two different things.

You get a message like what you show on line 2. FOR AN EXAMPLE.
Saying that is what you get.

You can pass the message through format nodes (that will/may not be easy) and do other tricks with it to make it as you want it displayed.
That is one thing.

Then you get (have) the message. It is in msg.payload and you want it displayed.

You send the message through a change node (or not - I'll get back to that) and set the msg.topic to the line number you want.
That is then sent into the desired MQTT node which directs it to be shown on that line.

You could - rather than having 4 change nodes have the msg.topic set in the code, and all messages - irrespective of line number - go through the one MQTT out node with no topic set as that is set upstream by other nodes.

Anyway, it looks like you have a good handle on this.

Good luck with it.

1 Like

Getting the basics down... and seeing that, as with most anything, there is a bazillion ways to do the same thing, and 2 bazillion opinions as to the best way. Ahhh, choices. :rofl:

Thanks for your insights and examples, they all help with my own learning of this new toy/tool.