CelliesProjects / aquacontrol32

5 channel aquarium LED controller with web interface for ESP32 boards. Supports DS18B20, SSD1306, ILI9341, XPT2046 and SmartConfig. Arduino IDE.
MIT License
59 stars 20 forks source link
aquarium-lights arduino-ide ds18b20 esp32 iot iot-application iot-device led-controller mh-et-d1-mini moon-phase oled-display-ssd1306 smartconfig sntp temperature-logger temperature-sensor tft-display web-interface xpt2046

Codacy Badge

Aquacontrol32

Aquacontrol32 can control 5 led strips to create gradual sunrises and sunsets in your aquarium. It is developed for and tested on MH-ET LIVE MiniKit ESP32 MCUs. Other than the led dimming hardware, no additional hardware is needed to control the device.

The minimum hardware would be a ESP32 board with at least 5 free output pins connected via 100R gate resistors to 5 NPN mosfets that drive the led lights. You will need logic level mosfets for example IRLZ44N mosfets.

With some modifications and provided there are enough pins broken out, Aquacontrol32 should run on basically any ESP32 based board. The built-in web interface already gives access to most functions. The goal is v2.0 as a single binary with all functions accessible via the web interface.

You can connect a 128x64 I2C OLED and/or a ILI9341 SPI tft display to have some feedback on the display(s). The ILI9341 displays usually come with a XPT2046 touch controller which is supported (and assumed).

Another cool feature is support for 3 Dallas DS18B20 temperature sensors, with temperature logging to FATFS and a 30 day temperature history.

Index

Aquacontrol32 dimming down YouTube video

VIDEO

Features

Requirements

Libraries

Most libraries can be installed with the Arduino library Manager Sketch > Include Library > Manage Libraries.

A few have to be downloaded from GitHub:

Install in the Arduino libraries or ESP32 libraries folder.

Quick start

  1. Download and unpack the latest release.
  2. Check if all libraries are installed and the correct version. (in aquacontrol32.ino)
  3. (Optional) Adjust the wifi_password and wifi_network. (in aquacontrol32.ino)
  4. Check and adjust device specific setup in deviceSetup.h and devicePinSetup.h.
  5. Flash your device. Remember to use a FFat partition!
  6. On the first boot ( or after a flash erase ) the internal flash drive will be formatted so first boot will take a little longer. Updating aquacontrol to a new version will not format the drive.

The sensors and displays should be plug and play, except the ILI9341 when it has no MISO pin connected. For these displays you can enable TFT_HAS_NO_MISO (set it to true) in deviceSetup.h.

Compile options

Compile notes

Toggle the GIT_TAG option in deviceSetup.h to enable or disable version information.
Setting GIT_TAG to true makes that the Arduino IDE can no longer compile or flash your script.
You then have to use the script compile.sh to verify your sketch and flash.sh to verify/upload the sketch to the controller. You might have to adjust these scripts for your particular OS or setup.
Read this blog post to see why I choose this method.

Connecting a ILI9341

To override the device detection for ILI9341 displays you can use the ILI9341 force button in the setup page of the web interface. This will force a ILI9341 display until the device reboots.

Lunar cycle night light

SmartConfig and WiFi setup

Set your wifi_network and wifi_password in aquacontrol32.ino before you flash your device. Double check because setting a wrong wifi_network or wifi_password will result in a boot loop!

Or use SmartConfig and take note of the next couple of things.

Note: ESP32s can only connect to a 2.4Ghz WiFi network. Connect your phone to a 2.4Ghz network before starting the SmartConfig app.
Note 2: Since Android 9 only the latest Espressif app seems to work. Android apps now requires location access to probe WiFi.

DHCP or static IP

By default aquacontrol will get an ip address from the DHCP server.

Follow these steps to to set a static ip address:

  1. Enable SET_STATIC_IP (set it to true) in aquacontrol32.ino.
  2. Change STATIC_IP, GATEWAY, SUBNET, PRIMARY_DNS and SECONDARY_DNS to the desired values.

Log files

By default log files are not generated.
This is because log files saved on FFat could reduce the lifetime of the flash memory.
Sensor logging can be enabled in the web interface.

Known issues

Not really an issue but if your controller has a problem after flashing (no Wifi or stuck/not properly booting) reflashing after a full flash erase will solve it almost always.
Always backup your default.aqu in the file manager before flashing and upload it back to the controller after you succesfully flashed your controller.
Use this command to erase flash (FFat INCLUDED!) in Debian based Linux:
~/Arduino/hardware/espressif/esp32/tools/esptool.py --port /dev/ttyUSBx erase_flash

Libraries used in web interface

The test hardware

This program is beerware.

I develop Aquacontrol32 in my spare time for fun. Although I like to code, my afk time is equally important. If you like the project, you could buy me a beer for some moral support.

paypal

MIT License

Copyright (c) 2017 Cellie

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.