Water Level Notifier awesome arduino projects with php web mailer

If you live in the midwestern part of the United States like I do, you know all
about heavy rains and the effects they can have on a basement. Stories of
sump pumps failing during torrential downpours are often punctuated with
“Had I only known how quickly the water level in my sump pit was rising, I
would have had more time to move my stored items out of the way.”



other scenario, where someone needs to use a dehumidifier to
remove dampness in a cellar. Inexpensive dehumidifiers often stop working
when water reaches a certain height in the condensation bucket. Some
models may include an audible alarm or flashing light when this shutdown
occurs, but such alerts are ineffective because the dehumidifier is typically
installed in an infrequently visited area.
Wouldn’t it be more convenient to receive an email from your house when the
water levels in these containment areas exceed a certain threshold, alerting
you to take action? (See Figure 1, Have your house email you, on page 24.)
Let’s get our feet wet, so to speak, and build a system that will provide this
helpful notification service.

1.What You Need…

  •  flex sensor.
  •  The buoyancy of rising water levels will bend the sensor.
  •  As the sensor bends one way or the other, current values will increase or decrease
    accordingly.
  •  The sensor’s position can be read with a simple Arduino program.
  •  powered via either the Arduino’s 3.3 or 5.0 volt pins.

1. An Arduino Uno
2. An Ethernet shield1
3. A flex sensor2
4. A 10k ohm resistor3

 




5. A 1-inch fishing bobber
6. Three wires (power, ground, and analog pin 0) trimmed to desired length
7. A 9-volt power supply to power the Arduino and Ethernet shield once
untethered from the USB cable
8. A pole or wood plank to attach and hang the flex resistor from
9. A web server running PHP 4.3 or higher (not pictured)
You will also need a standard A-B USB cable (not pictured) to connect the
Arduino to the computer and an Ethernet cable (also not pictured) to connect
the Ethernet shield to your network.
We will be reusing the Arduino and Ethernet shield again in several other
projects, so—not including the cost of these two items—the remaining hardware
expenses should be under twenty dollars. Considering the peace of mind
and the ease with which you can build further ideas upon this concept, this
is money well spent.

Building the Solution

Before the Water Level Notifier can start broadcasting alerts, we need to
complete the following tasks:
1. Attach wires and a resistor to the exposed sensor leads on one end of the
flex resistor and the fishing bobber on its other end.
2. Connect the leads of the flex sensor to an analog pin of an Arduino.
3. Write a program (i.e., sketch) for the Arduino that will monitor changes
in the flex sensor readings. It should trigger an event when a large-enough
deviation from the initial value is detected.
4. Attach an Ethernet shield to the Arduino so that the sketch can communicate
with a web server running PHP.
5. Write a PHP script that will capture incoming values from the Arduino.
When the water level has changed, it should format a message and send
an email alert to the intended recipient, who will need to react quickly to
the alert!
We will begin by assembling the hardware and testing out the flex sensor
measurements.

Hooking It Up

Let’s start by making sure our flex sensor works the way we intend it to.
Connect the positive lead of the sensor to the Arduino’s 5.0-volt pin using a
wire. When looking at the flex sensor standing on its end, the positive lead
is the trace that runs vertically. The negative lead is the one that looks like


the rungs of a ladder. Connect the negative lead to the analog 0 pin with
another wire. Lastly, bridge the analog 0 pin to the ground pin using the 10k
ohm resistor to dampen the flow of current through the circuit. Refer to Figure
3, Water Level Notifier wiring diagram, on page 28, to make sure you attach
the wires and resistor to the correct pins.
Attach the bobber to the end of the flex sensor. Most bobbers come with a
retractable hook that can be fastened to the plastic tip of the sensor. If the
bobber doesn’t stay affixed to the sensor, you can also use hot glue or heat
shrink tubing to help keep the bobber attached. Just be careful not to damage
the sensor when heating it with these affixing solutions. You can also try duct
tape as a safe alternative, though the tape may lose its grip over time.
Use plenty of wire so you have enough length to safely mount the Arduino
and power source far away from the water source. The Arduino that I have
monitoring my sump pit is sitting in a hobby box mounted on the wall several
feel above the sump pit, and the two wires attached to the flex resistor are
about two meters (roughly six feet) in length.
Now that the Arduino has been wired up, we can work on the logic of what
the hardware is supposed to do for us. We will begin with a quick test program
that will verify that the flex sensor is connected correctly and working properly.

Sketching Things Out

