Arduino for ODROID-GO - I2C

  • Refer to the Arduino official documents. This tells us useful common functions with great instructions.
  • Refer to the ESP32 official programming guide. Most of ESP32 specific functions introduced here.
  • The hardware, LCD with I2C interface is not for sale. But with this guide you can get to know how to control the external I2C devices.

We will learn that how to display “Hello world” on the 16×2 LCD via external I2C interface.

First of all, you should connect the 16×2 LCD to your ODROID-GO's P2(expansion connector) as follows.

P2, ODROID-GO 16×2 LCD
GND(Pin #1) GND
IO15(Pin #4) SDA
IO4(Pin #5) SCL
P3V3(Pin #6) VCC


You have to clone the library to use it properly.
Enter the following codes to clone it from the Github repository.

Windows

Open Git Bash program to enter the following commands.

cd $USERPROFILE/Documents/Arduino/libraries
git clone https://github.com/marcoschwartz/LiquidCrystal_I2C

Linux

Open a Terminal window to enter the following command.

git clone https://github.com/marcoschwartz/LiquidCrystal_I2C ~/Arduino/libraries/LiquidCrystal_I2C

I2C on Arduino

Using I2C is simple on the Arduino IDE; The ESP32's Wire library could help us.

We're already know that the ports for I2C communication are 15 for SDA, 4 for SCL.
Define as a pre-processor them and use Wire.begin() function. you can put only 2 parameters, pin number for SDA and SCL.

#define PIN_I2C_SDA 15
#define PIN_I2C_SCL 4
 
void setup() {
    // put your setup code here, to run once:
    Wire.begin(PIN_I2C_SDA, PIN_I2C_SCL);
}
 
void loop() {
    // put your main code here, to run repeatedly:
}

And add a code for set the LCD up.
Include LiquidCrystal_I2C.h library to show a message on that easily.
Create a instance for control the LCD with LiquidCrystal_I2C lcd(LCD_ADDR, 16, 2) line. Given parameters are the LCD ADDR, cols and rows for 16×2 LCD.

Do init(), turn on the backlit with backlight(), set cursor to specify a point to write down with setCursor().
And print().

#include <LiquidCrystal_I2C.h>
 
#define PIN_I2C_SDA 15
#define PIN_I2C_SCL 4
 
const uint8_t LCD_ADDR = 0x3f;
LiquidCrystal_I2C lcd(LCD_ADDR, 16, 2);
 
void setup() {
    // put your setup code here, to run once:
    Wire.begin(PIN_I2C_SDA, PIN_I2C_SCL);
 
    lcd.init();
    lcd.backlight();
    lcd.setCursor(0, 0);
    lcd.print("Hello, ODROID-GO");
}
 
void loop() {
    // put your main code here, to run repeatedly:
}

Press CTRL-U to compile and upload the sketch to show a message on the LCD.

Complete example: current battery status on the 16x2 LCD

We have prepared more an advanced example based on the previous we made together.
Click the Files → Examples → ODROID-GO → 16x2_LCD_I2C menu to import and press CTRL-U to compile/upload.