/Smart-Aquarium-Project

This project was developed as a final project for CS362: Computer design at the University of Illinois at Chicago. It was also entered in the yearly expo held at UIC: https://engineeringexpo.uic.edu/news-stories/smart-aquarium/

Primary LanguageJavaMIT LicenseMIT

Smart-Aquarium-Project

This project was developed as a final project for CS362: Computer design at the University of Illinois at Chicago. It was also entered in the yearly expo held at UIC: https://engineeringexpo.uic.edu/news-stories/smart-aquarium/

The goal of this project is to make aquarium monitoring and maintenance easier. Using the Arduino UNO, tasks like light control, testing water quality, temperature control, fish feeding, etc., can be automated. This project has 4 main functionalities: timed fish feeding using a real-time clock, temperature monitoring, water level monitoring, and light control. There is a remote-control aspect over Wi-Fi, where the Wi-Fi module acts as a server and it communicates with the Arduino over serial and mobile device over local a loacal Wi-Fi network. You can control and monitor the Arduino via the android app. The app will allow you to control lights, feed fish, and set an alarm for feeding fish, monitor real-time water temperature and level.

See this for the final results and usage: https://youtu.be/kJp_m0JY0r8

Quick links:

Required Components

  • Arduino UNO 3.
  • Wi-FI module ESP 8266-01.
  • Android device.
  • DS18B20 digital temperature sensor.
  • 16x2 LCD.
  • Stepper Motor.
  • RTC – DS3231.
  • Relay – 5V 2-Channel Relay.
  • Aquarium Lights.
  • Breadboard.
  • Aquarium (For implementation).
  • Wires, Resistors, etc.
  • Male to Male, Male to Female, Female to Female Breadboard Jumper wires.
  • Water Level Sensor.
  • 3.3V Voltage Regulator.

Some diargrams

Communication of WiFi module, Arduino and Android:

Communication and Network Diagram

The above image shows how the individual components communicatre with wach other. The arduino is the one controlling the I/O devices realted to the aquarium. The arduino communicates with the wifi module ESP8266-01. The wifi module is connected to a local network through which it can respond to http get requests. Almost all request that it gets are forwarded to the arduino over serial, to which the arduino reponds and then the wifi module sends the response to the client.

App:

Below is the screenshot of the app this project uses. You can find the code in the Android_Code folder and the .apk file in APK_file folder.

App ScreenShot

LCD working:

Here is what you will see on the LCD once you assemble the project.

LCD in action

Fish feeding Mechanism:

Stepper Mechanism

Building the project

Below there are multiple sections that you can read through, although going in increasing numerical order is okay, it is advised you to go with this order mentioned below for better understanding. Follow the order:

At this point you are done with uploading code to the ESP8266-01. Now for the Arduino.

At this point you have uploaded code to the Arduino, ESP8266-01 and have the wirings done.

  • Now install the APP [link to APK at end] on your android device and follow Section 5.
  • Next, look at the How to use section.

Section 1.1: Wiring the Setup [Arduino Side]

Arduino Pin To where ###### Arduino Pin To where
A0 Water level analog read (S - pin)[Gets analog data] ###### 5 LCD pin 11
A1 Light Relay Pin (Digital Write)[Controls the lights] ###### 6 LCD pin 10
A2 Water level power pin(VCC - pin) [TURN ON/OFF] ###### 7 LCD pin 5
A3 Temperature Sensor Digital Pin[Read temperature] ###### 8 LCD pin 3
A4 None ###### 9 Stepper IC pin 15
A5 None ###### 10 Stepper IC pin 10
0 [RX] TX of ESP8266-01 ###### 11 Stepper IC pin 7
1 [TX] RX of ESP8266-01 ###### 12 StepperIC pin 2
2 Button Used toggle LCD between IP and Normal mode ###### 13 None
3 LCD pin 13 ###### SDA SDA of RTC
4 LCD pin 12 ###### SCL SCL of RTC
  • For Pin Numbering of LCD and Stepper IC look at Section 1.2
  • For Diagrams look at Section 1.3

Section 1.2: LCD, ESP8266-01 and Stepper Pin Numbering

  • Stepper IC:

    • Stepper IC Pin numbers

    • Use Section 1.1 to connect arduino to IC.

    • Use stepper diagram in Section1.2 for connecting IC to stepper.

  • LCD:

    • LCD Pinout
    • For a more detailed view of lcd check section 1.3.
  • ESP8266-01

    • ESP8266-01 Pinout
  • Keep these in mind as future sections would be using this terminology.

Section 1.3: Diagrams

This sections has all connections diagrams for each arduino component.

  • LCD
    • LCD connections
  • RTC
    • RTC connections
  • Lights
    • Light connections
  • Temperature Sensor
    • Temp. sensor connections
  • Stepper motor
    • Stepper connections
  • Water level sensor
    • Water level sensor connections

Section 2.1: ESP8266 - 01 [Program Mode]

The program mode of the esp8266-01 is when the GPIO-0 is connected to ground and all other GPIO pins are disconnected. This mode of the WiFi module is used to upload code to it. We can do this by using the Arduino as a dummy and then using the Rx and Tx Pins to make a connection between the PC and the Wifi Module [More on Flashing the Software in next sections]. In this section let us see what connections we need for the program mode.

