Pressure sensor LCD I2C problem

Hi guys! I have a little problem with my shiny new I2C-LCD 20x4 screen. I bought this one
LCD Display Module

I downloaded the LiquidCrystal_I2C library (from the official Arduino site) by Frank de Brabander version 1.1.2 to communicate with the screen.

I then copy past the code from a tutorial on youtube here is the link
Pressure Sensor Arduino

I have connected everything according to the video and Arduino - Wire (A4 (SDA), A5 (SCL))
I hope that you can see the pictures...


Here is the code (I only changed the communication address from the one I got after running the scanner)
<
#include "Wire.h" //allows communication over i2c devices
#include "LiquidCrystal_I2C.h" //allows interfacing with LCD screens

const int pressureInput = A0; //select the analog input pin for the pressure transducer
const int pressureZero = 102.4; //analog reading of pressure transducer at 0psi
const int pressureMax = 921.6; //analog reading of pressure transducer at 100psi
const int pressuretransducermaxPSI = 200; //psi value of transducer being used
const int baudRate = 9600; //constant integer to set the baud rate for serial monitor
const int sensorreadDelay = 250; //constant integer to set the sensor read delay in milliseconds

float pressureValue = 0; //variable to store the value coming from the pressure transducer

LiquidCrystal_I2C lcd(0x27, 20, 4); //sets the LCD I2C communication address; format(address, columns, rows)

void setup() //setup routine, runs once when system turned on or reset
{
Serial.begin(baudRate); //initializes serial communication at set baud rate bits per second
lcd.begin(); //initializes the LCD screen
}

void loop() //loop routine runs over and over again forever
{
pressureValue = analogRead(pressureInput); //reads value from input pin and assigns to variable
pressureValue = ((pressureValue-pressureZero)*pressuretransducermaxPSI)/(pressureMax-pressureZero); //conversion equation to convert analog reading to psi
Serial.print(pressureValue, 1); //prints value from previous line to serial
Serial.println("psi"); //prints label to serial
lcd.setCursor(0,0); //sets cursor to column 0, row 0
lcd.print("Pressure:"); //prints label
lcd.print(pressureValue, 1); //prints pressure value to lcd screen, 1 digit on float
lcd.print("psi"); //prints label after value
lcd.print(" "); //to clear the display after large values or negatives
delay(sensorreadDelay); //delay in milliseconds between read values
}
/>

Here is the error message that I got
D:\Docs de Frederic\Documents\Arduino\pressure_sensor\pressure_sensor.ino: In function 'void setup()':
pressure_sensor:20:13: error: no matching function for call to 'LiquidCrystal_I2C::begin()'
lcd.begin(); //initializes the LCD screen
^
In file included from D:\Docs de Frederic\Documents\Arduino\pressure_sensor\pressure_sensor.ino:4:0:
D:\Docs de Frederic\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:58:8: note: candidate: void LiquidCrystal_I2C::begin(uint8_t, uint8_t, uint8_t)
void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS );
^~~~~
D:\Docs de Frederic\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:58:8: note: candidate expects 3 arguments, 0 provided
exit status 1
no matching function for call to 'LiquidCrystal_I2C::begin()'

Thanks in advance.

That's good. You'll solve that.

Please read the topics telling how to use this forum, how to get the best from this forum.
Screen shots are mostly useless. Magnifying them they get blurred and unreadable.
Posting code calls for 2 things.

  1. Autoformat in the IDE.
  2. Use code tags, </>, when pasting.

Read the forum guidelines.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

The errors stem from you using the code for a different version of the LiquidCrystal_I2C library than the one that you have installed. There are several versions of that library with the same name, but they are not, necessarily, compatible. Another good reason to use the hd44780 library for your LCD.

Have you tried the contrast adjustment?

For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.

To install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE menus, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.

The class that you want to use is the hd44780_I2Cexp class. There are examples to show how to use the library. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping.

In the examples, there is a diagnostic sketch that will help us to help you if you still have trouble with the display. Run the diagnostic sketch and post the results.

Here is your code modified to use the hd44780 library for the LCD. The hd44780 library is better than the LiquidCrystal_I2C libraries and is actively maintained, unlike the LiquidCrystal_I2C libraries.
The code is formatted with the IDE auto format tool and posted in code tags.

#include "Wire.h" //allows communication over i2c devices
//#include "LiquidCrystal_I2C.h" //allows interfacing with LCD screens
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

const int pressureInput = A0; //select the analog input pin for the pressure transducer
const int pressureZero = 102.4; //analog reading of pressure transducer at 0psi
const int pressureMax = 921.6; //analog reading of pressure transducer at 100psi
const int pressuretransducermaxPSI = 200; //psi value of transducer being used
const int baudRate = 9600; //constant integer to set the baud rate for serial monitor
const int sensorreadDelay = 250; //constant integer to set the sensor read delay in milliseconds

float pressureValue = 0; //variable to store the value coming from the pressure transducer

//LiquidCrystal_I2C lcd(0x27, 20, 4); //sets the LCD I2C communication address; format(address, columns, rows)
hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip

// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;

void setup() //setup routine, runs once when system turned on or reset
{
   Serial.begin(baudRate); //initializes serial communication at set baud rate bits per second
   //lcd.begin(); //initializes the LCD screen
   lcd.begin(LCD_COLS, LCD_ROWS);
}

void loop() //loop routine runs over and over again forever
{
   pressureValue = analogRead(pressureInput); //reads value from input pin and assigns to variable
   pressureValue = ((pressureValue - pressureZero) * pressuretransducermaxPSI) / (pressureMax - pressureZero); //conversion equation to convert analog reading to psi
   Serial.print(pressureValue, 1); //prints value from previous line to serial
   Serial.println("psi"); //prints label to serial
   lcd.setCursor(0, 0); //sets cursor to column 0, row 0
   lcd.print("Pressure:"); //prints label
   lcd.print(pressureValue, 1); //prints pressure value to lcd screen, 1 digit on float
   lcd.print("psi"); //prints label after value
   lcd.print(" "); //to clear the display after large values or negatives
   delay(sensorreadDelay); //delay in milliseconds between read values
}

Beautiful!!!

Thank you very sir!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.