Arduino Nano, LCD display 1602, bmp180, weather data display (No.2)
Welcome to my blog, this time I will show you my project which read the data of bmp180 sensor and display it to lcd display 1602. Let`s get into it.
Introduction
In the meteorology there`s high pressure and low pressure mass. Usually the weather is good when the pressure is high and when it`s low it is the opposite. Reading the air pressure declining or ascending is an important element in forecasting the weather.
Materials
Bmp180, arduino nano, LCD display 1602
Connection
Both connections are I2C.
bmp180 <---> arduino nano
VIN <---> 3.3V
GND <---> GND
SDA <---> A4
SCL <---> A5
And also,
LCD display <---> arduino nano
VIN <---> 5V
GND <---> GND
SDA <---> A4
SCL <---> A5
Coding
*Code may vary with what kind of library you use.
#include <Wire.h> #include <Adafruit_BMP085.h> #include <LiquidCrystal_I2C.h> Adafruit_BMP085 bmp; // Set the LCD address to 0x27 for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x27, 16, 2); void setup() { lcd.begin(0,2); // sda=GPIO_0, scl=GPIO_2 lcd.init(); // Turn on the backlight. lcd.backlight(); // Print a message to the LCD. lcd.print("hello, world!"); if (!bmp.begin()) { Serial.println("Could not find BMP180 or BMP085 sensor at 0x77"); while (1) {} } } void loop() { lcd.setCursor(0, 0); // set cursor to colum 0, line 1 in lcd lcd.print(bmp.readTemperature()); // print the data from bmp180 lcd.print((char)223);// defining ° lcd.println("C"); // ℃ symbol // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print("Pres = "); lcd.print(bmp.readPressure()/100); lcd.print(" hPa "); Serial.print(millis() / 1000); }
コメント
コメントを投稿