# 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:** 20\
**Page:** 1

<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:** [1 July 2021 03:14 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/1 "2021-07-01T03:14:21Z")

</div>

While pointing out the search options for another member looking to write to an LCD, I decided to try it myself.

I setup a Sainsmart 2004 LCD with I2C backpack onto my RPi.

Tested it with some Python code... yes, my setup is a bit "how ya doin" but it clearly is working 🙂

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/8/f8ca4f7f9e8b40c08d595986fc3126530a01d491.jpeg)

Now the issue I have... I am trying out this contrib - [node-red-contrib-lcd20x4-i2c](https://flows.nodered.org/node/node-red-contrib-lcd20x4-i2c) as it best matches the hardware. It is older, but doesn't seem to state any version limits.

On that note, I am running NR v1.3.5

The issue I am running into is shear ignorance 😊 when interpreting the directions... in short form here...

**This node will accept an object `msg.payload.msgs** - Umm what?

**Object format:**

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

```

I tried many other random variations... but this doesn't throw a deploy error...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/1/9115a8fbef822352bf861d49f5c657b9c3f68aa1.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/3/13ca15cdc9e81073f52ce465b3f65f03ec40e568.png)

with actual text being...  
`{msgs: [{msg: "Hello",pos: 0,center: "false"}]};`

No errors, but nothing on the LCD either.

Am I even injecting this correctly?

---

<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:** [1 July 2021 03:24 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/2 "2021-07-01T03:24:11Z")

</div>

I rebooted the RPi (my go to for troubleshooting 😛 ) and ran it again... this time I do get an error...

```auto
6/30/2021, 8:22:42 PMmsg : string[72]

"msgs Value not Defined: {msgs: [{msg: "Hello",pos: 0,center: "false"}]};"

6/30/2021, 8:22:42 PMmsg : string[46]

"Error Sending Message to LCD - See Error Above"

6/30/2021, 8:22:43 PM[node: 1e1df103.6cf1ef](http://10.10.3.13:1880/#)msg : error

"TypeError: Cannot read property 'stdin' of null"

```

So apparently I am NOT injecting the payload correctly? At a loss ☹

---

<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:** [1 July 2021 04:34 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/3 "2021-07-01T04:34:25Z")

</div>

I tried a template node...

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

Position 0?? the template starts at 1

At this point I am just banging keys like a 🐒

---

<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:** [1 July 2021 04:45 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/4 "2021-07-01T04:45:27Z")

</div>

```auto
6/30/2021, 8:22:42 PMmsg : string[72]

"msgs Value not Defined: {msgs: [{msg: "Hello",pos: 0,center: "false"}]};"

6/30/2021, 8:22:42 PMmsg : string[46]

"Error Sending Message to LCD - See Error Above"

6/30/2021, 8:22:43 PM[node: 1e1df103.6cf1ef](http://10.10.3.13:1880/#)msg : error

"TypeError: Cannot read property 'stdin' of null"

```

The problem is the nested " in the line.

Someone else had that problem.

`"{msgs: [{msg: "Hello",pos: 0,center: "false"}]};"`

To help, stick a `debug` node just before that node and set it to show the whole message.

Copy that and paste it here.

---

<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:** [1 July 2021 04:50 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/5 "2021-07-01T04:50:47Z")

</div>

```auto
6/30/2021, 9:48:40 PM[node: 37116244.613c4e](http://10.10.3.13:1880/#)msg.payload : string[48]

"{msgs: [{msg: "Hello",pos: 0,center: "false"}]};"

```

Looks the same coming out as it did going in 😛

---

<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:** [1 July 2021 04:59 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/6 "2021-07-01T04:59:09Z")

</div>

Ok. (I'm not an expert)

First thing is I think you are using the wrong node.

`template` isn't the one you want.  
I should have picked that up sooner, but I'm not _running on all cylinders_ just now.

Try a `function` node.

Paste the example from the node's page into there and see what happens.

So basically open the `function` node, delete anything there and paste this:

```auto
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"
        }
    ]
};

```

Give that a try.

I think that will go a long way to helping you.

---

<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:** [1 July 2021 05:12 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/7 "2021-07-01T05:12:39Z")

</div>

> [@Trying\_to\_learn](#):
>
> So basically open the `function` node, delete anything there and paste this:

Done... and _nothing_ appeared on the debug, nor did the LCD node give any indication it received anything... just kept saying **Stopped**

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/7/d7e8f179b0de7e374d963b79176aa4bc7ed0dfff.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/75b7c785517b2c06952a230e3889e548944b13a1.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:** [1 July 2021 05:15 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/8 "2021-07-01T05:15:38Z")

</div>

No problems.

First thing - BTW, lucky I have one of these (or similar) so I am checking here myself and if I can get it working it would be great.

Ok, first big thing is the RED mark on the node.

if you run the command `sudo i2cdetect -y 1` what do you see?

It should show you the address of the display. If that isn't set correctly: all bets are off.

Let's start with that. Sorry, but this is going to be a bit of a long way of doing it.  
But I'm not doing too much else just now.

I don't think it is seeing the display.

---

<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:** [1 July 2021 05:17 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/9 "2021-07-01T05:17:48Z")

</div>

> [@Trying\_to\_learn](#):
>
> `sudo i2cdetect -y 1`

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

Remember, I have tested OK with python code right on the RPi.

---

<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:** [1 July 2021 05:18 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/10 "2021-07-01T05:18:21Z")

</div>

Ok, so you have the address set to 3F I guess?

Ok!

# hang on.

Mine shows up as `72`. But I guess that depends on other thigns.

What are the other two things? Do you know?

If you remove the display does the `3F` go away?

---

<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:** [1 July 2021 05:19 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/11 "2021-07-01T05:19:15Z")

</div>

But whether any of the nodes I have tested (about 3 or 4 so far) can connect is a big, dunno

---

<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:** [1 July 2021 05:20 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/12 "2021-07-01T05:20:37Z")

</div>

Ah, yeah, sorry. Apologies.

I think I went down this track and gave up.

I got someone else to help me write some code to display messages on the display.

That works 99.9% of the time.

I can share if you want.

---

<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:** [1 July 2021 05:21 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/13 "2021-07-01T05:21:07Z")

</div>

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

> [@Trying\_to\_learn](#):
>
> What are the other two things? Do you know?

Yes... one is a PWM board and the other is a BrightPi camera light. I have tested with them disconnected as well

---

<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:** [1 July 2021 05:23 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/14 "2021-07-01T05:23:32Z")

</div>

The docs are poorly written IMO. the "boolean" designation is confusing.

I am suspicious it should be simply boolean.  
so the line would actually be:

`center: true` or center: false`

---

<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:** [1 July 2021 05:23 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/15 "2021-07-01T05:23:36Z")

</div>

> [@Trying\_to\_learn](#):
>
> I can share if you want.

Sure!!!... although the main goal was to learn how to properly inject these commands but if I can't get any results, then is it me or the node???

Thus might as well try some other way just to see it work, then I can go watch Netflix in peace (from the nagging..."did I do this???") in the back of my head 😃

---

<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:** [1 July 2021 05:25 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/16 "2021-07-01T05:25:19Z")

</div>

I see Dave is also replying.

I am not going to say I am better than he is. I am still pretty much learning.

But it is a bit of python code and a couple of nodes (normal ones) needed to get it all working.

I'll let Dave get his post in and I will get the files needed.

---

<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:** [1 July 2021 05:25 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/17 "2021-07-01T05:25:25Z")

</div>

> [@Trying\_to\_learn](#):
>
> `center: true` or center: false

No diff.... No error, but it looks like that is because noting ever left the function node.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [1 July 2021 05:25 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/18 "2021-07-01T05:25:46Z")

</div>

I don't know if you are showing all the code in the function node, but it doesn't look as if it returns anything.  
Surely there should be a `return msg;` at the very end ??  
Also why have you got two outputs on the function node??

---

<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:** [1 July 2021 05:27 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/19 "2021-07-01T05:27:23Z")

</div>

> [@dynamicdave](#):
>
> Surely there should be a `return msg;` at the very end ??

Doh... even I should have realized that, having played with a few functions in the recent past.

> [@dynamicdave](#):
>
> Also why have you got two outputs on the function node??

Just playing around to see if it made any diff.

---

<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:** [1 July 2021 05:27 UTC](https://discourse.nodered.org/t/trying-to-send-text-to-lcd-over-i2c-contrib/47873/20 "2021-07-01T05:27:27Z")

</div>

# OOPS!

😉

Alas it hasn't **solved** the problem.  
(See next post)

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