-
• #2
The display may need a moment to I utilize itself, try waiting a second or two before you try to use it (by putting the initialization code in a setTimeout()
-
• #3
Sorry, no. Tried this before.
Even 2 seconds don't make a change:function onInit() { setTimeout( function() { I2C1.setup({scl:B6, sda:B7}); var lcd = require("HD44780").connectI2C(I2C1); lcd.clear(); lcd.print( "Hello World!" ); }, 2000 ); }
I even use the very same LCD in an Arduino project and can start sending to it right away with no issues there.
Any other idea?
-
• #4
Suggest trying I2C.setup and require lines before the settimeout.
leave the lcd lines inside the settimeout -
• #5
The
.connect()
writes initialization code(*) to the LCD... keeping this initialization outside of (/ execute before) the delayingtimeout()
for the application driven.clear()
and.print()
should solve the issue with a much smaller delay (50ms)... which is what @ClearMemory041063 suggests.(*) HD44780.js module, lines 28 under '//initialise'. The *** Initializing by Instruction*** section in HD4480 Datasheet - on pages 45 and 46 - talks about timings when initialization instructions are sent... (datasheet pdf doc linked below). The times before the initialization instructions may not need to be taken into account, because proper power should have been stable before first JS code is reached.
1 Attachment
-
• #6
B6 and B7 on the Pico are pins used for Serial1 - which is where the console moves by default.
I guess that might be affecting things - while they shouldn't transmit anything for ~1 second after startup (by which time you changed the pins around anyway), I guess it's possible that their startup values confuse I2C on the display and it needs a timeout to recover.
I'd hope that the following - as suggested above - might work:
function onInit() { I2C1.setup({scl:B6, sda:B7}); setTimeout( function() { var lcd = require("HD44780").connectI2C(I2C1); lcd.clear(); lcd.print( "Hello World!" ); }, 2000 ); }
But the other option is just to use some different pins - it's bad luck - those two are literally the only ones on the board that get used for something else by default :)
-
• #7
Gordon, it seems the pins caused it.
Just changed it to I2C3 and this works:function onInit() { I2C3.setup({scl:A8, sda:B4}); var lcd = require("HD44780").connectI2C(I2C3); lcd.clear(); lcd.print( "Hello World!" ); }
No delay needed. Just different pins.
Thanks for the hint.
-
• #8
I had a similar problem with an infrared temperature sensor a few month ago - sadly without finding the bug: http://forum.espruino.com/conversations/280634/#comment12743705
@ChristianW
Could you try out the pin configurationI2C1.setup( { scl: B8, sda: B9 } );
?
This would be really nice and would help to verify/falsify my voodoo theory that I2C1 is different in some kind of initialisation and that the cause are not the concrete pins (B6, B7).For completeness: I have a lot of (>10) different I2C devices which work on I2C1 without any problem.
-
• #10
Thank you. So I know that my problem with the MLX90614 has obiously a different cause.
Beginner with espruino and having some trouble with onInit on my Pico:
Upload and save() works as expected:
But when I un- and re-plug USB it's not working - the LCD is staying blank:
Just manually executing load() again and voila - the LCD shows "Hello World!"
What's going wrong?