Program mode ESP8266-01

Notice the highlighted areas in the above image.

  • The RESET pin of the arduino is grounded - this makes the arduino act a dummy.
  • RX Arduino -> ESP8266-01 RX pin
  • TX Arduino -> ESP8266-01 TX pin
  • GPIO 0 of ESP8266-01 is grounded. [Enables programming mode]

The setup is not for communication between the module and the Arduino, we are uploading code to the ESP, hence we extend the serial channel by connecting rx to rx and tx to tx.

Section 2.2: ESP8266 - 01 [Working Mode]

Once we have the ESP8266-01 programmed use this section to make the appropriate connections to enable the WiFi module to talk with the arduino. The connections go as follows:

Working mode ESP8266-01

The Difference between this and program mode:

  • GPIO 0 is not grounded
  • RX Arduino -> TX ESP8266-01
  • TX Arduino -> RX ESP8266-01
  • GPIO 2 -> LED [Used to indicate status of wifi module]

Section 3: Flashing code onto the ESP8266-01

This is an important section, because we had to do a lot of online digging to get this working. The program mode section 2.1 and this section go hand in hand when it comes to uploading code to the esp8266-01.

Step 1: Set up the EPS8266-01 in program mode as shown in Section 2.1.

Step 2: Connect the Arduino to your computer, and open Arduino IDE.

Step 3: Open preferences and add the ESP board manager.

Step 4: Go to tools and selec the Boards Manager

  • Step 4

Step 5: Install this open source package for ESP8266-01

  • Step 5

Step 6: Choose the Generic ESP8266 Modul e Board from the list of available new boards.

  • Step 6

(Now make sure your arduino is connected and all connections from Section 2.1 are propper )

Step 7: Flash the code from the file server.ino similar to how you do it for any other Arduino.

Important Resource to check out: Installing ESP8266 in Arduino IDE (Windows, Mac OS X, Linux) | Random Nerd Tutorials

Section 4: Flash Software on the Arduino.

This is the easiest section, and majority of the audience are familiar with doing this.

Take the smart_aquarium.ino code and flash it to the arduino using the Arduino IDE.

Section 5: Making the Final Connections.

Assuming that you have completed all the sections prior to this, connect the ESP8266-01 to the Arduino in working mode [Section 2.2], and make sure that the connections from Section 1.1 are made.

We have already provided the Android APK and the code. Next, once all connections are made, power on the arduino and then boot up the APP. Watch: https://youtu.be/kJp_m0JY0r8

References:

Arduino Project Hub. 2018. How to Code Step Motor. [online] Available at: https://create.arduino.cc/projecthub/MisterBotBreak/how-to-code-step-motor-e3e228\ [Accessed 26 February 2021].

Arduino Project Hub. 2021. ESP8266 - Setup and First WiFi Connection. [online] Available at: https://create.arduino.cc/projecthub/neverofftheinternet/esp8266-setup-and-first-wifi-connection-76fc3c\ [Accessed 26 February 2021].

Dimitrov, K., 2017. DIY Arduino Thermometer With DS18B20. [online] Instructables. Available at: https://www.instructables.com/How-To-Make-Arduino-Thermometer-With-DS18B20 [Accessed 26 February 2021].

Electronics Hub. 2018. WiFi Controlled LED using ESP8266 and Arduino | Electronics Hub. [online] Available at: https://www.electronicshub.org/wifi-controlled-led-using-esp8266-and-arduino/#:~:text=A%20simple%20project%20called%20WiFi,of%20a%20simple%20HTML%20webpage. [Accessed 26 February 2021].

iot boys, 2017. How To Use DS18B20 Water Proof Temperature Sensor. [online] Arduino Project Hub. Available at: https://create.arduino.cc/projecthub/iotboys/how-to-use-ds18b20-water-proof-temperature-sensor-2adecc [Accessed 26 February 2021].

jos, o., n.d. Controlling AC Light Using Arduino With Relay Module. [online] Instructables.com. Available at: https://www.instructables.com/Controlling-AC-light-using-Arduino-with-relay-modu/ [Accessed 26 February 2021].

Last Minute Engineers. 2021. In-Depth: Interface DS3231 Precision RTC Module with Arduino. [online] Available at: https://lastminuteengineers.com/ds3231-rtc-arduino-tutorial/ [Accessed 26 February 2021].

Paredes, J., 2017. Add WiFi to Arduino UNO. [online] Arduino Project Hub. Available at: https://create.arduino.cc/projecthub/imjeffparedes/add-wifi-to-arduino-uno-663b9e [Accessed 26 February 2021].

Patel, A., 2020. Remote Control Light Bulb using a Relay. [online] Arduino Project Hub. Available at: https://create.arduino.cc/projecthub/aaravpatel0124/remote-control-light-bulb-using-a-relay-6e659a [Accessed 26 February 2021].

Team, G., 2020. Interfacing float sensor with Arduino - Gadgetronicx. [online] Gadgetronicx. Available at: https://www.gadgetronicx.com/interfacing-float-sensor-arduino/ [Accessed 26 February 2021].

www.arduino.cc. n.d. Hello World Tutorial LCD. [online] Available at: https://www.arduino.cc/en/Tutorial/LibraryExamples/HelloWorld [Accessed 26 February 2021].