Hello,
I'm new to this forum. I'm posting this message on behalf of my son who is doing a project for his school. He wants to interface a soil moisture sensor with an LCD display through an ESP 32 board. From what i understand the sensor works and he is able to read the values online however he is not able to interface these values to a LCD screen. He has used the below circuit
Thank you for your reply.
I am going to be using the arduino nano bord insred of the esp32 as it has a bad usb socket.
I had referred to the same tutorial before but it still did not work. This is the list of events-
Bord- arduino nano, i2c board and 162a lcd.
Problem- does no work no matter what .
First used esp32 without i2c board- did not work.
Tried multiple codes - did not work.
Bought a new LCD thinking the old one was faulty- did not work.
Bought i2c board and used multiple codes - did not work .
Used arduino nano - did not work.
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x3F for a 16 chars and 2 line display
void setup() {
lcd.init();
lcd.clear();
lcd.backlight(); // Make sure backlight is on
// Print a message on both lines of the LCD.
lcd.setCursor(2,0); //Set cursor to character 2 on line 0
lcd.print("Hello world!");
#include <LCD_I2C>
LCD_I2C lcd(0x27, 16, 2); // set the LCD address to 0x3F for a 16 chars and 2 line display
void setup() {
lcd.begin(); // initialize the lcd
delay (500);
lcd.clear();
lcd.backlight();
// Print a message on both lines of the LCD.
lcd.setCursor(2,0); //Set cursor to character 2 on line 0
lcd.print("Hello world!");
If that doesn't work, load and run this I2C Scanner code to determine the LCD I2C address
#include <Wire.h>
// Set I2C bus to use: Wire, Wire1, etc.
#define WIRE Wire
void setup() {
WIRE.begin();
Serial.begin(9600);
while (!Serial)
delay(10);
Serial.println("\nI2C Scanner");
}
void loop() {
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
WIRE.beginTransmission(address);
error = WIRE.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x3F for a 16 chars and 2 line display
void setup() {
lcd.init();
lcd.clear();
lcd.backlight(); // Make sure backlight is on
// Print a message on both lines of the LCD.
lcd.setCursor(2,0); //Set cursor to character 2 on line 0
lcd.print("Hello world!");
Are you buying the I2C board and LCD display separately? If so, are you soldering the connections? Just sticking header pins/jumpers into the holes to make connection is highly unreliable.
Are you using the classic Nano board, with the atmega328 chip?
Lets try something a bit different, in the IDE, go to the library manager and install the "hd44780" library by Bill Perry.
Run the sketch File>Examples>hd44780>ioClass>hd44780I2Cexp>I2CexpDiag, making sure the serial monitor is set to 9600 baud.
If that library cannot find the display, there is something very wrong.
Thank you for your suggestions . i have bought the display and i2c board separately and i have soldiered the connections. i am not aware of the type of Arduino nano , but it is running on he mega328p chip. as for the library, i will definitely try it out.
This window will appear. It may take some time for it to load, be patient.
Enter the target library in the search window and click Enter. Give it time to search.
Scroll down to find your library of interest. Click in that area and an "Install" button will appear.
Click it.
Check to make sure the I2C Backpack isn't touching the black metal tabs on the back of the display.
If it is, slide a business card or some sort of isolator between them to separate them.
I bend two of the tabs down prior to installing the backpack to assure they don't touch.