Hand tools and fabrication machines
I am an Computer Science Sophomore who is an intern at a small rural water plant facility.
The community celebrated it's 50th anniversary this summer. Being that old, means that much of the water infrastructure is old. It' not uncommon for plumbing between the street and someone's house to spring a leak. If that happens in the middle of the night, it's very possible for the community to wake up in the morning with no water.
I was asked to create a remote monitoring system with the following capabilities:
- 24 hour remote monitoring of the water tank level from a PC, Phone or Tablet.
- SMS notification to employees and key community members, if the water tank is below a specific level.
- Remote Monitoring of the general water plant status with history.
The water plant staff suggested monitoring the PSI because there is a strong relationship between water pressure and water tank level.
After some research we chose an automotive PSI sensor. This is because they are inexpensive, robust, and easy to add to a Particle Photon.
I chose Ubidots as the tool for displaying measurements in a dashboard for the water plant folks. I also tried using both Ubidots and IFTTT for SMS messaging. Ubidots won our responsiveness test when compared to IFTTT. So for the moment, we are using Ubidots exclusively.
The pressure sensor I picked is rated for 5V. Unfortunately the Particle Photon is 3.3V. I wasn't sure the sensor would work. So, I bought the sensor (luckily they are reasonably cheap) and tested it at 3.3V. To power the sensor, I set a bench supply to 3.3V, attached the Red lead from the bench supply to the Red lead on the sensor. I connected the Black lead on the Power supply to the Black lead on the sensor. I put the Red lead from the meter onto the White lead from the sensor and the Black lead from the meter to the Black lead of the power supply.
The initial reading is the voltage value for 0 PSI. I then attached the sensor to an air compressor and set the compressor to 25, 50 and 75 PSI. The voltage values all changed as expected. So, I knew I could use the device with my Particle Photon.
To calibrate the sensor I soldered the Red lead to the 3V3 connector on the power shield. I soldered the Black lead to the GND lead on the power shield. Finally, I connected the White lead to A3.
I wrote a small program that executed analogread (A3) and pushed the value to Ubidots. I repeated the 0, 25, 50, and 75 PSI settings on the air compressor and recorded the analogread values.
I put the values into Excel and scatter plotted them.
In Excel, once I inserted the scatter plot, I used "Quick Layout" on the Design Ribbon to pick a graph that shows the linear regression values. This function turns directly into code. However, the value above has a Y intercept of about 4 PSI. Since 0 PSI should return 0 PSI, I redid the scatter plot with only two points (first and last) and used the new linear regression values in my code.
The water plant staff had a table that mapped pressure to gallons in the tank, which can be used to calculate feet in the tank. The maximum level is 22 feet.
The table isn't entirely correct (6.8 PSI = empty, really means 68 = empty). To turn this into code, I put the low values and the high values into a scatter plot (as described above) and used the resulting formula to do gallons conversion. I then used the conversion from gallons to feet (on the bottom of the table) to provide a feet value.
The dials from Ubidots showing the PSI, Gallons and Feet values.
Everything to this point is "technically correct." However, once the sensor was up and running there were several epiphanies.
- Real world data is very noisy. The water plant staff really didn't want to see every "Burp and Gurgle" the plant makes.
- Though, in general, PSI maps to water tank level, once every 8 hours and 45 minutes the plant runs through a backwash cycle. During that time the PSI values plummet and stay that way for about 15 minutes. This made detecting the "real water level" challenging because the water plant folks didn't want an SMS message in the middle of the night saying the tank level was low, when the system was running through a backwash cycle.
My solution was to average the PSI value. However, it took a couple of weeks of collecting data to get enough information where I could determine the amount of averaging needed to ignore a backwash cycle, but still be responsive to pressure drops caused by a water leak.
Assembly is straightforward. The only sensor is the PSI sensor and I used the same wiring scheme I used when testing (Sensor Red lead - 3V3, Sensor Black lead - GND and Sensor White lead - A3). I mounted the Particle Power Shield on a Proto board and cut it to shape then drilled hole in it so I could mount it in the box.
I was concerned about corrosion because chlorine is used to treat the water, and would be in the air - which causes items to corrode quickly. So, I picked a case that seals tightly and tried to ensure that the holes I drilled (power, antenna and sensor) were sealed.
Though the final results are really nothing more than a Photon, Photon Power Shield and a PSI sensor in a box - it definitely looks cool.
I used a Photon Power Shield because power outages in this area are very common. I didn't want the averaging to stop and the data collection to be reset because the power went out. When the power is out, the tank still has water, the system still has pressure and water is still available in the community.