Projects 2021 04 14 Snake Tank Pt. 5 - Mobile App
Post
Cancel

Snake Tank Pt. 5 - Mobile App

Preview Image

This article covers the design and implementation of the arduino software for my Snake Tank Humidifier project.

  1. What + Why?
    1. Goals/Requirements
      1. Arduino App
      2. Mobile App
    2. Background
  2. How?
    1. On stock vs custom light control
    2. Supplies
    3. Prepping the gang box
      1. Power cable hole
      2. Control wires hole
    4. Wiring components
      1. Harvest wire from power cord (optional)
      2. AC wiring to relays
      3. Relay control wires
    5. Finish assembly
      1. Hot glue relays in place
      2. Secure outlets in place
      3. Attach outlet cover

What + Why?

The final major component of the Snake Tank Humidifier project is the software, which is responsible for controlling all of the electronics sub-systems and providing remote control of the system with network connectivity

Goals/Requirements

When designing the software for this project I wanted to ensure that the system could be monitored and updated remotely over the network, eliminating the need to change settings with code updates, and allowing for remote monitoring of the system status without a serial connection to a computer. In order to implement this functionality, there will be two separate code bases; one that runs on the arduino, and one for the mobile monitoring and control app.

Arduino App

The arduino app consists of a few main components that control the electronics

  • Two separate outlets connected to AC line voltage, one for day and one for night.
  • Each outlet needs two plugs (one for each tank)
  • Each outlet needs to be able to be independently switched off/on by an arduino microcontroller.

Mobile App

  • Two separate outlets connected to AC line voltage, one for day and one for night.
  • Each outlet needs two plugs (one for each tank)
  • Each outlet needs to be able to be independently switched off/on by an arduino microcontroller.

Background

How?

On stock vs custom light control

I want to discuss a little more in depth my reasoning for building a custom switchable outlet box, rather than using one of the many existing out-of-the box day/night timer setups available online and in pet shops everywhere. The timer I currently use before designing this system works by having a dial similar to that on a wind-up kitchen timer, that completes one rotation every 24 hours. This dial has a bunch of tabs representing equal portions of that rotation that can be pulled out or pushed in to control whether the day or night light will be turned on during the period of time when the arrow is in that section. Each of these sections control 30 minute increments, the timers are pretty easy to install and configure, and they work pretty reliably in my experience.

So why would I go through the trouble of designing my own light controller? Well, for one, those timers are static and have to be changed manually to adjust for seasonal lighting differences, daylight savings time, etc. They are also basically a flip flop switch, meaning that at any given time, one light will be on and the other off; there is no point at which they can be both off or on simulataneously. With my system, I should have the ability to either blend the cycle switches together, or leave a period of no lighting in between the day/night switches.

However, my main purpose in building a custom system is to have dynamic control of the lighting schedule: To replicate the lighting in the snakes native territory, and to be able to alter the lighting schedule according to the season. This will have the added benefit of having timing controlled by syncing to an internet time server, rather than being a relative timer that stops and gets out of sync anytime it is unplugged or loses power for any reason.

Supplies

So the basic design is a custom outlet box with two separate outlets, each switched by it’s own 5V controlled relay. Below are a list of all the required tools and components:

Parts:

Tools:

Prepping the gang box

The first step is to gather components and prepare the gang box for wiring. We need one hole for the main power cable, and two more for each of the relays control wires

Power cable hole

Drill one hole in the side of the gang box with the same diameter as your chosen power cable, making sure the cable fits snugly, reaming the hole slightly larger with the same bit if needed.

Control wires hole

Drill two 1/4 in holes on the opposite side of the gang box for the relay control wires. Each relay will have three 22AWG wires for it’s control, so make sure that you can comfortably fit 3 wires through each of these holes without damaging them.

Wiring components

Once the gang box is prepared, it’s time to start wiring in all the components. This can be a kind of tricky process to get right, so I recommend checking out some video tutorials like this one for proper safety and techniques for wiring outlets.

Safety is the number one priority when dealing with electricity, especially AC line voltage, which has the power to KILL YOU if you aren’t careful. Please take this seriously and make sure everything is unplugged before working on any wiring.

Harvest wire from power cord (optional)

If you decide to harvest the wiring for inside the gang box from the power cable you’re using, cut off a length of about 1-1 1/2 ft. of wire from the end of the cable and remove all of the outer insulation so you’re left with three individual strands of wire. If you’re using separate wire for inside the gang box, skip this step.

AC wiring to relays

Internal outlet wiring diagram

Relay control wires

Finish assembly

Third major component

Hot glue relays in place

Secure outlets in place

Attach outlet cover

This post is licensed under CC BY 4.0 by the author.