Before we start writing code, we first need to make sure we can communicate
with the Arduino. Then we will learn how to collect and act upon data sent
by the flex sensor with a program (what the Arduino community prefers to
call a sketch).
The first sketch we write will detect when the flex resistor values have changed.
If the change is large enough (in other words, if water is making the resistor
bend), we will transmit a request to a PHP server that will process the request.
That server will then send out an email notifying us of the change.
We will build the sketch incrementally, first by connecting the flex sensor to
the Arduino and collecting values when the sensor is straight and then when
it bends in both directions. Once these values have been identified, we will
write conditional statements that will call functions to send HTTP GET
statements containing data we will include in the email alert.

Configuring an Arduino
We will use the Arduino IDE to write, compile, and download our code into
the Arduino. For those who would like a more comprehensive introduction
to Arduino programming, read Maik Schmidt’s excellent Arduino: A Quick
Start Guide [Sch11].
If you are already familiar with the Arduino or are willing to hang on for the
ride, let’s get started by launching the Arduino IDE. Check to ensure that
your Arduino is connected via USB cable and recognized and selected accordingly
on one of the serial ports identified by the Arduino IDE’s Tools→Serial
Port menu. You can perform a quick test of your configuration with the LED
Blink example program located in the Arduino IDE’s File→Examples→1.Basics
→Blink menu. Upload it to the attached Arduino and check to see that it
executes correctly.
If it fails to do so, first verify that the Arduino is correctly plugged into the
computer and powered by the USB. If it is, check next to be sure you’ve
selected the correct serial port in the Arduino IDE and highlighted the right
type of Arduino board in the Tools→Board. A few correctly placed mouse
clicks on either of these settings usually fixes the problem.
The Flex Sensor Sketch
Now that the Arduino is connected and tested, we can write a sketch that will
validate and interpret the bending of the flex sensor. We will begin by defining
a few constants that we will refer to in the program.


Since we have to account for the sensor bending in either direction, we will
define two named constants that will be used to set the upper and lower
threshold limits.
We place these constants at the beginning of the sketch so they’re easier to
locate in case we need to edit these values later on. By convention, defined
constants are also all uppercase so that they are easier to identify in the code.
Let’s call them FLEX_TOO_HI and FLEX_TOO_LOW. The range between these upper
and lower limits will depend on the degree of flex that is optimal for your own
scenario. I prefer a variance of plus or minus five units to allow a minor
amount of bend before the notification event is triggered. Having such a range
will allow us to account for minor environmental effects like a light breeze or
a low-grade vibration.
We also need to account for the Arduino’s onboard LED and the analog pin
that the flex sensor is attached to.
• FLEX_TOO_HIGH is the value of the assigned analog pin when the flex sensor
is bent forward past this threshold.
• FLEX_TOO_LOW is the value of the assigned analog pin when the flex sensor
is bent backward past this threshold.
• ONBOARD_LED is assigned to the Arduino’s onboard LED located at pin 13.
We will use it provide us with a visual indicator when the flex resistor has
deviated far enough to send an alert. This allows us to use the Arduino’s


onboard LED as a kind of visual debugger so that we can visually confirm
that the flex events are being detected.
• FLEX_SENSOR is connected to the analog pin on the Arduino that the flex
resistor is connected to. In this case, that value is 0 because the resistor
is connected to pin 0.
These constants will be defined at the beginning of the sketch.
Download WaterLevelNotifier/WaterLevelSensor.pde
#define FLEX_TOO_HI 475
#define FLEX_TOO_LOW 465
#define ONBOARD_LED 13
#define FLEX_SENSOR 0
Now we will create two variables to capture the changing value and state of
the flex resistor and set their initial values to zero.
• bend_value will store the changing analog values of the flex resistor as it
bends.

• bend_state is the binary condition of the flex sensor. If it’s straight, its value
is equal to zero. If the flex resistor deviates either direction, we will set its
state to one.
These variables will follow after the define statements we wrote earlier.
Download WaterLevelNotifier/WaterLevelSensor.pde
int bend_value = 0;
byte bend_state = 0;
With the constants defined and the variables initialized, we need to set up
the serial port to monitor the continuous stream of values being polled in the
main program’s loop. The onboard LED also has to be configured so we can
see it turn on and off based on the bend_state of the flex resistor.

void setup()
{
// for serial window debugging
Serial.begin(9600);
// set pin for onboard led
pinMode(ONBOARD_LED, OUTPUT);
}

