Bonjour-nO! This post will show you how to connect an Adafruit Huzzah ESP8266 board to a standard HD44780 LCD via i2c. I just did this myself and it took way too many google searches to battle through dumb issues so I hope this saves you some time.
USB to serial cable - https://www.adafruit.com/product/954
Bread board
Male and Female wires for breadboarding
LCD (we use a 16x2) - https://www.adafruit.com/products/181
i2c backpack - http://www.adafruit.com/products/292
Arduino IDE
It is important to note that there are multiple locations with libraries that the Arduino IDE references. Here is a synopsis of the locations of my library files (yours may be slightly different) and descriptions of what each location contains.
Your goal is to ensure that there is only ONE copy of the Wire.h and LiquidCrystal.h libraries for the ESP8266 which is up-to-date and installed.
For the Wire library, I ended up going into locations 1 and 2 listed above and moving out any folder and it's contents named "Wire" since the Wire library was installed into location 3 with the other esp8266 libraries upon setting up my Arduino IDE for esp8266 boards. If the Wire library was for some reason not installed into location 3, you can find all the esp8266 libraries here:
https://github.com/esp8266/Arduino/tree/master/libraries
Any libraries I moved out I just tossed into a backup folder somewhere to store them in case I needed to revert back.
For the LiquidCrystal library, I moved all LiquidCrystal folders and files out of locations 1, 2 and 3 into my backup folder. I then downloaded the i2c supported version of the library from Adafruit here:
https://github.com/adafruit/LiquidCrystal
and installed it via the the Arduino IDE's zip file library loader (Click Sketch-->Include Library-->Add .Zip Library...).
The code can also be found here:
Uploaded code to Arduino and nothing is happening - Test that the pins you are using for DAT and CLK (2 & 14 in the code above) are working correctly. Find an LED and turn it on and off or read the voltage coming out of the pin. Also, ensure your LCD is good by seeing if the backlight will turn on by feeding 5V to pin 15 and GND pin 16.
Good luck, I hope this helps!
<adventures in hacking etsy seo>
shop
Chicago Laser Cut Coasters
blog filler
</adventures in hacking etsy seo>
MATERIALS:
Adafruit Huzzah ESP8266 board (other esp8266 boards might work as well but this was done using the huzzah board) - https://www.adafruit.com/products/2471USB to serial cable - https://www.adafruit.com/product/954
Bread board
Male and Female wires for breadboarding
LCD (we use a 16x2) - https://www.adafruit.com/products/181
i2c backpack - http://www.adafruit.com/products/292
Arduino IDE
ASSUMPTIONS:
I will assume you know how to setup your Arduino IDE to program the esp8266 huzzah board. If you do not know how to do this, checkout my instructions on those topics here: <to come>. (See also Adafruit's tutorial, https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/using-arduino-ide). I'll also let you follow Adafruit's tutorial on how to get the i2c backpack soldered onto your lcd, https://learn.adafruit.com/i2c-spi-lcd-backpack/overview.DEALING WITH LIBRARIES:
The most brutal part of making this work was figuring out what libraries I had installed in the Arduino IDE, which were duplicate libraries, and where all of the libraries were found. The two libraries you need for this project are...- Wire
- LiquidCrystal (the updated version that includes i2c support)
It is important to note that there are multiple locations with libraries that the Arduino IDE references. Here is a synopsis of the locations of my library files (yours may be slightly different) and descriptions of what each location contains.
- The libraries you manually load, found within the "libraries" folder in the same folder your sketches are saved to - C:\Users\YOUR_NAME\Documents\Arduino\libraries
- The libraries that the Arduino IDE comes with, found within the location that you installed the Arduino IDE - C:\Program Files (x86)\Arduino\libraries
- The libraries that were installed when you setup the Arduino IDE to be able to program your ESP8266 - C:\Users\YOUR_NAME\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries
Your goal is to ensure that there is only ONE copy of the Wire.h and LiquidCrystal.h libraries for the ESP8266 which is up-to-date and installed.
For the Wire library, I ended up going into locations 1 and 2 listed above and moving out any folder and it's contents named "Wire" since the Wire library was installed into location 3 with the other esp8266 libraries upon setting up my Arduino IDE for esp8266 boards. If the Wire library was for some reason not installed into location 3, you can find all the esp8266 libraries here:
https://github.com/esp8266/Arduino/tree/master/libraries
Any libraries I moved out I just tossed into a backup folder somewhere to store them in case I needed to revert back.
For the LiquidCrystal library, I moved all LiquidCrystal folders and files out of locations 1, 2 and 3 into my backup folder. I then downloaded the i2c supported version of the library from Adafruit here:
https://github.com/adafruit/LiquidCrystal
and installed it via the the Arduino IDE's zip file library loader (Click Sketch-->Include Library-->Add .Zip Library...).
Once you have done these two things you should be able to go to "Sketch-->Include Library" and see both the "Wire" and "LiquidCrystal-master" libraries under "Contributed libraries".
WIRE IT:
First things second, let's get this sucker wired up. We are going to power the whole shoot-n-shebang off the USB to serial power wire. Here's a pinout that will help you figure out what to connect to what:Device | Pin | Connect to Device | Connect to Pin |
USB to Serial Cable | Rx (3.3V, white) | ESP8266 Huzzah | Tx |
USB to Serial Cable | Tx (3.3V, green) | ESP8266 Huzzah | Rx |
USB to Serial Cable | Power (5V @ 500mA) | Breadboard | Power Rail |
USB to Serial Cable | GND | ESP8266 Huzzah | GND |
i2c Back Pack | LAT | none | none |
i2c Back Pack | DAT | ESP8266 Huzzah | 2 |
i2c Back Pack | CLK | ESP8266 Huzzah | 14 |
i2c Back Pack | 5V | Breadboard | Power Rail |
i2c Back Pack | GND | Breadboard | GND Rail |
ESP8266 Huzzah | GND | Breadboard | GND Rail |
CODE IT:
Next, you will go through the usual process to save code to the Huzzah board by holding down the GPIO0 button, clicking the "Reset" button and then letting go of the GPIO0 button. This action sets your board into bootload mode and you can then click to upload the sketch from the Arduino IDE. You will use the following code to upload to your board.The code can also be found here:
/*
Demonstration sketch for Adafruit i2c/SPI LCD backpack
using MCP23008 I2C expander
( http://www.ladyada.net/products/i2cspilcdbackpack/index.html )
This sketch prints "Hello World!" to the LCD
and shows the time since the board was reset.
The circuit see: http://www.imaginen4tion.blogspot.com/2015/10/how-to-connect-esp8266-to-lcd-via-i2c.html
*/
// Originally written by Adafruit.
// Modified for esp8266 by Bob Rowe on 10.31.15, giddyup!
// include the library code:
#include "Wire.h"
#include "LiquidCrystal.h"
// Note, problems with your libraries is a common issue due to multiple
// libraries with the same name getting imported into your Arduino IDE
// when setting up to develop on esp8266.
// See for more info:
// Connect to LCD via i2c, default address #0 (A0-A2 not jumpered)
LiquidCrystal lcd(0);
// "Default address" simply refers to how your Adafruit i2c backpack is setup.
// See here for more info: https://learn.adafruit.com/i2c-spi-lcd-backpack/connect-to-i2c
void setup() {
// Initiate the i2c connection on esp pins 2 (DAT/SDA) and 14 (CLK/SCL)
Wire.begin(2,14);
// set up the LCD's number of rows and columns:
// Here we are using a standard LCD with 16 columns and 2 rows
// example of LCD: https://www.adafruit.com/products/181
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
lcd.setBacklight(HIGH);
delay(500);
lcd.setBacklight(LOW);
delay(500);
}
TROUBLESHOOT:
Problems with libraries - search your computer for the library.h file you are having issue with, eg: search "Wire.h". Then ensure that you only have one version of that library within the Arduino IDE's reach.Uploaded code to Arduino and nothing is happening - Test that the pins you are using for DAT and CLK (2 & 14 in the code above) are working correctly. Find an LED and turn it on and off or read the voltage coming out of the pin. Also, ensure your LCD is good by seeing if the backlight will turn on by feeding 5V to pin 15 and GND pin 16.
Good luck, I hope this helps!
<adventures in hacking etsy seo>
shop
Chicago Laser Cut Coasters
blog filler
</adventures in hacking etsy seo>