I’m trying to build a battery-powered (Li-ion) temperature/humidity/motion sensor using the Pico-W, a DHT22, and a PIR sensor. I’ve got it working, but ran into a snag. I need to monitor the voltage of the battery so I can change it when it gets low. Here’s the latest code I’ve tried:
sensor:
# Temperature and Humidity
- platform: dht
model: DHT22
pin: 16
temperature:
name: "My Temperature"
humidity:
name: "My Humidity"
update_interval: 60s
# Read Battery Voltage
- platform: adc
pin: 24
id: "VSYS"
internal: true
# Convert to Battery Percentage
- platform: template
name: "Battery Level"
unit_of_measurement: '%'
update_interval: 5s
lambda: |-
return ((id(VSYS).state-3) /1.2 * 100.00);
# PIR Motion Sensor
binary_sensor:
- platform: gpio
pin: 15
name: "PIR Sensor"
device_class: motion
I receive the following error when I try to compile:
INFO ESPHome 2023.7.0
INFO Reading configuration /config/esphome/pico-test.yaml...
Failed config
sensor.adc: [source /config/esphome/pico-test.yaml:42]
platform: adc
RP2040: Only pins 26, 27, 28 and 29 support ADC.
pin: 24
id: VSYS
internal: True
I thought about connecting physical pin 39 (VSYS) directly to physical pin 34 (GP28/ADC2), then changing the code to use pin 28. I don’t want to fry my Pico (I’m new at this), so I thought I should ask here before moving forward. Will that work, or is there a better way to go about this?