Introduction: A Real-Time Well Water Temperature, Conductivity & Water Level Meter
These instructions describe how to build a low-cost, real-time, water meter for monitoring temperature, Electrical Conductivity (EC) and water levels in dug wells. The meter is designed to hang inside a dug well, measure the water temperature, EC and water level once a day, and send the data by WiFi or cellular connection to the Internet for immediate viewing and downloading. The cost for the parts to build the meter is approximately Can$230 for the WiFi version and Can$330 for the cellular version. The water meter is shown in Figure 1. A full report with building instructions, parts list, tips for constructing and operating the meter, and how to install the meter in a water well is provided in the attached file (EC Meter Instructions.pdf). A previously published version of this water meter is available for monitoring water levels only (https://www.instructables.com/id/A-Real-Time-Well-...).
The meter uses three sensors: 1) an ultrasonic sensor to measure the depth to water in the well; 2) a waterproof thermometer to measure water temperature, and 3) a common household two-pronged plug, which is used as a low-cost EC sensor to measure the electrical conductivity of the water. The ultrasonic sensor is attached directly to the meter case, which hangs at the top of the well and measures the distance between the sensor and the water level in the well; the ultrasonic sensor is not in direct contact with the water in the well. The temperature and EC sensors must be immersed under the water; these two sensors are attached to the meter case with a cable that is long enough to allow the sensors to extend below the water level.
The sensors are attached to an Internet-of-Things (IoT) device that connects to a WiFi or cellular network and sends the water data to a web service to be graphed. The web service used in this project is ThingSpeak.com (https://thingspeak.com/), which is free to use for non-commercial small projects (fewer than 8,200 messages/day). In order for the WiFi version of the meter to work, it must be located close to a WiFi network. Domestic water wells often meet this condition because they are located close to a house with WiFi. The meter does not include a data logger, rather it sends the water data to ThingSpeak where it is stored in the cloud. Therefore, if there is a data transmission problem (e.g. during an Internet outage) the water data for that day are not transmitted and are permanently lost.
The meter design presented here was modified after a meter that was made for measuring water levels in a domestic water tank and reporting the water level via Twitter (https://www.instructables.com/id/Wi-Fi-Twitter-Wat...). The main differences between the original design and the design presented here are the ability to operate the meter on AA batteries instead of a wired power adaptor, the ability to view the data in a time-series graph instead of a Twitter message, the use of an ultrasonic sensor that is specifically designed for measuring water levels, and the addition of temperature and EC sensors.
The low-cost, custom-made EC sensor, which is made with a common household plug, was based on a sensor design for measuring fertilizer concentrations in a hydroponics or aquaponics operation (https://hackaday.io/project/7008-fly-wars-a-hacker...). The conductivity measurements from the EC sensor are temperature compensated using the temperature data provided by the water temperature sensor. The custom-made EC sensor relies on a simple electrical circuit (DC voltage divider) which can only be used for relatively quick, discrete conductivity measurements (i.e. not for continuous EC measurements). Conductivity measurements with this design can be taken approximately every five seconds. Because this circuit uses DC current rather than AC current, taking conductivity measurements at less than five second intervals may cause the ions in the water to become polarized, leading to inaccurate readings. The custom-made EC sensor was tested against a commercial EC meter (YSI EcoSense pH/EC 1030A) and was found to measure conductivity within approximately 10% of the commercial meter for solutions that are within ±500 uS/cm of the sensor’s calibration value. If desired, the low-cost custom-made EC sensor can be substituted with a commercially probe, such as the Atlas Scientific conductivity probe (https://atlas-scientific.com/probes/conductivity-p...).
The water meter in this report was designed and tested for large diameter (0.9 m inside diameter) dug wells with shallow water depths (less than 10 m below ground surface). However, it could potentially be used for measuring water levels in other situations, such as environmental monitoring wells, drilled wells, and surface water bodies.
Step-by-step instructions for constructing the water meter are provided below. It is recommended that the builder read through all constructions steps before starting the meter construction process. The IoT device used in this project is a Particle Photon, and therefore in the following sections the terms “IoT device” and “Photon” are used interchangeably.
Table 1: Parts List
Water level sensor – MaxBotix MB7389 (5m range) https://www.maxbotix.com/Ultrasonic_Sensors/MB7389...
Waterproof digital temperature sensor https://www.robotshop.com/ca/en/ds18b20-waterproof...
IoT device - Particle Photon with headers https://store.particle.io/collections/wifi/product...
Antenna (antenna installed inside the meter case) – 2.4 GHz, 6dBi, IPEX or u.FL connector, 170 mm long
Extension cord for making the conductivity probe – 2 prong, common outdoor cord, 5 m length
Wire used to extend temperature probe, 4 conductors, 5 m length
Wire – jumper wire with push on connectors (300 mm length)
Battery pack – 4 X AA
Batteries – 4 X AA
Plumbing and Hardware Parts:
Pipe - ABS, 50 mm (2 inch) diameter, 125 mm long
Top cap, ABS, 50 mm (2 inch), threaded with gasket to make a watertight seal
Bottom cap, PVC, 50 mm (2 inch) with ¾ inch female NPT thread to fit sensor
2 Pipe couplers, ABS, 50 mm (2 inch) to connect top and bottom cap to ABS pipe
Eye bolt and 2 nuts, stainless steel (1/4 inch) to make hanger on the top cap
Other materials: electrical tape, Teflon tape, heat shrink, pill bottle to make EC sensor cover, solder, silicone, glue for assembling case
Step 1: Assemble the Meter Case
Assemble the meter case as shown in Figures 1 and 2 above. The total length of the assembled meter, tip to tip including the sensor and eye bolt, is approximately 320 mm. The 50 mm diameter ABS pipe used to make the meter case should be cut to approximately 125 mm in length. This allows sufficient space inside the case to house the IoT device, battery pack, and a 170 mm-long internal antenna.
Seal all joints with either silicon or ABS glue to make the case watertight. This is very important, otherwise moisture can get inside the case and destroy the internal components. A small desiccant pack can be placed inside the case to absorb moisture.
Install an eye bolt in the top cap by drilling a hole and inserting the eye bolt and nut. A nut should be used on both the inside and the outside of the case to secure the eye bolt. Silicon the inside of the cap at the bolt hole to make it watertight.
Step 2: Attach Wires to Sensors
Water Level Sensor:
Three wires (see Figure 3a) must be soldered to the water level sensor in order to attach it to the Photon (i.e. sensor pins GND, V+, and Pin 2). Soldering the wires to the sensor can be challenging because the connection holes on the sensor are small and close together. It is very important that the wires are properly soldered to the sensor so there is a good, strong physical and electrical connection and no solder arcs between adjacent wires. Good lighting and a magnifying lens help with the soldering process. For those who do not have previous soldering experience, some practice soldering is recommended prior to soldering the wires to the sensor. An online tutorial on how to solder is available from SparkFun Electronics (https://learn.sparkfun.com/tutorials/how-to-solder...).
After the wires are soldered to the sensor, any excess bare wire that sticks out from the sensor can be trimmed off with wire cutters to approximately 2 mm length. It is recommended that the solder joints be covered with a thick bead of silicon. This gives the connections more strength and reduces the chance of corrosion and electrical problems at the sensor connections if moisture gets into the meter case. Electrical tape can also be wrapped around the three wires at the sensor connection to provide additional protection and strain relief, reducing the chance that the wires will break at the solder joints.
The sensor wires can have push-on-type connectors (see Figure 3b) at the one end to attach to the Photon. Using push-on connectors makes it easier to assemble and disassemble the meter. The sensor wires should be at least 270 mm long so they can extend the entire length of the meter case. This length will allow the Photon to be connected from the top end of the case with the sensor in place at the bottom end of the case. Note that this recommended wire length assumes that the ABS pipe used to make the meter case is cut to a length of 125 mm. Confirm in advance of cutting and soldering the wires to the sensor that a wire length of 270 mm is sufficient to extend beyond the top of the meter case so that the Photon can be connected after the case has been assembled and the sensor is permanently attached to the case.
The water level sensor can now be attached to the meter case. It should be screwed tightly into the bottom cap, using Teflon tape to ensure a watertight seal.
The DS18B20 waterproof temperature sensor has three wires (Fig. 4), which are usually coloured red (V+), black (GND) and yellow (data). These temperature sensors typically come with a relatively short cable, less than 2 m long, which is not long enough to allow the sensor to reach the water level in the well. Therefore, the sensor cable must be extended with a waterproof cable and joined to the sensor cable with a waterproof splice. This can be done by coating the solder connections with silicon, followed by heat shrink. Instructions for making a waterproof splice are provided here: https://www.maxbotix.com/Tutorials/133.htm. The extension cable can be made using common outdoor telephone extension line, which has four conductors and is readily available for purchase online at low cost. The cable should be long enough so the temperature sensor can extend from the meter case and be immersed under water in the well, including an allowance for water level drop.
In order for the temperature sensor to work, a resistor must be connected between the red (V+) and yellow (data) wires of the sensor. The resistor can be installed inside the meter case directly on the Photon pins where the temperature sensor wires attach, as listed below in Table 2. The resistor value is flexible. For this project, a 2.2 kOhm resistor was used, however, any value between 2.2 kOhm and 4.7 kOhm will work. The temperature sensor also requires a special code to operate. The temperature sensor code will be added later, as described in Section 3.4 (Software Setup). Further information about connecting a temperature sensor to a Photon can be found in the tutorial here: https://docs.particle.io/workshops/photon-maker-k...
The cable for the temperature sensor must be inserted through the meter case so it can attach to the Photon. The cable should be inserted through the bottom of the case by drilling a hole through the case bottom cap (Fig. 5). The same hole can be used to insert the conductivity sensor cable, as described in Section 3.2.3. After the cable is inserted, the hole should be thoroughly sealed with silicon to prevent any moisture from entering the case.
The EC sensor used in this project is made from a standard North American Type A, 2 prong electrical plug inserted through a plastic “pill bottle” to control “wall effects” (Fig. 6). Wall effects can affect conductivity readings when the sensor is within about 40 mm of another object. Adding the pill bottle as a protective case around the sensor will control wall effects if the sensor is in close contact with the side of the water well or another object in the well. A hole is drilled through the pill bottle cap to insert the sensor cable and the bottom of the pill bottle is cut off so the water can flow into the bottle and be in direct contact with the plug prongs.
The EC sensor has two wires, including a ground wire and a data wire. It does not matter which plug prong you choose to be the ground and data wires. If a sufficiently long extension cord is used to make the EC sensor, then the cable will be long enough to reach the water level in the well and no waterproof splice will be needed to extend the sensor cable. A resistor must be connected between the data wire of the EC sensor and a Photon pin to provide power. The resistor can be installed inside the meter case directly on the Photon pins where the EC sensor wires attach, as listed below in Table 2. The resistor value is flexible. For this project, a 1 kOhm resistor was used; however, any value between 500 Ohm and 2.2 kOhm will work. Higher resistor values are better for measuring low conductivity solutions. The code included with these instructions uses a 1 kOhm resistor; if a different resistor is used, the value of the resistor must be adjusted in line 133 of the code.
The cable for the EC sensor must be inserted through the meter case so it can attach to the Photon. The cable should be inserted through the bottom of the case by drilling a hole through the case bottom cap (Fig. 5). The same hole can be used to insert the temperature sensor cable. After the cable is inserted, the hole should be thoroughly sealed with silicon to prevent any moisture from entering the case.
The EC sensor must be calibrated using a commercial EC meter. The calibration procedure is done in the field, as described in Section 5.2 (Field Setup Procedure) of the attached report (EC Meter Instructions.pdf). The calibration is done to determine the cell constant for the EC meter. The cell constant depends on the properties of the EC sensor, including the type of metal the prongs are made of, the surface area of the prongs, and the distance between the prongs. For a standard Type A plug like the one used in this project, the cell constant is approximately 0.3. Further information on the theory and measurement of conductivity is available here: https://support.hach.com/ci/okcsFattach/get/100253... and here: https://www.emerson.com/documents/automation/appli...
Step 3: Attach Sensors, Battery Pack, and Antenna to IoT Device
Attach the three sensors, battery pack, and antenna to the Photon (Fig. 7), and insert all parts into the meter case. Table 2 provides a list of the pin connections indicated in Figure 7. The sensors and battery pack wires can be attached by soldering directly to the Photon or with push-on-type connectors that attach to the header pins on the underside of the Photon (as seen in Fig. 2). Using push-on connectors makes it easier to disassemble the meter or replace the Photon if it fails. The antenna connection on the Photon requires a u.FL type connector (Fig. 7) and needs to be very firmly pushed onto the Photon to make the connection. Do not install the batteries into the battery pack until the meter is ready to be tested or installed in a well. There is no on/off switch included in this design, so the meter is turned on and off by installing and removing the batteries.
Table 2: List of pin connections on the IoT device (Particle Photon):
Photon pin D2 - connect to - WL sensor pin 6, V+ (red wire)
Photon pin D3 - connect to - WL sensor pin 2, data (brown wire)
Photon pin GND - connect to - WL sensor pin 7, GND (black wire)
Photon pin D5 - connect to - Temp sensor, data (yellow wire)
Photon pin D6 - connect to - Temp sensor, V+ (red wire)
Photon pin A4 - connect to - Temp sensor, GND (black wire)
Photon pin D5 to D6 - Temp sensor, resistor R1 (connect a 2.2k resistor between Photon pins D5 and D6)
Photon pin A0 - connect to - EC sensor, data
Photon pin A1 - connect to - EC sensor, GND
Photon pin A2 to A0 - EC sensor, resistor R2 (connect a 1k resistor between Photon pins A0 and A2)
Photon pin VIN - connect to - Battery pack, V+ (red wire)
Photon pin GND - connect to - Battery pack, GND (black wire)
Photon u.FL pin - connect to - Antenna
Step 4: Software Setup
Five main steps are needed to set up the software for the meter:
1. Create a Particle account that will provide an online interface with the Photon. To do this, download the Particle mobile app to a smartphone: https://docs.particle.io/quickstart/photon/. After installing the app, create a Particle account and follow the online instructions to add the Photon to the account. Note that any additional Photons can be added to the same account without the need to download the Particle app and create an account again.
2. Create a ThingSpeak account https://thingspeak.com/login and set up a new channel to display the water level data. An example of a ThingSpeak webpage for a water meter is shown in Figure 8, which can also be viewed here: https://thingspeak.com/channels/316660 Instructions for setting up a ThingSpeak channel are provided at: https://docs.particle.io/tutorials/device-cloud/we... Note that additional channels for other Photons can be added to the same account without the need to create another ThingSpeak account.
3. A “webhook” is required in order to pass water level data from the Photon to the ThingSpeak channel. Instructions for setting up a webhook are provided in Appendix B of the attached report (EC Meter Instructions.pdf) If more than one water meter is being built, a new webhook with a unique name must be created for each additional Photon.
4. The webhook that was created in the above step must be inserted into the code that operates the Photon. The code for the WiFi version of the water level meter is provided in the attached file (Code1_WiFi_Version_ECMeter.txt). On a computer, go to the Particle webpage https://thingspeak.com/login login to the Particle account, and navigate to the Particle app interface. Copy the code and use it to create a new app in the Particle app interface. Insert the name of the webhook created above into line 154 of the code. To do this, delete the text inside the quotes and insert the new webhook name inside the quotes in line 154, which reads as follows: Particle.publish("Insert_Webhook_Name_Inside_These_Quotes".
5. The code can now be verified, saved, and installed onto the Photon. When the code is verified it will return an error that says “OneWire.h: No such file or directory”. OneWire is the library code that runs the temperature sensor. This error must be fixed by installing the OneWire code from the Particle library. To do this, go to the Particle App interface with your code displayed and scroll down to the Libraries icon on the left-hand side of the screen (located just above the question mark icon). Click on the Libraries icon, and search for OneWire. Select OneWire and click “Include in Project”. Choose the name of your app from the list, click “Confirm” and then save the app. This will add three new lines to the top of the code. These three new lines can be deleted without affecting the code. It is recommended that you delete these three lines so that the code line numbers will match the instructions in this document. If the three lines are left in place, then all code line numbers discussed in this document will be advanced by three lines. Note that the code is stored in and installed onto the Photon from the cloud. This code will be used to operate the water meter when it is in the water well. During the field installation, some changes will need to be made to the code to set the reporting frequency to once a day and add information about the water well (this is described in the attached file "EC Meter Instructions.pdf" in the section entitled “Installing the Meter in a Water Well”).
Step 5: Test the Meter
The meter construction and software setup are now complete. At this point it is recommended that the meter be tested. Two tests should be completed. The first test is used to confirm that the meter can correctly measure water levels, EC values and temperature and send the data to ThingSpeak. The second test is used to confirm that the power consumption of the Photon is within the expected range. This second test is useful because the batteries will fail sooner than expected if the Photon is using too much power.
For testing purposes, the code is set to measure and report water levels every two minutes. This is a practical time period to wait between measurements while the meter is being tested. If a different measurement frequency is desired, change the variable called MeasureTime in line 19 of the code to the desired measurement frequency. The measurement frequency is entered in seconds (i.e. 120 seconds equals two minutes).
The first test can be done in the office by hanging the meter above the floor, turning it on, and checking that the ThingSpeak channel accurately reports the distance between the sensor and the floor. In this testing scenario the ultrasonic pulse reflects off the floor, which is used to simulate the water surface in the well. The EC and temperature sensors can be placed in a container of water of known temperature and conductivity (i.e. as measured by a commercial EC meter) to confirm the sensors report the correct values to the ThingSpeak channel.
For the second test, the electrical current between the battery pack and the Photon should be measured to confirm that it matches the specifications in the Photon datasheet: https://docs.particle.io/datasheets/wi-fi/photon-d... Experience has shown that this test helps identify defective IoT devices before they are deployed in the field. Measure the current by placing a current meter between the positive V+ wire (red wire) on the battery pack and the VIN pin on the Photon. The current should be measured in both operating mode and deep sleep mode. To do this, turn the Photon on and it will start up in operating mode (as indicated by the LED on the Photon turning a cyan colour), which runs for approximately 20 seconds. Use the current meter to observe the operating current during this time. The Photon will then automatically go into deep sleep mode for two minutes (as indicated by the LED on the Photon turning off). Use the current meter to observe the deep sleep current at this time. The operating current should be between 80 and 100 mA, and the deep sleep current should be between 80 and 100 µA. If the current is higher than these values, the Photon should be replaced.
The meter is now ready to be installed in a water well (Fig. 9). Instructions on how to install the meter in a water well, as well as meter construction and operation tips, are provided in the attached file (EC Meter Instructions.pdf).
Step 6: How to Make a Cellular Version of the Meter
A cellular version of the water meter can be built by making modifications to the previously described parts list, instructions and code. The cellular version does not require WiFi because it connects to the Internet via a cellular signal. The cost of the parts to build the cellular version of the meter is approximately Can$330 (excluding taxes and shipping), plus approximately Can$4 per month for the cellular data plan that comes with the cellular IoT device.
The cellular meter uses the same parts and construction steps listed above with the following modifications:
• Substitute the WiFi IoT device (Particle Photon) for a cellular IoT device (Particle Electron): https://store.particle.io/collections/cellular/pro... When constructing the meter, use the same pin connections described above for the WiFi version of the meter in Step 3.
• The cellular IoT device uses more power than the WiFi version, and therefore two battery sources are recommended: a 3.7V Li-Po battery, which comes with the IoT device, and a battery pack with 4 AA batteries. The 3.7V LiPo battery attaches directly to the IoT device with the connectors provided. The AA battery pack is attached to the IoT device the same way as described above for the WiFi version of the meter in Step 3. Field testing has shown that the cellular version of the meter will operate for approximately 9 months using the battery setup described above. An alternative to using both the AA battery pack and 2000 mAh 3.7 V Li-Po battery is to use one 3.7V Li-Po battery with a higher capacity (e.g. 4000 or 5000 mAh).
• An external antenna must be attached to the meter, such as: https://www.amazon.ca/gp/product/B07PZFV9NK/ref=p... Ensure it is rated for the frequency used by the cellular service provider where the water meter will be used. The antenna that comes with the cellular IoT device is not suitable for outdoor use. The external antenna can be connected with a long (3 m) cable that allows the antenna to be attached to the outside of the well at the wellhead (Fig. 10). It is recommended that the antenna cable be inserted through the bottom of the case and thoroughly sealed with silicon to prevent moisture entry (Fig. 11). A good-quality, waterproof, outdoor coaxial extension cable is recommended.
• The cellular IoT device runs on a different code than the WiFi version of the meter. The code for the cellular version of the meter is provided in the attached file (Code2_Cellular_Version_ECMeter.txt).