1. Connect BME280 Sensor to ESP32-PICO-D4:
- Connect the VCC pin of the BME280 to the 3.3V pin of the ESP32-PICO-D4.
- Connect the GND pin of the BME280 to the GND pin of the ESP32-PICO-D4.
- Connect the SCL pin of the BME280 to the GPIO22 (SCL) pin of the ESP32-PICO-D4.
- Connect the SDA pin of the BME280 to the GPIO21 (SDA) pin of the ESP32-PICO-D4.
2. Connect OLED Display to ESP32-PICO-D4 (optional):
- Connect the VCC pin of the OLED display to the 3.3V pin of the ESP32-PICO-D4.
- Connect the GND pin of the OLED display to the GND pin of the ESP32-PICO-D4.
- Connect the SCL pin of the OLED display to the GPIO22 (SCL) pin of the ESP32-PICO-D4.
- Connect the SDA pin of the OLED display to the GPIO21 (SDA) pin of the ESP32-PICO-D4.
3. Power Supply:
Ensure the ESP32-PICO-D4 and other components are properly powered with a 5V power supply.
4. Programming:
Write a program for the ESP32-PICO-D4 to read data from the BME280 sensor and serve this data on a web server. You can use the Arduino IDE for this purpose.
Example Code:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <WiFi.h>
#include <WebServer.h>
// Replace with your network credentials
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";
// Create an instance of the BME280 sensor
Adafruit_BME280 bme;
// Create a web server object that listens for HTTP request on port 80
WebServer server(80);
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
// Start the sensor
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
// Define the web server routes
server.on("/", handleRoot);
server.begin();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
}
void handleRoot() {
float temperature = bme.readTemperature();
float humidity = bme.readHumidity();
float pressure = bme.readPressure() / 100.0F;
String html = "<!DOCTYPE html><html><head><title>Weather Station</title></head><body>";
html += "<h1>Weather Station</h1>";
html += "<p>Temperature: " + String(temperature) + " °C</p>";
html += "<p>Humidity: " + String(humidity) + " %</p>";
html += "<p>Pressure: " + String(pressure) + " hPa</p>";
html += "</body></html>";
server.send(200, "text/html", html);
}
Testing:
Upload the program to the ESP32-PICO-D4 and power up the circuit. Connect your computer or smartphone to the same Wi-Fi network as the ESP32-PICO-D4. Open a web browser and enter the IP address assigned to the ESP32-PICO-D4 (you can find this in the Serial Monitor). The web page should display the current temperature, humidity, and pressure readings.
Conclusion:Creating a Wi-Fi enabled weather station with the ESP32-PICO-D4 showcases the module's capabilities in IoT applications. This project can be further enhanced with additional sensors, data logging to a cloud service, or integration with smart home systems. The ESP32-PICO-D4's versatility and connectivity make it an ideal choice for various IoT projects.
Comments
Please log in or sign up to comment.