Setting up Atlas Scientific sensors in ESPHome (aquaponics kit)
Posted: Tue Apr 12, 2022 4:42 am
Here's the code I used in order to get my Aquaponics Kit from Atlas Scientific to read data. It's not 100% yet as I haven't worked on calibrating or anything (I'll update when I get there), but I know just getting this far took me probably 5 days of messing around with ESPHome, Tasmota, and just a sprinkle of Arduino.
But first, see my first hand account of Tasmota vs ESPHome with the goal getting everything in Home Assistant for automation (like I believe we're all going for).
I got frustrated with esphome and this forum made me think it was going to be easier to figure out tasmota... Well I was able to get all the sensors to recognize the programming but not send the information back to me.
Getting it that close in Tasmota involved:
- taking the code that Tasmota flashes on your device at the original setup (I have the Atlas Scientific Aquaponics Kit that's powered by an Adafruit Huzzah32 Feather)
- opening it up with Gitpod
- modifying the "platformio_override.ini" for esp32 devices instead of esp8266 AND
- modifying the "user_config_override.h" to #define the ezo sensors, etc, then
- running in the Terminal and praying it builds all the way
- downloading the "tasmota32.bin" file to my computer and moving it into the esptool folder
- opening my computers Terminal in the esptool folder and running the following commands
- (My USB port is COM7)
-
This is when it's ready to go back into Tasmota where you can define if the pins should be "high" or "low" (HUM, CO2, and RTD high. EC, DO, and pH low) so that the proper current is flowing to get readings.
But that's where I got stuck because I couldn't figure out how to use MQTT to share data with Home Assistant.
The big thing for a beginner like me that I couldn't figure out until today was that both i2c and gpio, while located at the same place, have to be defined in order for readings to happen.
I have zero coding experience and am working on automating a pretty significantly sized hydroponic system. I was able to get a little esp32-CAM setup in ESPHome yesterday so I decided to give ESPHome another try for the kit.
here's some code so hopefully you won't have to spend as long as I did figuring it out
(or if you're a seasoned vet you can have a good laugh)
I guess the binary_sensor: is how you define if the pin should be high/low as well as let HA know it's got data you want, while the sensor: lets HA know what kind of data and how often it should give it to you.
For whatever reason I still can't get the co2 sensor to respond, but I figured 5/6 was still pretty good.
Sorry if this post is a little long but I've been creeping around this forum for a while now for advice/guidance and I actually, finally have something I think is worth contributing... The complete beginner's account.
-Ray
But first, see my first hand account of Tasmota vs ESPHome with the goal getting everything in Home Assistant for automation (like I believe we're all going for).
I got frustrated with esphome and this forum made me think it was going to be easier to figure out tasmota... Well I was able to get all the sensors to recognize the programming but not send the information back to me.
Getting it that close in Tasmota involved:
- taking the code that Tasmota flashes on your device at the original setup (I have the Atlas Scientific Aquaponics Kit that's powered by an Adafruit Huzzah32 Feather)
- opening it up with Gitpod
- modifying the "platformio_override.ini" for esp32 devices instead of esp8266 AND
- modifying the "user_config_override.h" to #define the ezo sensors, etc, then
- running in the Terminal
Code: Select all
platformio run -e tasmota32
- downloading the "tasmota32.bin" file to my computer and moving it into the esptool folder
- opening my computers Terminal in the esptool folder and running the following commands
-
Code: Select all
esptool.py --port COM7 erase_flash
-
Code: Select all
esptool.py --port COM7 write_flash -fs 2MB -fm dout 0x0 tasmota32.bin
But that's where I got stuck because I couldn't figure out how to use MQTT to share data with Home Assistant.
The big thing for a beginner like me that I couldn't figure out until today was that both i2c and gpio, while located at the same place, have to be defined in order for readings to happen.
I have zero coding experience and am working on automating a pretty significantly sized hydroponic system. I was able to get a little esp32-CAM setup in ESPHome yesterday so I decided to give ESPHome another try for the kit.
here's some code so hopefully you won't have to spend as long as I did figuring it out
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
(or if you're a seasoned vet you can have a good laugh)
Code: Select all
esphome:
name: lettuce-hub-v4
esp32:
board: featheresp32
framework:
type: arduino
i2c:
sda: 23
scl: 22
scan: True
id: bus_a
binary_sensor:
- platform: gpio
name: "HUM"
pin:
number: 32
inverted: false
mode:
input: true
pullup: true
- platform: gpio
name: "CO2"
pin:
number: 15
inverted: false
mode:
pullup: true
input: true
- platform: gpio
name: "RTD"
pin:
number: 33
mode:
input: true
pullup: true
filters:
- delayed_on: 100ms
- platform: gpio
name: "EC"
pin:
number: 27
mode:
input: true
pullup: false
- platform: gpio
name: "DO"
pin:
number: 12
mode:
input: true
pullup: false
- platform: gpio
name: "pH"
pin:
number: 13
mode:
input: true
pullup: false
sensor:
- platform: ezo
id: EZO_HUM
name: "HUM"
device_class: humidity
state_class: measurement
address: 111
unit_of_measurement: "%"
on_raw_value:
then:
logger.log: "Humidity f****** worked!!!"
- platform: ezo
id: EZO_CO2
name: "CO2"
device_class: carbon_dioxide
state_class: measurement
address: 105
unit_of_measurement: "ppm"
- platform: ezo
id: EZO_RTD
name: "RTD"
device_class: temperature
state_class: measurement
address: 0x66
accuracy_decimals: 2
unit_of_measurement: temperature
- platform: ezo
id: EZO_EC
name: "EC"
state_class: measurement
address: 100
accuracy_decimals: 0
unit_of_measurement: "CN"
- platform: ezo
id: EZO_DO
name: "DO"
state_class: measurement
address: 97
unit_of_measurement: "DO"
- platform: ezo
id: EZO_pH
name: "PH"
device_class: ""
state_class: measurement
address: 99
accuracy_decimals: 2
unit_of_measurement: "pH"
For whatever reason I still can't get the co2 sensor to respond, but I figured 5/6 was still pretty good.
Sorry if this post is a little long but I've been creeping around this forum for a while now for advice/guidance and I actually, finally have something I think is worth contributing... The complete beginner's account.
-Ray