We’ll cover how to measure temperature, humidity, pressure, altitude, light, and UV values, and display the data on a DFRobot TFT display.
1️⃣Components NeededDFRobot Multifunctional Environmental Sensor (SEN0500)🌡️🌧️🌞
- This sensor combines temperature, humidity, atmospheric pressure, altitude, light, and UV sensors into one compact module.🌡️
- It supports both UART and I2C communication.🌧️
- Provides accurate data in standard units (e.g., °C, %RH, KPa, lx, mW/cm²).🌬️
DFRobot FireBeetle ESP32-C6:🚀
- A low-power IoT controller board based on the ESP32-C6 chip.
- Supports Wi-Fi 6, Bluetooth 5, Zigbee 3.0, and Thread 1.3.📶
- Multiple power supply options, including Type-C, 5V DC, and solar charging.🔋
DFRobot TFT Display (2" 320x240):🖼️
- Features SPI communication and an integrated SD card slot3.
- Resolution: 320x240 pixels.🕸️
- Suitable for displaying environmental data.📂
Connect the Environmental Sensor to the ESP32-C6:
- Use either UART or I2C communication to connect the sensor to the ESP32-C6.
- Refer to the sensor’s datasheet for pinout details.
- Ensure proper voltage levels (3.3V) and pull-up resistors if using I2C.
Wire the TFT Display to the ESP32-C6:
Connect the TFT display using GDI port in the FireBeetle 2 ESP32-C6.
Power Supply:
Choose the appropriate power supply for your setup:
- USB Type-C (for development and testing) 🔌
- 5V DC (for permanent installations) 🔌
- Solar charging (if using solar panels) ☀️
- Install the necessary libraries for the DFRobot Multifunctional Environmental Sensor and the TFT display.
Here is the GIT Repo for DFRobot TFT Display
Here is the MultiFunctional Environmental sensor GIT Repo.
- Read data from the sensor (temperature, humidity, pressure, altitude, light, and UV).
- Display the data on the TFT display using appropriate graphics and text.
#include "DFRobot_GDL.h"
#include "DFRobot_EnvironmentalSensor.h"
#define TFT_DC D2
#define TFT_CS D6
#define TFT_RST D3
DFRobot_ST7789_240x320_HW_SPI screen(/*dc=*/TFT_DC, /*cs=*/TFT_CS, /*rst=*/TFT_RST);
DFRobot_EnvironmentalSensor environment(/*addr = */ SEN050X_DEFAULT_DEVICE_ADDRESS, /*pWire = */ &Wire);
int led = 15;
void setup() {
Serial.begin(115200);
screen.begin();
Wire.begin();
pinMode(led, OUTPUT);
while (environment.begin() != 0) {
Serial.println(" Sensor initialize failed!!");
delay(1000);
}
Serial.println(" Sensor initialize success!!");
}
void loop() {
Serial.println("-------------------------------");
Serial.print("Temp: ");
Serial.print(environment.getTemperature(TEMP_C));
Serial.println("C");
Serial.print("Temp: ");
Serial.print(environment.getTemperature(TEMP_F));
Serial.println("F");
Serial.print("Humidity: ");
Serial.print(environment.getHumidity());
Serial.println(" %");
Serial.print("Ultraviolet intensity: ");
Serial.print(environment.getUltravioletIntensity());
Serial.println(" mw/cm2");
Serial.print("LuminousIntensity: ");
Serial.print(environment.getLuminousIntensity());
Serial.println(" lx");
Serial.print("Atmospheric pressure: ");
Serial.print(environment.getAtmospherePressure(HPA));
Serial.println(" hpa");
Serial.print("Altitude: ");
Serial.print(environment.getElevation());
Serial.println(" m");
Serial.println("-------------------------------");
int16_t color = 0x00FF;
screen.setTextWrap(false);
screen.setRotation(1);
screen.fillScreen(COLOR_RGB565_BLACK);
screen.setTextColor(COLOR_RGB565_GREEN);
screen.setFont(&FreeMono9pt7b);
screen.setTextSize(1.5);
screen.setCursor(20, 30);
screen.println("-DFRobot Environment Node-");
screen.setCursor(0, 60);
screen.println("Temperature: ");
screen.setCursor(0, 90);
screen.println("Humidity: ");
screen.setCursor(0, 120);
screen.println("Pressure: ");
screen.setCursor(0, 150);
screen.println("Altitude: ");
screen.setCursor(0, 180);
screen.println("UV: ");
screen.setCursor(0, 210);
screen.println("Luminous: ");
screen.setTextColor(COLOR_RGB565_RED);
screen.setCursor(135, 60);
screen.println(environment.getTemperature(TEMP_C));
screen.setCursor(195, 60);
screen.println("C");
screen.setCursor(135, 90);
screen.println(environment.getHumidity());
screen.setCursor(195, 90);
screen.println("%");
screen.setCursor(135, 120);
screen.println(environment.getAtmospherePressure(HPA));
screen.setCursor(195, 120);
screen.println("hpa");
screen.setCursor(135, 150);
screen.println(environment.getElevation());
screen.setCursor(205, 150);
screen.println("m");
screen.setCursor(135, 180);
screen.println(environment.getUltravioletIntensity());
screen.setCursor(195, 180);
screen.println("mw/cm2");
screen.setCursor(135, 210);
screen.println(environment.getLuminousIntensity());
screen.setCursor(205, 210);
screen.println("lx");
digitalWrite(led, HIGH);
delay(1000);
}
Select the correct port and the Board. Then upload the sketch.
Once you have uploaded the sketch look at the serial port and see this kind of response from the board.
Home Indoor and Outdoor Environment Detection System:
The environmental sensor can be used to monitor indoor air quality, temperature, humidity, and light levels. For example:
- Detecting changes in room conditions (e.g., humidity spikes, temperature fluctuations).🌡️🌧️
- Monitoring air quality for health and comfort.🌬️
- Adjusting HVAC systems based on real-time data.
Environmental Monitoring Work:
Researchers, environmentalists, and hobbyists can deploy this setup for various monitoring tasks:
- Weather Stations: Collect data on temperature, humidity, and atmospheric pressure.🌦️
- UV Exposure Measurement: Assess UV radiation levels for skin safety.☀️
- Light Intensity Monitoring: Measure ambient light levels indoors or outdoors.🌞
- Altitude Sensing: Useful for tracking elevation changes or detecting floor transitions.🏔️
Internet of Things (IoT) Applications:
The FireBeetle ESP32-C6 provides Wi-Fi 6 and Bluetooth 5 connectivity, making it suitable for IoT projects:
- Smart Home Automation: Control heating, ventilation, and air conditioning (HVAC) based on environmental data.🏠
- Wearable Devices: Integrate environmental sensing into wearables for personalized health monitoring.👟
- GPS Enhancement: Improve time-to-first-fix and dead reckoning accuracy by combining environmental data with GPS signals.🌐
Indoor Navigation:
The combined sensor setup can aid indoor navigation systems:
- Detect changes in floor levels (e.g., moving between different floors in a building).🚶♂️
- Identify elevator usage based on altitude changes.🛗
You can create an efficient environmental monitoring node by combining the DFRobot Multifunctional Environmental Sensor and the DFRobot FireBeetle ESP32-C6. Display the collected data on the TFT screen for easy visualization. Feel free to customize the code and add more features to suit your project needs! 🚀
If you have any more questions or need further assistance, feel free to ask. Happy tinkering! 🛠️🌟
Comments