Weather station (Arduino pro mini, BME280, LCD1602)

Introduction



What can be displayed on the two-line screen, except for β€œHello world!”? Why not display temperature humidity and pressure?



Sensors offered as a tutorial for arduino (DHT11, DHT22) show temperature and humidity. For educational purposes (for the university) it was necessary to observe pressure as well. Naturally, there is a barometer in the department, but why not collect your own? In addition, you can continue to accumulate readings in the automatic mode, and this is a good experience in the study of arduino.



Anyway, components were ordered from China and the device was assembled.



Required components



Arduino Pro Mini

I2C for LCD (it was possible to order immediately assembled, but it turned out a little bit cheaper)

LCD 1602

BME280



A USB-UART was used to send the sketch to the arduino. You could also use a Raspberry Pi or a computer with a COM port.



Connection diagram for firmware and program code



From China, USB-UART came with a set of wires:



image



They were quite enough. The jumper was left at 3.3 volts, despite the fact that my version of the arduino is powered by 5 volts.



UART - Arduino

5v - VCC

TXD - RXD

RXD - TXD

GND - GND

CTS - DTR (optional, did not work for me, possibly because the voltage of the signals remained 3.3V)



If you do not connect DTR, then after sending the arduino firmware, you need to restart with the built-in button, an active data exchange will begin in both directions (as indicated by the LEDs on the USB-UART), after successfully downloading the firmware, it will restart itself.



Required third-party libraries:



SparkFunBME280

LiquidCrystal I2C



Directly code, with comments from the examples (in case someone needs something to change).



Code
#include <stdint.h> #include "SparkFunBME280.h" #include "Wire.h" #include "SPI.h" #include <LiquidCrystal_I2C.h> //Global sensor object BME280 mySensor; LiquidCrystal_I2C lcd(0x3F,16,2); // ,    0x3F void setup() { lcd.init(); lcd.backlight(); //***Driver settings********************************// //commInterface can be I2C_MODE or SPI_MODE //specify chipSelectPin using arduino pin names //specify I2C address. Can be 0x77(default) or 0x76 //For I2C, enable the following and disable the SPI section mySensor.settings.commInterface = I2C_MODE; mySensor.settings.I2CAddress = 0x76; // ,      //For SPI enable the following and dissable the I2C section //mySensor.settings.commInterface = SPI_MODE; //mySensor.settings.chipSelectPin = 10; //***Operation settings*****************************// //renMode can be: // 0, Sleep mode // 1 or 2, Forced mode // 3, Normal mode mySensor.settings.runMode = 3; //    Forced mode,        Normal mode //tStandby can be: // 0, 0.5ms // 1, 62.5ms // 2, 125ms // 3, 250ms // 4, 500ms // 5, 1000ms // 6, 10ms // 7, 20ms mySensor.settings.tStandby = 5; //    //filter can be off or number of FIR coefficients to use: // 0, filter off // 1, coefficients = 2 // 2, coefficients = 4 // 3, coefficients = 8 // 4, coefficients = 16 mySensor.settings.filter = 0; //tempOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively mySensor.settings.tempOverSample = 1; //pressOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively mySensor.settings.pressOverSample = 1; //humidOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively mySensor.settings.humidOverSample = 1; //Calling .begin() causes the settings to be loaded mySensor.begin(); } void loop() { //    ,    ,          . lcd.setCursor(0,0); lcd.print("H="); lcd.print((uint8_t)mySensor.readFloatHumidity()); lcd.print("%"); lcd.print(" T="); lcd.print(mySensor.readTempC()); lcd.setCursor(13,0); lcd.print(" P:"); lcd.setCursor(0,1); int mmH=mySensor.readFloatPressure()/133; lcd.print(mmH); lcd.print("mmH "); lcd.print(mySensor.readFloatPressure()); lcd.setCursor(14,1); lcd.print("Pa"); delay(1000); }
      
      







Sensor address can be guessed, there are only two.



How to find the address of your display, you can see here . Depending on the chip, there are two labels.



In this case:



image






And the address will be 0x3F. A0 - A2 open:



image



The LED that is circled in the oval can be better evaporated.



Wiring diagram



The resistor was chosen as half of the resistance of the sensor (between VVC and GND), so that the voltage drop across it was 1.7 volts. The same circuit can be powered from the input RAW, other voltage (for example from the crown).



image



The photograph shows that for compactness, you can take power on the sensor and the display from another pin. Also there you can see a branch of the orange-yellow pair of wires, a 100 Ohm resistor is hanging on them, to reduce the backlight brightness (you can leave a jumper, but it will cut your eyes).



image



In my case, everything is powered by an old computer power supply. Can be powered by USB. All components were glued with Moment glue, which was on hand.



Total



At the workplace appeared 1602 bolted to the table, which shows the pressure, humidity, temperature. Arduino can be reflashed without removing it ( it may become a running line ).



A photo
image



Workplace, general view.



image



Front view.



image



Back view.



All Articles