With the upper and lower flex bending limits defined, we need a routine that
will check to see if these limits have been exceeded. If they have, we will turn
on the Arduino’s onboard LED. When the flex resistor returns to its resting
straight position, we will turn the LED off.

void SendWaterAlert(int bend_value, int bend_state)
{
digitalWrite(ONBOARD_LED, bend_state ? HIGH : LOW);
if (bend_state)
Serial.print(“Water Level Threshold Exceeded, bend_value=”);
else
Serial.print(“Water Level Returned To Normal bend_value=”);
Serial.println(bend_value);
}
Note the first line of this code block: digitalWrite(ONBOARD_LED, bend_state ? HIGH :
LOW);. This ternary operation polls the current state of the flex resistor based
on the value (0 or 1) that we passed to the function. The conditional statement
that follows prints out an appropriate message to the Arduino IDE’s serial
window. If the bend_state is true (HIGH), the flex resistor has been bent past
the limits we defined. In other words, water has exceeded the threshold. If
it’s false (LOW), the flex resistor is straight (i.e., the water level is not rising).

All that is left to write is the program’s main loop. Poll the FLEX_SENSOR
pin (currently defined as analog pin 0) every second for any increase or
decrease in value. When a flex event is detected, print the bend_value to the
serial port so we can see it displayed in the Arduino IDE’s serial window.
Download WaterLevelNotifier/WaterLevelSensor.pde
void loop()
{
// wait a second each loop iteration
delay(1000);
// poll FLEX_SENSOR voltage
bend_value = analogRead(FLEX_SENSOR);
// print bend_value to the serial port for baseline measurement
// comment this out once baseline, upper and lower threshold
// limits have been defined
Serial.print(“bend_value=”);
Serial.println(bend_value);
switch (bend_state)
{
case 0: // bend_value does not exceed high or low values
if (bend_value >= FLEX_TOO_HI || bend_value <= FLEX_TOO_LOW)
{
bend_state = 1;
SendWaterAlert(bend_value, bend_state);
}
break;
case 1: // bend_value exceeds high or low values
if (bend_value < FLEX_TOO_HI && bend_value > FLEX_TOO_LOW)
{

bend_state = 0;
SendWaterAlert(bend_value, bend_state);
}
break;
}
}
The main loop of the sketch will poll the value of the flex resistor every second.
A switch statement tests the condition of the flex resistor. If its last status was
straight (case 0:), check to see if it has since bent beyond the upper and lower
threshold limits. If so, set the bend_state accordingly and call the SendWaterAlert
function. Conversely, if the resistor’s last status was bent (case 1:), check to
see if it’s now straight. If it is, set the bend_state variable to zero and pass that
new state to the SendWaterAlert function.


Depending on the type of flex sensor and Ethernet shield used along with the
voltage pin selected, your baseline value may be different from the baseline
one I recorded. My flex sensor reported a value of 470.
Note the use of semicolons to mark the end of a line of instruction and
brackets to identify conditional blocks. Save the file. It’s also a good idea to
place this and all other code you write under your preferred choice of version
control before proceeding. I recommend Git,6 but others like Mercurial and
Subversion are certainly better than any non–version controlled alternative.
Later on, we will ask the SendWaterAlert function to call another function that
will connect to a designated PHP server. This in turn will send an email alert
that will contain the appropriate alert and the bend_value being monitored. But
before we do, we will verify that our threshold test is working by monitoring
the messages sent to the Arduino IDE’s serial window.
Run the Sketch
Save and click the Verify button in the Arduino IDE’s toolbar. This will compile
the sketch to check for any syntax errors. After confirming that there are
none, send the sketch to the Arduino by clicking the Upload button on the
toolbar. You should see the Arduino’s onboard LED flash a few times, indicating
that it is receiving the sketch. When the rapid flashing stops, the sketch
should be running.

 

Open up the Arduino IDE’s Serial Monitor window. Assuming you haven’t yet
commented out the Serial.print(“bend_value=”); statement in the main loop of the
sketch, observe the numbers that are continuously scrolling upward at a rate
of roughly once a second on the serial monitor’s display. If the characters
being displayed in the window look like gibberish, make sure to select the
correct baud rate (in this case, 9600) in the serial monitor’s drop-down list
located in the lower right corner of the serial monitor window. Take note of
the values of the flex resistor when it is straight, bent forward, and backward.
Depending on the amount of electrical resistance and the type of hardware
being used, update the FLEX_TOO_HIGH and FLEX_TOO_LOW constants to better
calibrate them to the changing values you are seeing in the serial window.
Once these defined amounts have been entered, save the program and upload
again to the Arduino, performing the same procedure as before. It may take
two or three tries to narrow in on the high and low values that help determine
the bend state of the flex resistor.


