Build a small monitor for your plant shelf with the PlantMate DHT30 + light sensor flex PCB, an ESP32, and a 0.91-inch OLED. The screen shows air temperature, relative humidity, and a relative light percentage so you can compare conditions near your plants.
What you’ll need
- One combo flex PCB and one matching 6-pin FFC/FPC adapter from the DHT30 + Light Sensor Flex Kit (5-Pack).
- An ESP32 DevKit with the classic ESP32-WROOM-32 module, a USB data cable, a breadboard, jumper wires, and a soldered header or leads for the adapter.
- A 3.3 V-compatible 128×32 I²C SSD1306 OLED such as the PlantMate 0.91-inch OLED.
- One 10 kΩ resistor for the light sensor. If the I²C modules lack pull-ups, add two 4.7 kΩ resistors for the bus.
1. Identify the six contacts
Disconnect USB power. Hold the flex with its sensors to the left and the exposed contacts facing up. Count from the top contact down. Insert the reinforced tail fully into the adapter and close the latch. Check continuity to the adapter header before applying power. If your flex is marked TEMP_GND and TEMP_3V3, these markings identify pins 1 and 6 respectively. Use the connections in the table.
| Flex pin | Function | Connect to |
|---|---|---|
| 1 | TEMT6000X01 emitter (TEMT_OUT) | ESP32 GPIO34 with a 10 kΩ pull-down to common GND |
| 2 | AHT30 SDA | ESP32 GPIO21, shared with OLED SDA |
| 3 | AHT30 GND | Common GND |
| 4 | AHT30 3.3 V supply (AHT30_3V3) | ESP32 3.3 V |
| 5 | AHT30 SCL | ESP32 GPIO22, shared with OLED SCL |
| 6 | TEMT6000X01 collector (TEMT_3V3) | ESP32 3.3 V |

2. Wire the OLED and both sensors
Connect the OLED’s VCC to 3.3 V and its GND to common ground. Connect both the OLED SDA and flex pin 2 to GPIO21. Connect both the OLED SCL and flex pin 5 to GPIO22. Wire flex pin 4 to 3.3 V and pin 3 to common ground. The ESP32, AHT30 and OLED share a 3.3 V I²C bus, so connect them directly. All SDA and SCL pull-ups must go to 3.3 V. If the modules lack them, connect one 4.7 kΩ resistor from SDA to 3.3 V and another from SCL to 3.3 V.
Run a separate wire from flex pin 6, the TEMT6000X01 collector, to 3.3 V. Connect flex pin 1, the emitter, to GPIO34 (ADC1). Add an external 10 kΩ resistor between GPIO34 and common GND, so one resistor lead shares the GPIO34 and pin 1 junction. The voltage across the resistor rises as more light reaches the phototransistor.

