Intro: How to Make a Wifi System That Control Your Aquarium Lighting & Heating
What is it doing ?
A system that switches on / off your aquarium automatically according to a scheduling or manually with a push button or an internet request.
A system that monitors the water temperature and sends email and alerts in case off under or over-heating.
A system that can also be used as heating thermostat.
It works with 3 different schedules that are pre-loaded and can be selected through Internet request. For instance I defined one for working weeks, another for holidays at home and a third for holidays out of home.
By doing so with the same lighting duration you can more enjoy your aquarium when you are at home.
Step 1: How Does It Work ?
The system is based on ESP8266 and use GPIO and WIFI capabilities.
GPIO are used to control 2 relays and to read water temperature from a sensor. The system uses UDP to exchange data with a Linux server. The schedule is weekly / daily / hourly defined. Each hour is divided in 8 parts of 7.5 minutes of duration. The pre-loaded schedule can be overwrite true Internet request. The system regularly sent information to the server so you can remotely know the water temperature and lighting status.
It sends alerts and emails in case of overheating or under-heating.
Step 2: What Do You Need to Do It ?
- 1 x ESP8266
- I choose the Olimex ESP8266-EVB that comes with 3.3 v power, a relay and is high quality.
- 1 or 2 relays
- 1 x DS18B20 waterproof temperature sensor
- 1 x 2N2222 switching transistor or equivalent
- 3 x resistors (100 ohms - 2.7K ohms - 4.7K ohms)
- 1 x button switch
- 1 x electrical box
- 1 x Prototype PCB
- 1 x FT232RL FTDI USB 3.3 V for uploading the software
- 1 x 5v & 3.3v power
Step 3: How to Make It ?
Get all the needed parts
Connect the parts on a breadboard
Solder components on a PCB
Put it all in the box
Download the ESP8266 code https://github.com/cuillerj/AquariumControlSystem.
Use Arduino IDE to download the code inside the ESP8266
Step 4: Server Software
I have an integrated domotic infrastructure.
Data are stored in a MySql DB. I use Tomcat as a web server. 3 batches are permanently running: one is acting as a time server, one is getting data from the ESP8266 and storing in the DB and one eventualy sends configuration update to teh ESP8266. All is running on a Linux server.
Time server is the only one required (run UdpEsp8266ServerTime.java) (unless you add NTP support inside the ESP8266 code).
I suggest to use the provided java code (run traceDataReceived.java) to have a look at the data the ESP8266 send before doing whatever you want.
Step 5: Connect Your Lighting and Heating Wires
Now it is time to test and eventually develop your own server code.
Use USB Serial adapter and the debug mode to test and develop. When you will get what you want you will have to deal with electrical power. So you must be very careful. It could be dangerous ! If you are not used to doing with, ask someone help. You must connect wires to the relays.
I modified a power outlet by cutting copper strip in order to get dedicated outlets for lighting and heating.