Home Project guides Solar-Powered Environmental Station
Intermediate

Solar-Powered Environmental Station

Estimated cost $40-60 · 8 parts

Bill of materials

ESP32-S3
BME280 (temp/humidity/pressure)
PMS5003 (air quality)
INA219 (power monitor)
6V 3W Solar Panel
CN3791 MPPT Controller
18650 Battery x2
IP67 Enclosure

Wiring

Solar Panel (6V 3W)
    │
    └─► CN3791 MPPT
           │
           └─► 2x 18650 (parallel)
                  │
                  └─► INA219 (monitor)
                         │
                         └─► ESP32-S3
                                │
                                ├─► BME280 (I2C)
                                └─► PMS5003 (UART)

Source code

main.py / main.ino
import machine
import time
import network
import urequests
import bme280
from pms5003 import PMS5003

# Deep sleep for power saving
def deep_sleep(seconds):
    machine.deepsleep(seconds * 1000)

def read_sensors():
    i2c = machine.I2C(0, scl=machine.Pin(9), sda=machine.Pin(8))
    bme = bme280.BME280(i2c=i2c)
    pms = PMS5003(uart=machine.UART(1, baudrate=9600))
    ina = INA219(i2c=i2c)
    
    return {
        'temp': bme.temperature,
        'humidity': bme.humidity,
        'pressure': bme.pressure,
        'pm25': pms.pm25,
        'pm10': pms.pm10,
        'battery_v': ina.voltage(),
        'solar_ma': ina.current()
    }

def main():
    # Connect WiFi
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    wlan.connect('SSID', 'password')
    
    # Read and send
    data = read_sensors()
    urequests.post('https://api.dendat.ai/sensor', json=data)
    
    # Sleep for 5 minutes
    deep_sleep(300)

main()