Using I2C module with LCD 16x02


Hello everyone, does anyone know how I can use the i2c module together with a Display LCD 16x02?
Using the arduino IDE was easy, but using mongoose I could not use.
Does anyone know how to print a “Hello Word” using the LCD 16x02 + I2C?
I’m using esp8266
mos call I2C.Scan return 39

  - ["i2c.enable", true]
  - ["i2c.sda_gpio", 4]
  - ["i2c.scl_gpio", 5]
  - ["i2c.debug", true]
  - ["debug.level", 3]                                                              
How to import a external javascript library

There is a very nice Arduino library which can be easily ported to Mongoose OS.


In the old forum, I found this library for mongoose.

I tested the code in javascript. This is my code.

load("api_aws.js"); //aws

LiquidCrystalI2C.create(addr, lcdColumns, lcdRows); 
LiquidCrystalI2C.setCursor(0, 1)

let D5 = 14;
let D8 = 15;
// BTN active rele
let BTND7 = 13;
let clicked = false;
let dht = DHT.create(D5, DHT.DHT11);

Timer.set(20000 /* milliseconds */, Timer.REPEAT, function () {
  let t = dht.getTemp();
  let h = dht.getHumidity();

  if (isNaN(h) || isNaN(t)) {
    print('Failed to read data from sensor');

  if (t >= 33) {
    if (clicked !== true) { GPIO.write(D8, 0); }
  else {
    if (clicked !== true) { GPIO.write(D8, 1); }
   //Send AWS
   Shadow.update(0, { reported: { temperature: t, humidity: h } }) 

  LiquidCrystalI2C.clear( )
  LiquidCrystalI2C.setCursor( 0,0 )
  LiquidCrystalI2C.print("Temp: " );
  LiquidCrystalI2C.print("Temp: " + String(t) + (char)223 + "C" );

}, null);

The problem occurs only with the display.

let lcd = LiquidCrystalI2C.create(addr, lcdColumns, lcdRows);
lcd.setCursor(0, 1)

The code is not generating the object.
When you run lcd.init () returns this error.

[Oct  5 16:37:17.288] {"__p":{}}  //object incorrect
[Oct  5 16:37:17.880] 
[Oct  5 16:37:17.880] SW WDT @ 0x4000dd38 //error
[Oct  5 16:37:17.880]  A0: 0x40002ef1  A1: 0x3ffff570  A2: 0xc42927fc  A3: 0x00000015
[Oct  5 16:37:17.886]  A4: 0x05056692  A5: 0x3ffee760  A6: 0x0000001f  A7: 0x3ffff5e0
[Oct  5 16:37:17.891]  A8: 0x402adabc  A9: 0x00000000 A10: 0xfffffffe A11: 0x00000000
[Oct  5 16:37:17.897] A12: 0x09896800 A13: 0xbf23c16a A14: 0x3fff47ec A15: 0xfff20000


It worked!!
I found another repository and just changed the mos file to esp8266.

This is the repository.


Although this post is a little old, I just wanted to ask if you could share a code example. I tried the following:

let lcd=LCD_I2C.create(0X3E);

Using this lib. Unfortunately I don’t get the display to show anything.

 mos call I2C.Scan

showed me to use the above I2C address (actually it showed 62, but the Grove datasheet told me to use the above one).


0x34 is the hexadecimal representation of decimal 62.