Components and supplies
Arduino UNO
BOSCH BME/BMP280
Rotary potentiometer (generic)
Pushbutton switch 12mm
RGB Backlight LCD - 16x2
Resistor 4.75k ohm
Jumper wires (generic)
Breadboard (generic)
Tools and machines
Soldering iron (generic)
Apps and platforms
Arduino IDE
Project description
Code
WeatherBase1.0
arduino
1/* ------------------------------------------------------------------------------- */ 2// Weather Station v1.0 3// Andrea Martignoni 4// martignoni.a@gmail.com 5 6#include <LiquidCrystal.h> //Liquid Cristal Mgt Lib 7#include <Wire.h> //Management of wire connections 8#include "cactus_io_BME280_I2C.h" //Manage BME280 temp, humidity, pressure sensor 9 10 11// Connections for LCD: 12// rs (LCD pin 4) to Arduino pin 12 13// rw (LCD pin 5) to Arduino pin 11 14// enable (LCD pin 6) to Arduino pin 10 15// LCD pin 15 to Arduino pin 13 16// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2 17LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); //Define PINs LCD 18// Create the BME280 object 19//BME280_I2C bme; // I2C using default 0x77 20BME280_I2C bme(0x76); // I2C using address 0x76 21 22int backLight = 13; // pin 13 will control the backlight managed by button 23 24 25void setup() 26{ 27 pinMode(backLight, OUTPUT); //Define output mode 28 Serial.begin(9600); //Serial communication 9600 29 30 digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off. 31 lcd.begin(16,2); // columns, rows. 16X2LCD 32 lcd.clear(); // start with a blank screen 33 lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row) 34 lcd.print("Temperatura Sensore"); //Starting text row 1 35 lcd.setCursor(0,1); // set cursor to column 0, row 1 36 lcd.print("XY Celsius"); //starting text row 2 37 38 39 if (!bme.begin()) { //Check if BME280 is connected and working 40 Serial.println("Could not find a valid BME280 sensor, check wiring!"); 41 while (1); 42 } 43 44 bme.setTempCal(-1); //Claibrate BME280 sensor 45 46 47} 48 49 50void loop() //Main looping code 51{ 52 53 lcd.clear(); //Clear LCD 54 bme.readSensor(); //Read Sensor 55 lcd.setCursor(0,0); //Position on row 1 56 lcd.print("P:"); lcd.print(bme.getPressure_MB()); //Send to LCD row 1 Pressure in millibars 57 lcd.print(" H:"); lcd.print(bme.getHumidity()); //Send to LCD row 1 Humidity in millipascals 58 lcd.setCursor(0,1); //Position on row 1 59 lcd.print("T:"); lcd.print(bme.getTemperature_C()); lcd.print("C"); //Send to LCD row 2 Temperature in C 60 lcd.print(" T:"); lcd.print(bme.getTemperature_F()); lcd.println("F"); //Send to LCD row 2 Temperature in F 61 62 delay(1000); //just here to slow down the output so it is easier to read 63} 64 65 66/* ------------------------------------------------------------------------------- */
WeatherBase1.0
arduino
1/* ------------------------------------------------------------------------------- */ 2// Weather Station v1.0 3// Andrea Martignoni 4// martignoni.a@gmail.com 5 6#include <LiquidCrystal.h> //Liquid Cristal Mgt Lib 7#include <Wire.h> //Management of wire connections 8#include "cactus_io_BME280_I2C.h" //Manage BME280 temp, humidity, pressure sensor 9 10 11// Connections for LCD: 12// rs (LCD pin 4) to Arduino pin 12 13// rw (LCD pin 5) to Arduino pin 11 14// enable (LCD pin 6) to Arduino pin 10 15// LCD pin 15 to Arduino pin 13 16// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2 17LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); //Define PINs LCD 18// Create the BME280 object 19//BME280_I2C bme; // I2C using default 0x77 20BME280_I2C bme(0x76); // I2C using address 0x76 21 22int backLight = 13; // pin 13 will control the backlight managed by button 23 24 25void setup() 26{ 27 pinMode(backLight, OUTPUT); //Define output mode 28 Serial.begin(9600); //Serial communication 9600 29 30 digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off. 31 lcd.begin(16,2); // columns, rows. 16X2LCD 32 lcd.clear(); // start with a blank screen 33 lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row) 34 lcd.print("Temperatura Sensore"); //Starting text row 1 35 lcd.setCursor(0,1); // set cursor to column 0, row 1 36 lcd.print("XY Celsius"); //starting text row 2 37 38 39 if (!bme.begin()) { //Check if BME280 is connected and working 40 Serial.println("Could not find a valid BME280 sensor, check wiring!"); 41 while (1); 42 } 43 44 bme.setTempCal(-1); //Claibrate BME280 sensor 45 46 47} 48 49 50void loop() //Main looping code 51{ 52 53 lcd.clear(); //Clear LCD 54 bme.readSensor(); //Read Sensor 55 lcd.setCursor(0,0); //Position on row 1 56 lcd.print("P:"); lcd.print(bme.getPressure_MB()); //Send to LCD row 1 Pressure in millibars 57 lcd.print(" H:"); lcd.print(bme.getHumidity()); //Send to LCD row 1 Humidity in millipascals 58 lcd.setCursor(0,1); //Position on row 1 59 lcd.print("T:"); lcd.print(bme.getTemperature_C()); lcd.print("C"); //Send to LCD row 2 Temperature in C 60 lcd.print(" T:"); lcd.print(bme.getTemperature_F()); lcd.println("F"); //Send to LCD row 2 Temperature in F 61 62 delay(1000); //just here to slow down the output so it is easier to read 63} 64 65 66/* ------------------------------------------------------------------------------- */
Downloadable files
WeatherStation1.0
Schematic and code
WeatherStation1.0
Comments
Only logged in users can leave comments