Hello everyone, I’m thrilled to share my latest project with you! I’ve recently completed a simple yet effective temperature management system for my aquarium, and I’d love to hear your thoughts and suggestions for further development.
Project Overview
My setup uses an ESP8266 NodeMCU v2, a Dallas temperature probe, and an SSD1306 128x64 I2C display. The system monitors the aquarium temperature and activates a heater if it drops below 23°C or a fan if it exceeds 27°C. The OLED display provides real-time temperature updates and a graph of recent values.
Here’s the code I developed:
esphome
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
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: |-…
I’ve also integrated this system with Home Assistant, creating a simple dashboard to monitor the temperature and control the switches. Here’s the dashboard code:
yaml
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
Challenges and Questions
While this project has been a great learning experience, I’m now looking to expand it. I’d like to add two more temperature bands to support additional heaters and fans. However, the NodeMCU v2 doesn’t have enough GPIO pins for this expansion.
Possible Solutions
- Upgrade to ESP32-WROOM: This module offers more GPIO pins and could provide the necessary flexibility for my project.
- Use Port Replicators: Are there any port replicators or expansion boards that could work with my current setup without complicating things?
I’d love to hear your thoughts on these options or any alternative solutions you might suggest. Whether it’s about hardware choices, software configurations, or best practices for aquarium temperature control, your insights would be invaluable!
Thank you in advance for your support and suggestions. I’m really excited to take this project to the next level! ![]()
Best regards,
M@t