Hello everyone, I had the pleasure to show you my first simple project for the temperature management of my aquarium and ask you for advice on development.
The design is based on an ESP8266MOD (nodemcu v2), a DALLAS probe and an SSD1306 128x64 i2c display.
If the temperature is lower than 23 then the heater is activated. If it is higher than 27 then it activates the fan. Between 23 and 27 then it turns off everything.
The OLED display shows current temperature with a graph of recent values and the status of switches.
Below the code developed:
esphome:
name: esp8266mod
esp8266:
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "..."
ota:
password: "..."
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
switch:
- platform: gpio
pin: D4 #Internal LED switching
name: "Internal LED"
id: Internal_LED
inverted: yes
- platform: gpio
pin: D6
name: "Heat Switch 1"
id: Heat_Switch_1
inverted: yes
- platform: gpio
pin: D7
name: "Fan Switch 1"
id: Fan_Switch_1
inverted: yes
dallas:
- pin: D5
update_interval: 10s
sensor:
- platform: dallas
address: 0x920312979463c228
name: "Acquario"
id: acquario
on_value_range:
below: 23
then:
- switch.turn_on: Heat_Switch_1
- switch.turn_off: Fan_Switch_1
- above: 23
below: 27
then:
- switch.turn_off: Heat_Switch_1
- switch.turn_off: Fan_Switch_1
- above: 27
then:
- switch.turn_off: Heat_Switch_1
- switch.turn_on: Fan_Switch_1
i2c:
sda: D2
scl: D1
scan: true
font:
- file: 'arialblk.ttf'
id: font1
size: 18
- file: 'arial.ttf'
id: font2
size: 15
graph:
- id: single_temperature_graph
sensor: acquario
duration: 10min
width: 110
height: 41
x_grid: 1min
y_grid: 1.0
line_type: SOLID
line_thickness: 3
display:
- platform: ssd1306_i2c
setup_priority: -100
model: "SSD1306 128x64"
#address: 0x3C
update_interval: 1s
contrast: 90%
id: sensor_display
pages:
- id: page1
lambda: |-
it.printf(20, 1, id(font2), TextAlign::TOP_LEFT , "Current:%.1f°", id(acquario).state);
it.graph(10, 20, id(single_temperature_graph));
- id: page2
lambda: |-
it.printf(20, 1, id(font2), TextAlign::TOP_LEFT , "Current:%.1f°", id(acquario).state);
it.printf(5, 30, id(font1), "Heat 1: %s", id (Heat_Switch_1).state? "ON": "OFF");
- id: page3
lambda: |-
it.printf(20, 1, id(font2), TextAlign::TOP_LEFT , "Current:%.1f°", id(acquario).state);
it.graph(10, 20, id(single_temperature_graph));
- id: page4
lambda: |-
it.printf(20, 1, id(font2), TextAlign::TOP_LEFT , "Current:%.1f°", id(acquario).state);
it.printf(5, 25, id(font1), " Fan 1: %s", id (Fan_Switch_1).state? "ON": "OFF");
interval:
- interval: 5sec
then:
display.page.show_next: sensor_display
Finally, I created on HA a simple Dashboard with indicator and status switch:
The code:
type: gauge
entity: sensor.acquario
name: Temperature
unit: °C
min: 10
max: 40
segments:
- from: 10
color: '#0000B0'
- from: 23
color: '#00A000'
- from: 27
color: '#db4437'
needle: true
I would like to add two additional temperature bands to duplicate heaters and fans.
Unfortunately to manage two more switches I need additional GPOs that are not available on nodemcu.
What do you suggest I do?
- Buy an esp32-WROOM?
- Are there any port replicators that I can insert into the project?
Thank you in advance for your support.
I would like to have your comments since this is my first project. : )
M@t