Okay, so I’ve got an ESP8266-based Plant Monitoring system. I have a large 26"x9" indoor herb garden that I’ve decided to fully automate.
It’s set up as follows:
Control: ESP8266MOD (NodeMCU v3)
Lights: 78x SK6812 Strip LEDs (attached to D4).
Relays: 1x 3.3v Relays (built to be expandable to 2x 3.3v relays if needed). The in-use one is attached to a 5v submersible water pump sitting in an 8L reserve tank. (Relays are assigned to D5 & D6)
Switch: Reed-switch style float, mounted in the side of the 8L reserve to detect when the water is low, attached to D7.
1x ADS1115 (assigned to SDA/D1 & SCL/D2)
Attached to A0 and A1 of the ADS1115 are:
2x Capacitive Moisture Sensors (v2.0), set to detect moisture levels in the soil.
(A2 and A3 are unused at the moment)
Sloppy Schematic:
The lights are on a circadian lighting plan (The Adaptive Lighting HACS add-on, controlled by HASS), and the watering is automated within ESPHome, but accessible within HASS as well. When toggled, the relay switches on for 15 seconds and stops. The relays, the switch, the LEDs all work fine.
What doesn’t work, is the detection on the ADS1115. I’m getting inconsistent results on A0 and zero results on A1, or rather A1 is always telling me 100% when the sensor is connected. Cables have been swapped out, moisture sensors have been swapped out, it doesn’t make a difference.
The only anomaly I can find is that when the lights are on (6:00am-7:00pm), the A0 moisture sensor has weird fluctuations in it’s values, but is rock-solid when the lights are off, as seen in my HASS history:
I’ve checked with my multimeter and everything that requires 3v3 is getting the required 3v3 (±0.01v). Everything that needs 5v is getting the required 5v (±0.01v). The LEDs are powered off the input voltage directly, and not through the ESP8266, so I don’t know why the lights themselves would affect anything. Everything is powered off a 5v 3a supply.
ESP Home code:
esphome:
name: plantkit
platform: ESP8266
board: nodemcuv2
on_boot:
priority: -100
then:
- light.turn_on: plantlamp
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
use_address: 192.168.0.5
manual_ip:
static_ip: 192.168.0.5
gateway: 192.168.0.1
subnet: 255.255.255.0
# enable fallback hotspot
ap:
ssid: "Plant Kit"
password: !secret ap_password
captive_portal:
i2c:
sda: 4
scl: 5
ads1115:
- address: 0x48
id: ads1115_X1
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
light:
- platform: neopixelbus
variant: SK6812
type: GRBW
pin: D4
num_leds: 78
name: "Plant Lighting"
id: plantlamp
default_transition_length: 1s
sensor:
- name: "Soil Saturation Sensor 1 (Blue)"
ads1115_id: ads1115_X1
id: soil_sensor_1
update_interval: 60s
unit_of_measurement: "%"
icon: "mdi:water-percent"
gain: 4.096
accuracy_decimals: 0
multiplexer: 'A0_GND' # Don't Change
filters:
- calibrate_linear:
- 0.7 -> 100.00
- 2.625 -> 0.00
- lambda: |
if (x < 0) return 0;
else if (x > 100) return 100;
else return (x);
platform: ads1115
- name: "Soil Saturation Sensor 2 (Red)"
ads1115_id: ads1115_X1
id: soil_sensor_2
update_interval: 60s
unit_of_measurement: "%"
icon: "mdi:water-percent"
gain: 4.096
accuracy_decimals: 0
multiplexer: 'A1_GND'
filters:
- calibrate_linear:
- 0.7 -> 100.00
- 2.625 -> 0.00
- lambda: |
if (x < 0) return 0;
else if (x > 100) return 100;
else return (x);
platform: ads1115
binary_sensor:
# Water Level (Tells if level is low)
- platform: gpio
pin:
number: D6
mode: INPUT_PULLUP
name: "Water low"
id: water_low
device_class: moisture
# SPARE RELAY
# - platform: gpio
# pin:
# number: D7
# inverted: true
# mode: INPUT_PULLUP
# name: "Water low"
# id: water_low
# device_class: moisture
time:
- platform: homeassistant
id: homeassistant_time
on_time:
# Run water pump check momentarily on a schedule
- seconds: 0
minutes: /7
then:
- if:
condition:
lambda: 'return (id(soil_sensor_1).state < 50 || id(soil_sensor_2).state < 50) && id(automatic_watering).state;'
then:
- switch.turn_on: water_pump_relay
switch:
# Water Pump (Switch on watering)
- platform: gpio
pin: D7
name: "Water Pump Relay"
id: water_pump_relay
#internal: true
on_turn_on:
- delay: 15sec
- switch.turn_off: water_pump_relay
# Dummy switch to turn automatic watering on and off
- platform: template
name: "Automatic Watering"
id: automatic_watering
optimistic: true
Am I just overtaxing the ESP8266 somehow?