With the modified upper and lower limits set to best suit your particular
configuration, observe the Arduino’s onboard LED to ensure that it lights up
when the flex resistor bends far enough forward or backward and turns off
when the resistor is straightened back to its original position.

Testing the Sketch

When you are confident that the hardware setup and the uploaded Arduino
sketch are behaving correctly, it’s time to try a simple water test by filling up
a bowl with water and dipping the bobber into the water while holding the
base of the flex resistor between your thumb and forefinger. As an extra precaution,
wrap any exposed solder connecting the two wires to the flex resistor
in waterproof electrical tape. I suggest wrapping the tape several layers thick,
both to have a solid base to hold the resistor as well as to protect it from any
errant drops of water that may accidentally splash or spill.
After properly and safely setting up the test, verify that as the buoyancy of
the water deflects the bobber attached to the flex resistor, the resistor bends
far enough in either direction to turn the LED light on.
Be careful not to submerge the exposed flex resistor. While the amount of
current flowing through the Arduino is relatively low, water and electricity
can make for a deadly combination. Place any electronics, including the flex
resistor and attached bobber, in a sealed plastic bag with enough room to
allow the flex resistor to bend. Use a high degree of caution to make absolutely
sure to not get any of the exposed wiring or electrical connections wet. Doing

 



so could damage your equipment or, even worse, you.
The base functionality of the water level notifier is complete. However, its
method of communicating a rise in water height is limited to a tiny LED on
the Arduino board. While that may be fine for science projects and people
who work right next to the Arduino monitoring the water source in question,
it needs to broadcast its alert beyond simple light illumination.
Receiving an email notification makes more sense, especially when the location
of water measurement is somewhere in the home that is not frequently visited.
Perhaps the detector will even operate at a remote location, such as when
monitoring the status of a sump pit at a vacation home after a heavy rain.
To do so, we will need to clip on an Ethernet shield to the Arduino and write
some code to send an email when the bend threshold is crossed. But before
we add more hardware to this project, we first need to set up a web-based
email notification application that our Arduino sketch can call upon when it
needs to send out an alert.

Writing the Web Mailer



Libraries for sending email directly from the Arduino abound. But these all
rely on a stand-alone, dedicated email server providing the mail gateway. So
even though the mailer code can be compiled into the Arduino sketch, the
solution still relies on an intermediary to send messages from the Arduino to
the email inbox of the intended recipient(s).
If you have access to an SMTP mail server that you can connect to for outbound
message transmission, check out Maik Schmidt’s Arduino: A Quick
Start Guide [Sch11]. His book supplies the necessary code and walkthrough
on how to make this work. If you don’t have access to a dedicated SMTP
gateway, we can use an Internet web hosting service that supports sending
email from a PHP script.
For this project, I have chosen a popular, preconfigured PHP-enabled web
server with an SMTP outbound gateway, a configuration that popular website
hosting companies like Dreamhost.net, Godaddy.com, and others offer to
their customers.
The PHP script for sending email consists of only a few short lines of code.
First, we will pass two parameters to the server: the type of alert to send and
the recorded value of the flex resistor. Then we will compose a mail message
containing the recipient’s email address, the subject, and the message contents.
Then we will send the email.



<?php
// Grab the type of alert to email and
// the current value of the flex resistor.
$alertvalue = $_GET[“alert”];
$flexvalue = $_GET[“flex”];
$contact = ‘your@emailaddress.com’;
if ($alertvalue == “1”) {
$subject = “Water Level Alert”;
$message = “The water level has deflected the flex
resistor to a value of ” . $flexvalue . “.”;
mail($contact, $subject, $message);
echo(“<p>Water Level Alert email sent.</p>”);
} elseif ($alertvalue == “0”) {
$subject = “Water Level OK”;
$message = “The water level is within acceptable levels.
Flex resistor value is ” . $flexvalue . “.”;
mail($contact, $subject, $message);
echo(“<p>Water Level OK email sent.</p>”);

}
?>

