Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By brutzler
#26980 Hi,
just worked a little bit in ths way with my LCDs.

tried two different I2C-modules
- I2C lcd1602 from mjkdz
- LCD-I2C/SER with support of a keypad. PIC18F23 on it. Maybe from web4robot.com No more further docs or infos found.
and two different LCD-Displays (blue 20x4)
- JHD629-204A
- YM 2004A

Of course, I had to change the I2C-adress to the matching one.
Using the sketch of the thread starter

But the success is more than poor.
- crazy signs on the display. LCD-I2C/SER + JHD629-204A
- some crazy signs with very low contrast and no signs on the upper left area ( ~2x8 charakters) LCD-I2C/SER + YM 2004A
- flashing display (some times dark, than a short flash of the backlight.

I trried the modified "core_esp8266_si2c.c" but not better in any way.

What I am astonished. Using "LiquidCrystal_I2C.h" earlier on normal arduino, there was a lcd.init(). But this command is not recognized any more???
User avatar
By brutzler
#27091 Hi,
now got it working for me :-)

Took the library from here: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
My I2C-LCD module is this: http://www.elektroda.pl/rtvforum/topic2562203.html
LCD is a normal 20x4 blue JHD629-204A

Took the code from Gutty, and made some changes to fit for my hardware.
-> No freezing or similiar.
Code: Select all/* Wiring:
 * 5V <-> 5V
 * GND <-> GND
 * SCL <-> D5 (GPIO14 / HSPICLK)
 * SDA <-> D7 (GPIO13 / HSPID)
 */
#include <Streaming.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define lcdAddr 0x20 // set the address of the I2C device the LCD is connected to
const int MAX_PACKET_SIZE = 101;
char packetBuffer[ MAX_PACKET_SIZE];

// create an lcd instance with correct constructor for how the lcd is wired to the I2C chip
LiquidCrystal_I2C lcd(lcdAddr, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE); // addr, EN, RW, RS, D4, D5, D6, D7, Backlight, POLARITY

void setup()
{
  Wire.begin(13,14);  //NodeMCU ESP-12
  lcd.begin(20,4);  // initialize the lcd as 20x4 (16,2 for 16x2)
  lcd.home();
  lcd.setCursor(0, 1);
  lcd.print("   Setup ...");
  Serial.begin(115200);
  Serial.println("   Setup ...");
  delay(500);
  strcpy(packetBuffer, "Pool  28.6 Erw. 0.0 Sonne 21.6 Ret. 26.8Luft  25.6 Vor. 27.2Pumpe  0   Wind 1.86");
  Serial << packetBuffer << endl;
  lcd.setCursor(0, 0);
  lcd << packetBuffer ;
  delay(2000);
  lcd.noCursor();
}

void loop()
{
  lcd.clear();
  lcd.setCursor(0, 1);
  lcd.print("   loop");
  delay(1000); 
}



And even the other I2C-converter from webrobot with keypad-function is working.
Here are infos: http://wentztech.com/radio/arduino/files/LCDI2C.html
User avatar
By Gutty
#27112 I deleted all lcd libs in the lib folder, also in the hardware esp8266 lib folder. Then I installed the recommended library.
Errors on compiling only the lins:
Code: Select all#include <Wire.h>  // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>
void setup() {}
void loop() {}

Brings this error when I compile for am ESP8266 board. If I compile for UNO, no error :? :? :?:
d:\Arduino\libraries\LiquidCrystal\LiquidCrystal.cpp: In member function 'virtual void LiquidCrystal::setBacklight(uint8_t)':
d:\Arduino\libraries\LiquidCrystal\LiquidCrystal.cpp:173:41: error: 'digitalPinToTimer' was not declared in this scope
if(digitalPinToTimer(_backlightPin) != NOT_ON_TIMER)
^
d:\Arduino\libraries\LiquidCrystal\LiquidCrystal.cpp:173:46: error: 'NOT_ON_TIMER' was not declared in this scope
if(digitalPinToTimer(_backlightPin) != NOT_ON_TIMER

:x

What OS do you use? Win / Mac/ linux ?