# Trying to send text to LCD over i2c contrib

**URL:** <https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873>\
**Category:** General\
**Created:** [1 July 2021 03:14 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873 "2021-07-01T03:14:21Z")\
**Posts on this page:** 18\
**Page:** 4

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [1 July 2021 10:19 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/62 "2021-07-01T10:19:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [2 July 2021 07:41 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/63 "2021-07-02T07:41:42Z")

</div>

Well, I heard back from the author of [node-red-contrib-i2clcd-alt - Github issue](https://github.com/tek79/node-red-contrib-i2clcd-alt/issues/2). No idea if he will go beyond _"works for me"_ or not 😛

Meanwhile I found a THIRD contrib that **does** work!! - [node-red-contrib-pcf8574-lcd (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-pcf8574-lcd)

 ![LCD in Node-Red](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b828f66b1ca4bb61c8e0441820fbf3c4b2843db5.jpeg)

```auto
[{"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 😊 Now on to more blinking vLEDs!!!

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 July 2021 11:39 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/64 "2021-07-02T11:39:54Z")

</div>

Good on you.

Glad it all works.

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [2 July 2021 22:40 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/65 "2021-07-02T22:40:43Z")

</div>

And to bring this topic's initial start back to full [MID](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/50) circle...

tek79 came out with a V2 of his contrib - [GitHub - tek79/node-red-contrib-i2clcd-alt at v2](https://github.com/tek79/node-red-contrib-i2clcd-alt/tree/v2)

```auto
[{"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 🥳 (_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** 👀 **gleing**

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [2 July 2021 22:54 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/66 "2021-07-02T22:54:55Z")

</div>

> [@Gunner](#):
>
> More **G** 👀 **gleing**

Well... that was easy

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/9/7951b7c05ee3995d5bb693d71bd65020d365be80.jpeg)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/faeb18de7baab29f89b23310e963ed22dba1356c.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 July 2021 22:57 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/67 "2021-07-02T22:57:07Z")

</div>

~~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?

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [2 July 2021 23:03 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/68 "2021-07-02T23:03:22Z")

</div>

> [@Trying\_to\_learn](#):
>
> you just stick a `change` node in there

I am resistant to change 😇 ... 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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 July 2021 23:06 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/69 "2021-07-02T23:06:49Z")

</div>

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

 ![Screenshot from 2021-07-03 09-05-48](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6aadc4bda7729a74fa21d6e6845f500151f4e2a7.png)

```auto
[{"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":""}]

```

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [2 July 2021 23:18 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/70 "2021-07-02T23:18:45Z")

</div>

> [@Gunner](#):
>
> This change node has me in a twist.

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/8/e8f1049708c082ed1bbe469f5040f175b8aaba18.png)

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 😇

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 July 2021 23:30 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/71 "2021-07-02T23:30:30Z")

</div>

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.

```auto
[{"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":""}]

```

 ![Screenshot from 2021-07-03 09-29-50](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8a2afd8e800887d5427dbcfcc8c8fe84a5c8c5a2.png)

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [2 July 2021 23:33 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/72 "2021-07-02T23:33:27Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/a/0a446a9ef2fdd4b32e9039774aaed624f6c83910.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 July 2021 23:36 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/73 "2021-07-02T23:36:05Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [2 July 2021 23:42 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/74 "2021-07-02T23:42:48Z")

</div>

> [@Trying\_to\_learn](#):
>
> What creates the message sent to `test/time` ?

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)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/f/cf2cd601b26cb5c7ea96e8984ed64345574d9c45.png)

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 🤔

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 July 2021 00:21 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/75 "2021-07-03T00:21:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [3 July 2021 01:15 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/76 "2021-07-03T01:15:07Z")

</div>

> [@Trying\_to\_learn](#):
>
> If/when you get other things/messages

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 !! 😁

 ![2021-07-02 18.06.37](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/129d881302874ac75c0955aed7fb20ac83fb628b.jpeg)

Right now [all of this](https://discourse.nodered.org/t/no0b-nr-user-just-joining-in/47385) 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 🕶

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 July 2021 01:33 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/77 "2021-07-03T01:33:36Z")

</div>

Ok,

> [@Gunner](#):
>
> They are just logic states

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.

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [3 July 2021 01:46 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/78 "2021-07-03T01:46:17Z")

</div>

> [@Trying\_to\_learn](#):
>
> Anyway, it looks like you have a good handle on this.

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. 🤣

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 July 2021 01:46 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/79 "2021-07-17T01:46:32Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873.md?page=3)
