The Air Conditioner in my house has its pipe that carry away the condensation broken. Water will start a mini-flood when the AC is turned on and the outside humidity is high. While the Water Alarm built a few days ago was still working great, having to remove the accumulated water frequently was still not a pleasurable task. Therefore, I decided to automate the work by automatically pumping the water away form the small container to a much bigger bucket.
In order to make sure things will go as they should be, i.e., no flooding, push alert will be delivered to multiple devices should there be abnormal situation and the water pump can be forced to activate remotely if needed.
The Water Pump
A simple search brought me to this €4 12V mini water pump available from an online shop, For an extra €0.1 it will come with a hose of 1m in length. The original idea was to turn on the pump whenever the water reached a certain depth, and stop when the water is mostly empty. However, a quick test showed that this pump could only operate when the inlet is totally submersed underwater, it will not work if the inlet is above the water level. That means I have to keep the water to a certain depth to ensure the pump will work when needed. No problem, it just needed to start with the container half filled.
The Power Source
To power both the 12V water pump AND the Spark Core, I can use a single 12V power source and a 7805 to get the 5V power needed for the Spark Core. However, I have found a better alternative when I was browsing online for battery packs, there is one manufacturer producing Li-ion battery packs that have both a 12V and a 5V USB output, with capacity of 8800 mAh, enough to operate this setup for days! The cost was about €7. I decided that this is perfect for the set up here, so I immediately went ahead and ordered one. I’ve got the delivery right to my door the next day.
In order to keep the water at a certain minimum level, and start pumping away excess water when it reached a certain maximum level, two sensors were deployed to produce triggers at Low Water Level and High Water Level. Sensors are extremely simple, each sensor is composed of two wires, placed at the same level as where the minimum or maximum depth is.
One of the two wires in the sensors was connected to an Output Pin, and the other was connected to an Analog Input Pin. The sensors were read by turning on the corresponding output pin and take the value of the analog input. A simple experiment shows that a value below 1000 was returned when a sensor is not submersed inside the water, and if it does, a value above 3000 is read. Therefore, a value of 2000~2500 can be used to reliably tell if the sensor is under or above water.
Same Spark Core is used, a slightly different program was written to turn on and off the water pump when the corresponding water level sensor was triggered. The logic is as below:
Turn on Digital Pin LEVEL_HIGH
Read Analog Input LEVEL_HIGH
Turn off Digital Pin LEVEL_HIGH
If (value > 2000) turn on pump
Turn on Digital Pin LEVEL_LOW
Read Analog Input LEVEL_LOW
Turn off Digital Pin LEVEL_LOW
If (value < 2000) turn off pump
Following is the circuit diagram for connecting all the components together. Note that the relay circuit composes of the 5V relay transistor, diode, resistor and LED is a ready made module as you can see from the above picture.
The whole purpose of having this setup is to avoid excess water flooding the place. Therefore, it is important to know when there is something wrong with the water level, like it is not going down. There are two features built to deal with emergencies like this.
The first one is the Push Alert feature using PushingBox.com. By sending a Critical Level alert to your devices that are capable to receive push alerts (Phone, Computer, Watch, etc.) when the water level failed to fall below the Low Water Level threshold 15s after the pump is turned on when the High Water Level threshold is reached.
The one is a function to force the water pump to activate, in case something wrong with the triggering mechanism. The function exposed to the Cloud API is called “pump”. Just invoking this function via the Spark Cloud API will start the water pump for 10s. After 10s, the pump will stop automatically.
The source code can be found here. Read the Readme and the source, some configuration will be required for it to work for you, such as the API key for the push alert.
Everything was working smoothly on the first try, the pump will turn itself on when the water reached the maximum allowed depth and triggered the High water level sensor. It will turn itself off automatically when the Low water level sensor did not sense any water.
Now, when the water level get high enough to trigger the high water level sensor, the pump will start pumping away the water until the low threshold is reached, then it will stop.