Back to engineering archive

Record 086 / Connected systems

Environmental OLED and cloud logger

An ESP32 environmental logger combines local OLED feedback with cloud reporting. Configuration routines cover Wi-Fi details and a spreadsheet logging endpoint.

Development work
ESP32Wi-FiOLEDCloud loggingEnvironmental sensing

Firmware flow

How readings become environmental flags

Selected sensor acquisition and state checks.

Read the motion input, update readings from sensors marked ready, and combine no-motion with valid numeric light or temperature values to set the two threshold flags.

The flags describe possible conditions, not measured energy savings. The excerpt does not clear old values when a sensor is unavailable or test reading freshness; cloud reporting is outside it.

Read the implementation

sensor acquisition / state flags excerpt · selected source lines 413–430. Source inspection is not a hardware test.

  int pirRaw = digitalRead(PIR_PIN);
  bool motionDetected = (pirRaw == LOW);
  bool noMotion = !motionDetected;

  if (bmeOK) {
    temperatureC = bme.readTemperature();
    humidity = bme.readHumidity();
    pressureHpa = bme.readPressure() / 100.0F;
  }

  if (tslOK) {
    sensors_event_t event;
    tsl.getEvent(&event);
    lux = event.light;
  }

  bool emptyRoomLightOn = noMotion && !isnan(lux) && lux > LIGHT_ON_THRESHOLD_LUX;
  bool possibleHeatingWaste = noMotion && !isnan(temperatureC) && temperatureC > HIGH_TEMP_THRESHOLD_C;
Open the exact source-level diagram
ActionRead the motion inputA LOW input is treated as motion.
ActionRefresh environmental readings when enabledRead temperature, humidity and pressure only when the environmental sensor is marked ready.
ActionRefresh the light reading when enabled
ActionCheck no-motion and threshold conditionsUse numeric light and temperature values to set the two possible-waste flags.

Technical notes

OLED feedback

showOLEDMessage() provides local display feedback alongside acquisition and remote logging.

Network and logging configuration

wifiDetailsAdded() and sheetsUrlAdded() identify two setup responsibilities: connecting the logger to a network and assigning its spreadsheet endpoint. This makes the destination part of the device configuration.

Spreadsheet records

The project includes a spreadsheet view with environmental columns and timestamped rows. This complements the local display: one presents device feedback, while the other organises reported data for later inspection.

Engineering archiveArchive record

Project enquiries

Discuss your project.

Tell us what you’re developing and where you need engineering support.

Discuss your project