Good day! I’ve recently started my Portable Weather Station and I’m having a trouble in displaying the data. I’ve done everything up to the dot of the circuit guide for the components, but it hasn’t worked.
Our materials are:
- 16x2 LCD Display Board IC2
- Arduino Uno
- BMP 180 Sensor
- DHT 11 Sensor
Here’s the full schematic:
The sensor in the diagram is DHT22 though, we’re using a DHT 11 so we didn’t follow any instruction related to a resistor.
The whole code is as follows:
// Include Libraries
#include “Arduino.h”
#include “SFE_BMP180.h”
#include “DHT.h”
#include “LiquidCrystal_PCF8574.h”
// Pin Definitions
#define DHT_PIN_DATA 2
// Global variables and defines
// There are several different versions of the LCD I2C adapter, each might have a different address.
// Try the given addresses by Un/commenting the following rows until LCD works follow the serial monitor prints.
// To find your LCD address go to: http://playground.arduino.cc/Main/I2cScanner and run example.
//#define LCD_ADDRESS 0x3F
#define LCD_ADDRESS 0x27
// Define LCD characteristics
#define LCD_ROWS 2
#define LCD_COLUMNS 16
#define SCROLL_DELAY 150
#define BACKLIGHT 255
// object initialization
SFE_BMP180 bmp180;
DHT dht(DHT_PIN_DATA);
LiquidCrystal_PCF8574 lcdI2C;
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println(“start”);
//Initialize I2C device
bmp180.begin();
dht.begin();
// initialize the lcd
lcdI2C.begin(LCD_COLUMNS, LCD_ROWS, LCD_ADDRESS, BACKLIGHT);
menuOption = menu();
}
// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop()
{
if(menuOption == '1') {
// BMP180 - Barometric Pressure Sensor Breakout - Test Code
// Read Altitude from barometric sensor, note that the sensor is 1m accurate
double bmp180Alt = bmp180.altitude();
double bmp180Pressure = bmp180.getPressure();
double bmp180TempC = bmp180.getTemperatureC(); //See also bmp180.getTemperatureF() for Fahrenheit
Serial.print(F("Altitude: ")); Serial.print(bmp180Alt,1); Serial.print(F(" [m]"));
Serial.print(F("\tpressure: ")); Serial.print(bmp180Pressure,1); Serial.print(F(" [hPa]"));
Serial.print(F("\tTemperature: ")); Serial.print(bmp180TempC,1); Serial.println(F(" [°C]"));
}
else if(menuOption == '2') {
// DHT22/11 Humidity and Temperature Sensor - Test Code
// Reading humidity in %
float dhtHumidity = dht.readHumidity();
// Read temperature in Celsius, for Fahrenheit use .readTempF()
float dhtTempC = dht.readTempC();
Serial.print(F("Humidity: ")); Serial.print(dhtHumidity); Serial.print(F(" [%]\t"));
Serial.print(F("Temp: ")); Serial.print(dhtTempC); Serial.println(F(" [C]"));
}
else if(menuOption == '3') {
// LCD Display Screen 16x2 I2C - Test Code
// The LCD Screen will display the text of your choice.
lcdI2C.clear(); // Clear LCD screen.
lcdI2C.print(" Circuito.io "); // Print print String to LCD on first line
lcdI2C.selectLine(2); // Set cursor at the begining of line 2
lcdI2C.print(" Rocks! "); // Print print String to LCD on second line
delay(1000);
}
if (millis() - time0 > timeout)
{
menuOption = menu();
}
}
// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{
Serial.println(F("\nWhich component would you like to test?"));
Serial.println(F("(1) BMP180 - Barometric Pressure Sensor Breakout"));
Serial.println(F("(2) DHT22/11 Humidity and Temperature Sensor"));
Serial.println(F("(3) LCD Display Screen 16x2 I2C"));
Serial.println(F("(menu) send anything else or press on board reset button\n"));
while (!Serial.available());
// Read data from serial monitor if received
while (Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{
if(c == '1')
Serial.println(F("Now Testing BMP180 - Barometric Pressure Sensor Breakout"));
else if(c == '2')
Serial.println(F("Now Testing DHT22/11 Humidity and Temperature Sensor"));
else if(c == '3')
Serial.println(F("Now Testing LCD Display Screen 16x2 I2C"));
else
{
Serial.println(F("illegal input!"));
return 0;
}
time0 = millis();
return c;
}
}
}
ISSUES:
- LCD just blinks and has no data.
- The Arduino IDE says it’s done uploading, but when I come to test it, nothing happens
I’m greatly asking for all of your kind assistance, this project means a lot to me, and this is my first project in the field of robotics. Thank you!