The script calls the built-in PHP mail function that passes three required
parameters: recipient(s), subject, and the body of the email. Yes, it’s that
simple.
Save the code to a file called wateralert.php in the root web directory of your
PHP server. You can test the script by opening your web browser and visiting
http://MYPHPSERVERNAME/wateralert.php?alert=1&flex=486. The page
should return a Wat er Level Alert email sent. message in the browser window, and
a corresponding email message should appear in the defined recipient’s inbox.
If it doesn’t, check your PHP server settings and make sure that your web
server is properly configured to use a working email gateway. If you’re still
not having luck with the message test, contact your website hosting provider
to make sure your hosted solution is correctly configured for PHP email
messaging.
By abstracting the delivery mechanism from the logic running in the Arduino,
we can easily modify the message recipients and contents.
Now that we have a working message gateway, we can hook up the Arduino
to an Ethernet shield so the deflected flex resistor can talk to the rest of the
world.

Adding an Ethernet Shield

Attach the Ethernet shield to the Arduino by lining up the base pins so that
the Ethernet jack is on top and facing the same direction as the Arduino USB
jack. Reconnect the wires to the 5V and analog-in 0 (A0) pins found on the
Ethernet shield just like you did when these wires were connected to the
Arduino.
Do the same for the 10k ohm resistor bridging across the ground (Gnd) and
A0 pins. Run your test again and check the values. In my tests, the base
value being read was different compared to the Arduino without the Ethernet
shield, and yours will likely reflect similar results. Since we’re more interested
in the deviation from this base value than the calibration of the actual value
itself, it’s important to use the unbent resistor value in the code and then
determine how far of a plus or minus deflection from this base value is acceptable
before transmitting the alert.
Now that our hardware is network-enabled, we can add the necessary code
to our sketch that transmits the flex sensor status to our PHP server.

Coding the Shield

We will programmatically send data via the Ethernet shield. But we first must
include a reference in the sketch to both the Arduino Ethernet library and
its dependency, the Serial Peripheral Interface (SPI) library.7 These two libraries
contain the code needed to initialize the Ethernet shield and allow us to initialize
it with network configuration details. Both libraries are included in the
Arduino IDE installation, so the only thing we need to do is import the SPI.h

and Ethernet.h libraries via the #include statement. Add these statements at the
beginning of the sketch:
Download WaterLevelNotifier/WaterLevelNotifier.pde
#include <SPI.h>
#include <Ethernet.h>
With the Ethernet library dependency satisfied, we can assign a unique Media
Access Control (MAC) and IP address to the shield. While DHCP libraries are
available from the Arduino community, it’s easier just to set the shield with
a static IP address.
For example, if your home network uses a 192.168.1.1 gateway address, set
the address of the shield to a high IP address like 192.168.1.230. If you plan
on using this address as a persistent static IP, refer to your home router’s
documentation on how to set a static IP range within a DHCP-served network.
Download WaterLevelNotifier/WaterLevelNotifier.pde
// configure the Ethernet Shield parameters
byte MAC[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEF };
// replace this shield IP address with one that resides within
// your own network range
byte IPADDR[] = { 192, 168, 1, 230 };
// replace with your gateway/router address
byte GATEWAY[] = { 192, 168, 1, 1 };
// replace with your subnet address
byte SUBNET[] = { 255, 255, 255, 0 };

// replace this server IP address with that of your PHP server
byte PHPSVR[] = {???, ???, ???, ???};
// initialize a Client object and assign it to your PHP server’s
// IP address connecting over the standard HTTP port 80
Client client(PHPSVR, 80);
Assign constants for the static MAC and IP addresses that will be used by
the Ethernet shield. Add the address of your Internet router to the GATEWAY
value, and add your SUBNET value as well (most home network subnets are
255.255.255.0). The IP address of your PHP server also has to be declared
prior to the sketch’s setup routine.
With the constants declared, we can now properly initialize the Ethernet
shield in the setup section of the sketch.

void setup()

{
// for serial window debugging
Serial.begin(9600);
// set up on board led on digital pin 13 for output
pinMode(ONBOARD_LED, OUTPUT);
// Initialize Ethernet Shield with defined MAC and IP address
Ethernet.begin(MAC, IPADDR, GATEWAY, SUBNET);
// Wait for Ethernet shield to initialize
delay(1000);
}
Note the use of the Ethernet object in Ethernet.begin(MAC, IPADDR, GATEWAY, SUBNET);.
This is where the Ethernet shield gets initialized with the assigned Media
Access Control (MAC) address and IP Address.
38 • Chapter 3. Water Level Notifier
report

OK, we have a working network connection. Now we can move on to the next
step of requesting the appropriate emailer page on your PHP server when the
bend thresholds have been exceeded.

