Project 4 : Experiment With External Sensor Module (BMP 280)

Hello everyone ๐Ÿ‘‹... and welcome back to my blogspot. This time, I'll run an experiment with the BMP 280 sensor, which can measure temperature, pressure, approximate altitude, and other parameters. At this moment, we will strive to make the blue led light up when the sensor detects a temperature greater than 40 degrees Celsius and the red led light up when the temperature is less than 40 degrees Celsius. 


Let's just get to work on the project. Before we begin working on these two projects, we must first prepare.

๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ๐Ÿ’จ


๐ŸงฐSET UP๐Ÿงฐ

1. 1 Pcs of ESP32


2. 3 Pcs of Male to Female Cable Jumper


3.  4 Pcs of Male to Male Cable Jumper

4. 2 Pcs of 5 mm Led Lamp (Blue and Red Color)

5. 2 Pcs of 330 Ohm Resistor


6. 1 Pcs of Micro USB cable


7. 1 Pcs Of .Barometetric Pressure Sensor (BMP280)



STEP BY STEP

When we heat the BMP280 sensor until it has a temperature above 40 degrees Celsius, the red led will light up, while when the temperature is lowered back below 40 degrees Celsius, the blue led will light up again.

1.Set up the sensor circuit as illustrated in Figure .


2. Arrange a series of lights as shown in the diagram below.note that the white cable will be linked to port GND , then the blue cable will be attached to port D26 , and the purple cable will be connected to port D27 on ESP32



3. Launch our Arduino IDE and download the BMP280 library. The trick is to go to Tab > Manage Libraries and search for Adafruit BMP280. Wait a few moments after pressing the install button.





4. Implement the code below. Please keep in mind that in this project, because there is a light indication in the experiment, we must configure pinMode as one of the properties for using light.

/*******************************************************************/
/* Interfacing Arduino with BMP280 temperature and pressure sensor.
 * Temperature and pressure values are displayed on 16x2 LCD.
 * This is a free software with NO WARRANTY.
 * https://simple-circuit.com/
 */

 // ESP32 SDA to D21 SCL to D22
 // ESP8266 SDA to D2 SCL to D1
 
#include <Wire.h>             // include Wire library, required for I2C devices
#include <Adafruit_Sensor.h>  // include Adafruit sensor library
#include <Adafruit_BMP280.h>  // include adafruit library for BMP280 sensor
 
// define device I2C address: 0x76 or 0x77 (0x77 is library default address)
#define BMP280_I2C_ADDRESS  0x76
 
Adafruit_BMP280 bmp280;

const int ledPin = 26;
const int ledPin2 = 27;
 
void setup() {
  Serial.begin(115200);

  pinMode (ledPin, OUTPUT);
  pinMode (ledPin2 , OUTPUT);
 
  Serial.println(F("Arduino + BMP280"));
  
  if (!bmp280.begin(BMP280_I2C_ADDRESS))
  {  
    Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    while (1);
  }
  Serial.println("Found BMP280 sensor!");
}

void loop() {
  // get temperature, pressure and altitude from library
  float temperature = bmp280.readTemperature();  // get temperature
  float pressure    = bmp280.readPressure();     // get pressure
  float altitude_   = bmp280.readAltitude(1013.25); // get altitude (this should be adjusted to your local forecast)

 if(temperature > 40.0){
    // turn LED on
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin2 , LOW);
    //Serial.println(" - LED on");
  }
  else{
    // turn LED 1 off
    // turn LED 2 on
    digitalWrite(ledPin,LOW);
    digitalWrite(ledPin2, HIGH);
    //Serial.println(" - LED off");
  }
  
  // print data on the serial monitor software
  // 1: print temperature
  
  Serial.print("Temperature = ");
  Serial.print(temperature);
  Serial.println(" °C");
  // 2: print pressure
  Serial.print("Pressure    = ");
  Serial.print(pressure/100);
  Serial.println(" hPa");
  // 3: print altitude
  Serial.print("Approx Altitude = ");
  Serial.print(altitude_);
  Serial.println(" m");
    
  Serial.println();  // start a new line
  delay(2000);       // wait 2 seconds
  
}
/*******************************************************************/

5. Click the Upload button and wait a few seconds for the words "Done Uploaded" to display. 




6. Then, on the tools tab, open the serial monitor and set it to 115200 baud.



7. Utilize any heating devices such as matches, lighters, hair dryers, and other instruments and try to make the sensor heat up.
8. Monitor temperature changes on the serial monitor and changes in the light indicators in accordance with the following specifications:
- If the blue LED lights up, the temperature is 40 degrees Celsius.
- If the red LED illuminates, the temperature is above 40 degrees Celsius.


Because the file size is large enough to demonstrate the project's outcomes, you can access the video using the following link: Project 4 : External Sensor using BMP280 with ESP32 modules 2023


                                ๐Ÿ˜ŽHooray, we've finished the external sensor project 
                                ๐Ÿ˜ŽSee you in my next blog with ESP32.




Comments

Popular posts from this blog

Project 7 : Connecting ESP32 and our smartphone with bluetooth connection