ESP 8266 I2C LCD Example
ESP 8266 I2C LCD Example
You will need the USB Driver for you're ESP 8266 for Windows 7 or w.e you use.
Library
arduinolibraries.info/libraries/hd44780
and
github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
Example Code (Detect I2C of LCD Board Address)
- Code:
#include <Wire.h>
// I2C Scanner will detect your i2c address mines 0x38
// Written by Nick Gammon
// Date: 20th April 2011
void setup() {
Serial.begin (115200);
// Leonardo: wait for serial port to connect
while (!Serial)
{
}
Serial.println ();
Serial.println ("I2C scanner. Scanning ...");
byte count = 0;
Wire.begin();
for (byte i = 8; i < 120; i++)
{
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0)
{
Serial.print ("Found address: ");
Serial.print (i, DEC);
Serial.print (" (0x");
Serial.print (i, HEX);
Serial.println (")");
count++;
delay (1); // maybe unneeded?
} // end of good response
} // end of for loop
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (count, DEC);
Serial.println (" device(s).");
} // end of setup
void loop() {}
Example Display Code
- Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// http://www.arduinolibraries.info/libraries/hd44780
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x38, 16, 2);
void setup()
{
// initialize the LCD
lcd.begin();
// Turn on the blacklight and print a message.
lcd.backlight();
lcd.print("Subscribe 2 JNET!");
}
void loop()
{
// Do nothing here...
}
Pins Used:
D1 (ESP NODE MCU 8266) = SCL I2C
D2 (ESP NODE MCU 8266) = SDA I2C
My address is 0x38 as I have bridged A0 & A1 & A2.
To use scanner make sure com port and serial broad rate is set correctly then reset the esp and look for address, then if you need it you have it, also set chars, mines 16, 2.
For USB Drivers search google
encrypted.google.com/search?q=usb+esp8266+windows+7+driver&oq=usb+esp8266+windows+7+driver&gs_l=psy-ab.3...92654.99132.0.99619.6.6.0.0.0.0.162.788.1j5.6.0....0...1.1.64.psy-ab..0.2.314...0i13k1j33i21k1.bleAZENtAec
Re: ESP 8266 I2C LCD Example
Also turns out esp 8266 does have a 5v pin but my gsm module needs more amps than my usb 3 can provide, (2amp) usb3 only has 1.5 amps.
Re: ESP 8266 I2C LCD Example
Serial To I2C LCD Example
- Code:
/**
* Displays text sent over the serial port (e.g. from the Serial Monitor) on
* an attached LCD.
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x38, 16, 2);
void setup()
{
lcd.begin();
lcd.backlight();
// Initialize the serial port at a speed of 9600 baud
Serial.begin(9600);
}
void loop()
{
// If characters arrived over the serial port...
if (Serial.available()) {
// Wait a bit for the entire message to arrive
delay(100);
// Clear the screen
lcd.clear();
// Write all characters received with the serial port to the LCD.
while (Serial.available() > 0) {
lcd.write(Serial.read());
}
}
}
Re: ESP 8266 I2C LCD Example
Scrolling LCD I2C
1 Line Static
1 Line Scroll
1 Line Static
1 Line Scroll
- Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// http://www.arduinolibraries.info/libraries/hd44780
// Set the LCD address to 0x27 (Default) Or 0x38 for bridged i2c for a 16 chars and 2 line display
// initialize the library with the numbers of the interface pins
LiquidCrystal_I2C lcd(0x38, 16, 2);
// lcd.print("Subscribe 2 JNET!");
String txtsc,txtnosc;
void setup(){
txtnosc="Subscribe JNET";
txtsc=" Scrolling Text Here.. jnet.forumotion.com";
lcd.begin();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(txtnosc);
}
void loop(){
lcd.setCursor(0,1);
txtsc=ScrollTxt(txtsc);
lcd.print(txtsc);
delay(200);
}
String ScrollTxt(String txt){
return txt.substring(1,txt.length()) + txt.substring(0,1);
}
Permissions in this forum:
You cannot reply to topics in this forum
|
|