Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Environmental Data Logger with GPS and RF Communication

View and Edit Project In Cirkit DesignerImage of ESP32-Based Environmental Data Logger with GPS and RF Communication

Circuit Documentation

Summary

The circuit is designed to collect environmental data using various sensors, including temperature, pressure, altitude, UV levels, air quality, and GPS location. The data is logged to an SD card through the SparkFun OpenLog. The ESP32-WROOM-32UE microcontroller serves as the central processing unit, interfacing with the BMP280, Adafruit VEML6075 UV Sensor, ENS160+AHT21 air quality sensor, and GPS NEO 6M module. A step-up boost converter is used to power the ESP32-CAM module, and a buzzer is included for audio feedback. The circuit is powered by a 3.7V battery, and a rocker switch is used to control power to the circuit.

Component List

Wiring Details

Power Supply

Ground Connections

Sensor Data Lines

Serial Communication

RFM95 LoRa Module

Buzzer

Power Control

Documented Code

/*
 * This Arduino Sketch reads data from BMP280, Adafruit VEML6075 UV Sensor,
 * ENS160+AHT21, and GPS NEO 6M sensors and logs the data to an SD card
 * using the SparkFun OpenLog.
 */

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_VEML6075.h>
#include <SparkFunENS160.h>
#include <TinyGPS++.h>

// Sensor objects
Adafruit_BMP280 bmp;
Adafruit_VEML6075 uv = Adafruit_VEML6075();
ENS160 airQuality;
TinyGPSPlus gps;

// OpenLog Serial
#define OPENLOG_RX 21
#define OPENLOG_TX 19

void setup() {
  Serial.begin(115200);
  Serial2.begin(9600, SERIAL_8N1, OPENLOG_RX, OPENLOG_TX);
  Wire.begin();

  // Initialize BMP280
  if (!bmp.begin()) {
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    while (1);
  }

  // Initialize VEML6075
  if (!uv.begin()) {
    Serial.println(F("Failed to communicate with VEML6075 sensor, check wiring!"));
    while (1);
  }

  // Initialize ENS160
  if (!airQuality.begin()) {
    Serial.println(F("Failed to communicate with ENS160 sensor, check wiring!"));
    while (1);
  }

  // Initialize GPS
  Serial1.begin(9600, SERIAL_8N1, 17, 16);
}

void loop() {
  // Read BMP280 data
  float temperature = bmp.readTemperature();
  float pressure = bmp.readPressure();
  float altitude = bmp.readAltitude(1013.25);

  // Read VEML6075 data
  float uva = uv.readUVA();
  float uvb = uv.readUVB();
  float uvIndex = uv.readUVI();

  // Read ENS160 data
  airQuality.readData();
  int tvoc = airQuality.getTVOC();
  int eco2 = airQuality.getECO2();

  // Read GPS data
  while (Serial1.available() > 0) {
    gps.encode(Serial1.read());
  }
  float latitude = gps.location.lat();
  float longitude = gps.location.lng();
  float speed = gps.speed.kmph();

  // Log data to OpenLog
  Serial2.print("Temperature: "); Serial2.print(temperature); Serial2.print(" C, ");
  Serial2.print("Pressure: "); Serial2.print(pressure); Serial2.print(" Pa, ");
  Serial2.print("Altitude: "); Serial2.print(altitude); Serial2.print(" m, ");
  Serial2.print("UVA: "); Serial2.print(uva); Serial2.print(", UVB: ");
  Serial2.print(uvb); Serial2.print(", UV Index: "); Serial2.print(uvIndex); Serial2.print(", ");
  Serial2.print("TVOC: "); Serial2.print(tvoc); Serial2.print(" ppb, ");
  Serial2.print("eCO2: "); Serial2.print(eco2); Serial2.print(" ppm, ");
  Serial2.print("Latitude: "); Serial2.print(latitude, 6); Serial2.print(", Longitude: ");
  Serial2.print(longitude, 6); Serial2.print(", Speed: "); Serial2.print(speed); Serial2.println(" km/h");

  delay(1000); // Log data every second
}

This code is designed to run on the ESP32-WROOM-32UE microcontroller. It initializes the connected sensors, reads their data, and logs the information to an SD card using the SparkFun OpenLog. The GPS data is read from a separate serial port (Serial1) and the data logging is done over another serial port (Serial2) dedicated to the OpenLog.