Sending a Message

 



Up to this point, we have told the Arduino to report the analog values being
generated by the flex resistor, initialized the Ethernet shield to connect the
Arduino to our network, and added stubs for routines to call out to our PHP
server script. Now it’s time to add that routine. We’ll call it ContactWebServer.
The ContactWebServer routine will take the same two parameters we captured
for the SendWaterAlert function, namely band_value and bend_state. Add the ContactWeb-
Server(bend_value, bend_state); line at the end of the SendWaterAlert function, since
we will talk to the designated PHP web server address each time the flex
resistor state changes.
We’re almost done. We just have to write the body of the ContactWebServer
function. This will consist of connecting to the PHP web server and printing
the well-formed HTTP GET string to the server. The string will contain and
pass the values of the bend_state and bend_value variables. These will then be
parsed on the server side and the PHP function will respond in kind.

void ContactWebServer(int bend_value, int bend_state)
{
Serial.println(“Connecting to the web server to send alert…”);
if (client.connect())
{
Serial.println(“Connected to PHP server”);
// Make an HTTP request:
client.print(“GET /wateralert.php?alert=”);
client.print(bend_state);
client.print(“&flex=”);
client.print(bend_value);
client.println(” HTTP/1.0″);
client.println();
client.stop();
}
else
{
Serial.println(“Failed to connect to the web server”);
}
}
It’s time to test the completed sketch. Download it to the Arduino, open up
a serial monitor window, bend the flex resistor, and watch the messages.
Check your recipient’s inbox for the corresponding email messages. Did you
receive the “Water Level Alert” and “Water Level OK” email messages that
correspond to the notifications you saw in the serial monitor window? If not,
make sure that your Arduino is connected to your home network by pinging
the IP address you assigned.
Test the PHP email URL and verify that you receive an email when you enter
http://MYPHPSERVER/wateralert.php?alert=1&flex=486 into your web
browser. When everything works as expected, we will be ready to put the
finishing touches on this project and make it fully operational.

All Together Now

We’re nearing the home stretch. Your hardware should look like the setup
pictured , An assembled water level notifier, on page 41. All that
remains is mounting the flex resistor securely and safely in place so that its
flexion is accurately detected and not impeded by any obstacles.
The base where the two wires attach to the exposed flex resistor leads needs
to be firmly stabilized so that when the water level rises and pushes the
bobber upward, the base does not pivot at its fulcrum. If it does pivot, the
flex resistor will remain straight and the running Arduino sketch will fail to
send the appropriate alert notification. Keep the base stabilized and prevent
it from pivoting.
Try using hot glue, heat shrink tubing, or duct tape. If the base still moves,
try attaching a small wood chip splint on each side of the base of the flex
resistor. Extend the splint length-wise approximately two centimeters above
and below the base. Then snugly wrap the splint several times with electrical
tape. Tack the top of the splinted base to a small wood post (such as that cut
from a typical two-by-four piece of lumber) that spans the diameter of the
hole containing the water source.
In the case of a sump pit, you will need to remove the cover of the pit, measure
the interior diameter and visit a lumberyard or hardware store that can cut
the wood for you. Add an extra centimeter to the cut so that the beam can
be wedged tightly as it spans the pit.
Similar principles apply in the case of a dehumidifier. Instead of using a large
piece of wood to act as the mounting base support, use the bottom, pantshanging
portion of an old wooden hanger that can be cut to slightly longer

than the diameter of the dehumidifier’s water collection bucket. Mount the
base of the splinted flex resistor in the center of the wood support. Depending

 



on the depth of the dehumidifier’s bucket, you may need to raise the base of
the flex resistor higher so that the alert doesn’t trigger prematurely when the
bucket is only half-full.
Once you’re satisfied with the stability of the mounted resistor, place the
bobber and flex resistor inside a small plastic bug, such as a locking seal
sandwich bag. This will keep the resistor dry and protected if the water level
rises excessively. Run the wires attached to the resistor a meter or more from
the measured water source and attach them to the Arduino/Ethernet shield
assembly. Power the Arduino using the 9-volt power supply and attach the
network cable to the Ethernet shield. Several seconds after you power up the
Arduino, perform a quick bend test. If you received the water alert and all-clear
messages in your email inbox, then you have succeeded!
Replace the cover of the water containment vessel you are monitoring and
wait for your device to alert you to rising water levels.

 



Congratulations

 

Leave a Reply

Your email address will not be published. Required fields are marked *