3. Install the libraries and upload the sketch
In Arduino IDE, install esp32 by Espressif Systems in Boards Manager if needed. Select ESP32 Dev Module and the connected port. Install AlashAHT, Adafruit SSD1306, and Adafruit GFX Library from Library Manager. Install Adafruit BusIO if prompted. Copy the sketch below, upload it, then open Serial Monitor at 115200 baud.
Both sensors are enabled by default. You can use either sensor on its own and keep the same OLED wiring.
- Temperature and humidity only. Wire flex pins 2–5 and set
ENABLE_LIGHTtofalse. - Light only. Wire flex pins 1 and 6 with the 10 kΩ pull-down, and set
ENABLE_AHT30tofalse.
Leave unused flex pins unconnected. The OLED shows only the readings for the sensors you enable.
#include <Arduino.h>
#include <Wire.h>
#include <AlashAHT.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Classic ESP32-WROOM-32 DevKit, PlantMate combo flex PCB, and 128x32 OLED.
// AHT30: flex pins 2 and 5 share GPIO21 SDA and GPIO22 SCL with the OLED.
// Flex pin 3 goes to common GND. Flex pins 4 and 6 each go to 3.3 V.
// Light: flex pin 1 goes to GPIO34. A 10 kΩ resistor goes from GPIO34 to GND.
constexpr bool ENABLE_AHT30 = true;
constexpr bool ENABLE_LIGHT = true;
constexpr int SDA_PIN = 21;
constexpr int SCL_PIN = 22;
constexpr int LIGHT_PIN = 34; // ADC1 on the classic ESP32.
constexpr uint8_t OLED_ADDRESS = 0x3C;
constexpr uint32_t I2C_HZ = 100000;
constexpr unsigned long CLIMATE_INTERVAL_MS = 8000;
constexpr unsigned long DISPLAY_INTERVAL_MS = 500;
// Adjust these to your dim and bright reference readings in millivolts.
constexpr int LIGHT_DARK_MV = 150;
constexpr int LIGHT_BRIGHT_MV = 2000;
constexpr uint8_t LIGHT_SAMPLES = 8;
static_assert(ENABLE_AHT30 || ENABLE_LIGHT, "Enable at least one sensor.");
static_assert(LIGHT_DARK_MV < LIGHT_BRIGHT_MV, "Set the bright endpoint above the dark endpoint.");
AlashAHT climate;
Adafruit_SSD1306 oled(128, 32, &Wire, -1, I2C_HZ, I2C_HZ);
bool i2cReady = false;
bool oledReady = false;
bool climateReady = false;
bool climateValid = false;
float temperatureC = 0.0f;
float humidityRh = 0.0f;
unsigned long lastClimateRead = 0;
unsigned long lastDisplay = 0;
void setup() {
Serial.begin(115200);
if (ENABLE_LIGHT) {
analogSetPinAttenuation(LIGHT_PIN, ADC_11db);
}
i2cReady = Wire.begin(SDA_PIN, SCL_PIN, I2C_HZ);
if (i2cReady) {
Wire.setTimeOut(50);
delay(100);
Wire.beginTransmission(OLED_ADDRESS);
oledReady = Wire.endTransmission() == 0 &&
oled.begin(SSD1306_SWITCHCAPVCC, OLED_ADDRESS, false, false);
} else {
Serial.println(F("I2C did not start. Check GPIO21 and GPIO22."));
}
if (oledReady) {
oled.setTextSize(1);
oled.setTextColor(SSD1306_WHITE);
oled.setTextWrap(false);
oled.clearDisplay();
oled.display();
} else {
Serial.println(F("OLED did not start. Check 3.3 V, I2C wiring and address."));
}
if (ENABLE_AHT30) {
climate.setLanguage(AlashAHT::LANG_EN);
}
lastClimateRead = millis() - CLIMATE_INTERVAL_MS;
lastDisplay = millis() - DISPLAY_INTERVAL_MS;
}
void readClimate() {
// Wire is already configured for the shared bus.
if (!climateReady) {
climateReady = climate.begin(Wire, false);
}
climateValid = climateReady && climate.update();
if (climateValid) {
temperatureC = climate.temperature();
humidityRh = climate.humidity();
Serial.print(F("T "));
Serial.print(temperatureC, 1);
Serial.print(F(" C, RH "));
Serial.print(humidityRh, 1);
Serial.println(F(" %"));
} else {
climateReady = false;
Serial.print(F("AHT30: "));
Serial.println(climate.errorText());
}
}
int readLightMillivolts() {
uint32_t total = 0;
for (uint8_t i = 0; i < LIGHT_SAMPLES; ++i) {
total += analogReadMilliVolts(LIGHT_PIN);
}
return (total + LIGHT_SAMPLES / 2) / LIGHT_SAMPLES;
}
int relativeLightPercent(int lightMillivolts) {
const int span = LIGHT_BRIGHT_MV - LIGHT_DARK_MV;
const int level = constrain(lightMillivolts - LIGHT_DARK_MV, 0, span);
return (100L * level + span / 2) / span;
}
void updateOled(int lightPercent) {
oled.clearDisplay();
if (ENABLE_AHT30) {
oled.setCursor(0, 0);
if (climateValid) {
oled.print(F("T "));
oled.print(temperatureC, 1);
oled.print(F(" C"));
oled.setCursor(0, 11);
oled.print(F("RH "));
oled.print(humidityRh, 1);
oled.print(F(" %"));
} else {
oled.print(F("AHT30 read error"));
oled.setCursor(0, 11);
oled.print(F("Check I2C wiring"));
}
}
if (ENABLE_LIGHT) {
oled.setCursor(0, ENABLE_AHT30 ? 22 : 0);
oled.print(F("Light "));
oled.print(lightPercent);
oled.print(F(" %"));
}
oled.display();
}
void loop() {
const unsigned long now = millis();
if (ENABLE_AHT30 && i2cReady && now - lastClimateRead >= CLIMATE_INTERVAL_MS) {
lastClimateRead = now;
readClimate();
}
if (now - lastDisplay < DISPLAY_INTERVAL_MS) {
delay(10);
return;
}
lastDisplay = now;
int lightPercent = 0;
if (ENABLE_LIGHT) {
const int lightMillivolts = readLightMillivolts();
lightPercent = relativeLightPercent(lightMillivolts);
Serial.print(F("Light "));
Serial.print(lightPercent);
Serial.print(F(" % (relative), GPIO34 "));
Serial.print(lightMillivolts);
Serial.println(F(" mV"));
}
if (oledReady) {
updateOled(lightPercent);
}
}
4. Check all three readings
The sketch reads the AHT30 about every eight seconds. The OLED and light reading update about twice per second. Shade the TEMT6000X01 briefly, then expose it to a lamp. The millivolt reading on GPIO34 and the displayed light percentage should rise as the sensor receives more light.
The sketch averages eight calibrated ADC readings and maps LIGHT_DARK_MV and LIGHT_BRIGHT_MV to 0% and 100%. Use the millivolt reading in Serial Monitor to choose dim and bright reference points for your setup. Start with 150 mV and 2000 mV and keep adjustments within about 150–2450 mV for the classic ESP32 ADC at 11 dB attenuation. Very bright light can clip the ADC reading. If the millivolt reading keeps rising after the display reaches 100%, the reading has reached your chosen bright endpoint. Use the percentage to compare light levels in this setup. Measuring lux requires calibration.

If a reading is missing
- OLED stays blank. Check 3.3 V, GND, SDA on GPIO21, and SCL on GPIO22. The sketch expects
0x3C. If an I²C scan finds the OLED at0x3D, updateOLED_ADDRESS. - AHT30 read error. Check flex pins 2–5 and the shared pull-ups to 3.3 V. The AHT30 normally appears at
0x38. - Light stays fixed. Watch the GPIO34 millivolt reading in Serial Monitor while shading the phototransistor. Check that pin 6 has 3.3 V and pin 1 reaches GPIO34. Confirm the 10 kΩ resistor goes from the pin 1/GPIO34 junction to common GND.
For the components used on the flex PCB, see the ASAIR AHT30 product information and the Vishay TEMT6000X01 datasheet. See Espressif’s ADC guide for the recommended measurement range.
Designing an enclosure?
Use the combo flex PCB STEP model to position the sensing head and plan access to the reinforced tail.

