Hi!!
I am writing for the 3 time on this forum in 3 days ahah, this time because I cant display the data on my LCD (the standard one 16:2). I watched a few tutorials on youtube and on internet sites but in there, they use always a white board. In my case I dont need it because my LCD has a thing attached to the pins site (sorry I am new in this field, I dont know the name ahah) with online 4 wires: GND, VCC, SDA and SCL. I am connecting the GND to ground, VCC to 5 volts, SDA and SCL to the respective arduino mega site for that. I tried with some codes that were given on the internet to test if the LCD worked but it didnt. Can someone help me?
Here is the code that I am using (It displays temperature and pressure at the same time in java)
#include <Wire.h>
#include "Seeed_BMP280.h"
BMP280 bmp280;
#define analogPin A0 //the thermistor attach to
#define beta 3950 //the beta of the thermistor
#define resistance 10 //the value of the pull-up resistor
void setup() {
Serial.begin(9600);
if(!bmp280.init())
Serial.println("Device error!");
}
void loop() {
long a =1023 - analogRead(analogPin);
float sensor1 = beta /(log((1025.0 * 10 / a - 10) / 10) + beta / 298.0) - 273.0;
float c = bmp280.getPressure();
Serial.print(sensor1);
Serial.print(", ");
Serial.println(c);
delay (500);
Can someone explain me how can I make temp and pressure data appear on my LCD?
Thank you very much!!!
You will need a library for the I2C LCD. 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, 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 (the thing attached to the LCD pin site) to LCD pin mapping.
I suppose it is a fair guess that the reason why the LCD does not show anything is because you aren't sending anything to show on it. You are not even using an LCD library, but it would be a good idea if you did. I don't suppose it is unreasonable to conclude that you have posted the wrong code, and posting the right code might also be a good idea. As things are, and since you imply that the display is an I2C LCD, you might start with getting a library appropriate for it. It will be called something like liquidcrystalI2c, hopefully recommended by the supplier. It will surely include a "hello world" example that will get you started
thank you very much!!! I tried the "hello, world" code example and it worked :))!! I will try now displaying the data from the temp and pressure using this library!
Thank you so much again!!
That shouldn't be hard. The temp and pressure are just variables like "hello world", and now it is mainly a matter of sensibly formatting the display, which can be learned gradually.
Wow that was fast. You had his problem diagnosed and fixed before I finished feeding the dogs and had my breakfast.
Here's some information based on comments in the original post.
"they use always a white board." <-- That's called a solderless breadboard.
"my LCD has a thing attached to the pins " <-- The thing is an I2C I/O adapter
I2C <-- pronounced I squared C, short for IIC, which stands for Inter Integrated Circuit. This is a technique for serial communication between devices that are close together on a circuit board.
I/O <-- Input / Output
Don
Ok I have done it guys!! Thank you very much for your help!