This project is a companion to my other Home Automation projects Smart Data- Logging Geyser Controller and Multi-purpose-Room-Lighting and Appliance Controller .
It is a pool side mounted monitor that measures the pool water temperature, ambient air temperature and barometric pressure. It then displays the pool water temperature on a local LED bargraph and transmits via WiFi/MQTT to a home system – in my case a software upgraded MQTT compatible version of the Lighting Controller. although it is easy to integrate it into any MQTT compatible Home system.
This Instructable focusses on the Pool Monitor design and construction, the upgrade of the Controller (new firmware and addition of an OLED display) will be included in the original controller shortly.
Key features include:
- The absence of poolside mains electricity determines a 18650 battery power supply with an integrated 1W solar polar panel to maintain the battery charge, battery life is further optimised by the use of the ESP8266 “Deep Sleep” mode. In my system, the unit was able to run over our “active swimming pool season” (November through to April) without manual intervention of manual top up charge.
- An optional local built in 8 LED bargraph displaying the pool temperature in 1 degree intervals.
- MQTT data transmission via local WiFi connection to any compatible host system.
- All programming is achieved over WiFi using the Monitor as an Access Point and internal Web Server configuration pages with all programmable parameters being stored in internal EEPROM.
- Time intervals between wake up and transmissions. 1 to 60 minute intervals.
- Configurable MQTT topic/message formats
- Individual message topics (E.g PoolTemp, AirTemp, BaroPress)
- Single compact topic (E.g. Pool Temp + Air Temp + Barometric pressure)
- Compatible with OLED display mounted on Multi-purpose-Room-Lighting and Appliance Controller (see title figure for example)
- WiFi network SSID and password
- Access Point SSID and password
- LED bargraph control
- Programable minimum temperature range (15 to 25’C)
- Programmable permanently ON, permanently OFF, Only on during daylight hours
Although I 3D printed my own enclosure / mounting arrangement and used a PCB board from a previous project, you can literally use what suits your personal preferences as nothing is critical or “cast in stone”. The last section of this Instructable contains Gerber and STL Files for the PCB boards and ABS housing that I designed specifically for this project
Step 1: Block Diagram and Discussion About the Choice of Components
The block diagram above highlights the main hardware modules of the Pool Monitor.
The ESP8266 used can be any of the ESP03/07/12 basic modules through to the more perfboard friendly NodeMCU and WEMOS modules.
I used the ESP-12, If your pool is some distance from your WiFi router you may prefer the ESP-07 with an external antenna. The NodeMCU/Wemos modules are very board friendly but will result in a slight increased power consumption due to their extra onboard voltage regulator and LEDS – this will affect the ability of the solar panel to daily keep the battery in charge and you may require a periodic manual charge using the USB port on the charger module.
Temperature sensors – Fig. 2
I have used the easily available and low cost metal tube + cable versions of the DS18B20 temperature sensors that come with around 1 metre of connecting cable as they are already robust and weatherproof. One using the full length of the cable for the pool water measurement and another with a shortened cable for the ambient air temperature.
Air ambient sensor
I have selected the excellent BME280 module to measure the ambient air humidity and barometric pressure. You may be wondering why I did not used the air temperature measurement function of this module.
The reason is simple – if, as I did in the original prototype use this function, you end up measuring the static air temperature INSIDE the housing which tends to read high due to internal self heating of the enclosure air space by the outside sun (it reads perfectly at night!). It was quickly realised that the air temperature sensor needed to be mounted outside of the enclosure but in the shade away from the direct sun light so I switched to a second DS18B20 and provided a small mounting point underneath the enclosure. The BME280 temp sensor although is still used as a diagnostic measurement for the in-enclosure temperature and can be monitored on the configuration server main page.
LED bargraph – Fig. 1
The eight local high intensity LED outputs are driven by a PCF8574 IO expander chip which in turns drives each LED by a PNP 2N3906 transistor. The PCF8574 will indicate just one LED at a time (to reduce the power consumption) depending on the measured pool water temperature and will stay active even when the ESP8266 is in its sleep mode. Thus, if enabled, the LED bargraph will be active all of the time.
- If the measured temperature is less than the minimum temperature assigned to the bargraph, then BOTH LED 1 and 2 will illuminate.
- If the measured temperature is greater than the minimum temperature assigned to the bargraph+8, then BOTH LED 7 and 8 will illuminate.
- If the light level as measured from output of the solar panel is lower than the threshold programmed in the configuration set up, the LED outputs will be disabled to save battery power, alternatively the bargraph can be permanently disabled (threshold set to 0) or enabled (threshold set to 100).
- If your build does not require the bargraph simply omit the PCF8574, LED’s, transistors and associated resistors
Solar panel, battery and battery charging board
The basic power supply is simply a 2000mAH (or greater) 18650 LIPO battery fed through an 1N4001 diode to reduce the battery voltage (max charged battery = 4.1V and max ESP8266 voltage = 3.6V).
Lower capacity batteries will work but I have no feeling if the daily charging by the solar panel will be adequate.
Beware the higher capacity labeled batteries (E.g. 6800 mAH) – many on the market are fakes. They will work but at what capacity and reliability is anyone’s guess.
The 1W 5V solar panel is connected to the inputs of a TP4056 LIPO charger board and the output of the latter to the battery thus the battery will be charged when the light level is high enough to produce a usable charging voltage and also the battery can be manually charged via the USB connector on the TP4056 board.
If you intend to use the 3D printed housing design then you must use the 110mm x 80mm sized solar panel. There are other sizes available so just take care when purchasing as this may be critical when selecting your type/size of housing.
Also a word of caution re temperatures. It can be difficult to establish the true max temperature limit of these cheap panels as it is often not stated – I found 65’C max specified on one device but nothing on the majority of onsite suppliers. Now consider that the panel by design is a) black and b) going to be out in the bright sunlight all day every day – you may find it better to allow a little shade over the panel if it gets too hot. My unit has not suffered any failure (installed early 2019) but its reliability will surely depend on your local climate and probably mounting place.
Push buttons – Fig. 3
You might think that a push button is well “just a push button” but when it is on an enclosure that is outside in the sun and rain 24/7 then you need to take care of its specification. Electrically it is a simple component but the sealing integrity of your housing hinges on their mechanical quality. I used what is very popular waterproof single pole 12mm push button available from many suppliers – this has proved itself to be a very robust switch..
- Button 1 is used as the reset button – used to manually force the monitor to make a measurement and transmit the result
- Button 2 when pressed immediately afterpressing and releasing button 1 will instruct the monitor to start up its Access Point (AP) using the SSID and password that you have previously programmed it with. If fitted, each alternative LED on the bargraph lights up briefly to indicate that the AP is starting up.
- Both buttons are also used in the initial build procedure to upload the firmware to the processor flash memory.
The 3 D printed housing is designed for these 12mm switches as listed in the bill of materials and as such are mounted on the side of the housing. If you are using your own housing I would recommend you fit them under the housing to shield them from weather exposure.
Toggle Button – Fig. 2
This is used to completely turn the monitor off when it is not being used and in storage. Note that the battery and solar panel remain connected to each other (but not the electronics) and so the battery will still receive charge if the panel is exposed to external light.
Enclosure – Fig. 3
This remains the last but very important component as this is the main component that provides protection for all of the other parts. The solar panel, push buttons, toggle switch, LED’s and temperature sensors all require drilling or cutting holes in the housing so water proofing is severely jeopardised if the sealing after fitting the items is not taken care of. I glued the solar panel to the cover then sealed inside with silicone sealing. The LED board was potted inside to ensure that all of the LED points were sealed on the inside. You get the picture – prevent any potential ingress points. Since I used a 3D printed ABS model, I sprayed the inside of the housing including the main PCB with PCB sealing spray (you can also just used paint) just as a precaution! Figure 1 shows the enclosure mounted by the pool side. The included STL files also include a simple mounting assembly that allows the enclosure to be assembled to the weir top cover. It can be mounted anywhere that suits you subject to the length of the water temperature sensor cable, exposure to sunlight and the viewability of the LED bargraph if fitted.
Step 2: Bill of Materials
I have included a “potential” bill of materials based on my own choice of components As previously stated, you do actually have a lot of flexibility when it comes to almost all of the build items. I have cut and pasted some items off the Amazon online shopping site purely as an illustration – not as a recommendation of supply. The 18650 battery can have direct solderable tabs for the wires or you can buy a “standard” type and battery holder (as I did) for ease of assembly
You will also need glue (2 part epoxy recommended), 4 x M4 nuts and bolt.
Depending on your location, you will have potentially more convenient and/or cheaper suppliers. For a fact, if you are not in a rush for the components, AliExpress promises significant reductions on some if not all of the major items.
Step 3: Electronic Build & Firmware Upload
The schematic reveals a relatively simple “standard ESP8266” with no “surprises” comprising of just the microcontroller and a collection of input devices (2 x DS18B20 temperature sensor, 1 x BME280 environmental sensor, 1 x PCF8574 IO expander, 2 x push buttons and a battery/charge/solar panel combination.
ESP8266 Pin assignments
- GPIO0 – Start AP Button
- GPIO2 – Not used
- GPIO4 – I2C – SCL
- GPIO5 – I2C – SDA
- GPIO12 – DS18B20 Data
- GPIO13 – Test – Not used
- GPIO14 – Not used
- GPIO16 – Deep Sleep wakeup
- ADC – Solar Panel voltage
PCF8574 pin assignments
- P0 – LED bargraph 1 – Minimum Temperature
- P1 – LED bargraph 2 – Minimum Temperature + 1’C
- P2 – LED bargraph 3 – Minimum Temperature + 2’C
- P3 – LED bargraph 4 – Minimum Temperature + 3’C
- P4 – LED bargraph 5 – Minimum Temperature + 4’C
- P5 – LED bargraph 6 – Minimum Temperature + 5’C
- P6 – LED bargraph 7 – Minimum Temperature + 6’C
- P7 – LED bargraph 8 – Minimum Temperature + 7’C
A copy of the firmware source code is included in the downloads section. The code has been written for the Arduino IDE version 1.8.13 with the following additions ….
- ESP8266 Board Manager (version 2.4.2)
- OneWire library
- Dallas Temperature library
- EEPROM library
- Adafruit BMP085 library
- PubSubClient library
- Wire library
Ensure that you select the correct baud rate on the Serial monitor (115200), and the correct board dependent on what version of the ESP8266 chip you are using).
If you need further instructions how to set up the Arduino IDE then refer to my two previous instructables, both contain extensive set up instructions and also there is a multitude of online r sources available. If all else fails, post me a message.
I have included in the build a connector for the serial port lines (TxD, RxD & 0V) for connection to your computer using a standard FTDI USB to TTL convertor and the two push buttons provide you with the ability to power the ESP8266 in flash programming mode. (Apply power with BOTH the Reset and Start AP buttons pressed, release the Reset button whilst still holding the Start AP button, then release the Start AP button)
- The push button connections, power supply, DS18B20 Temperature sensors can be brought out to standard 0.1″ header pins for easy IO connections
- The 100 uF electrolytic capacitor (C4) and 100 nF ceramic capacitor (C6) should be mounted as close as possible to the power supply pins of the ESP8266.
- The 100nF ceramic capacitor (C5) should be mounted as close as possible to the power pins of the PCF8574
- Figure 10 illustrates the total wiring schematic – You can build all of the components on one board or split them into 2 boards with the PCF8574, 8 x 2N3906 transistors (Q1 to Q8), 16 x resistors (R3 to 14, R19 to 22), C5 on one “LED bargraph board) and the remainder on the “Controller board” (This is what I did)
Step 4: Using the Provided 3D Printed Enclosure
The choice of housing is flexible depending on your preferences and installation requirements. I 3D printed an ABS housing to suit my own installation and include it to either reproduce or use as an “inspiration” for your own construction. The STL files from the Download section can be printed at 0.2 mm resolution. If you do not own a 3D printer nor have a friend with one, there are many commercial 3D printing companies out there now who should be able to provide an affordable service for you.
The individual printed items are:
- A. Enclosure base
- B. Enclosure cover
- C. Knuckle joint
- D. Enclosure knuckle mount adaptor
- E. Air sensor mount
- F. Enclose sensor cable guide
- G. 2 x rod (short and extended length – allows length of overall mount assembly to be varied)
- H. Weir cover top adaptor
- J. Weir cover bottom adaptor
Also needed are 4 x M4 threaded bolts and nuts
- Where items are glued, I recommend a two part epoxy resin or any suitable weatherproof glue.
- Glue the solar panel to the lid B and use silicon sealant in the inside of the cover to prevent any water ingress at the joining faces.
- Part E is glued to the part E at any point for mounting the air sensor. ALL of the air sensor must be below the housing base out of any direct view of sunlight (Ref Fig.5A)
- Part F and D should also be glued to the Enclosure part E base.
- The mounting knuckle assembly (G,C & G) fit together as a push fit and when their through holes are aligned, can be secured using 2 x M4 threaded bolts and washers (do not tighten until complete assembly is mounted and required orientation identified – do not over tighten to prevent cracking the plastic fittings). Cut the bolts to a suitable length if required.
- Mount parts H & J on the modified weir plat cover at a point where there is no risk of physical interference or stress from any pool cover strap etc (ref Fig 5 C,E & F). If the weir plate cover has a curved surface, I suggest that you use silicon sealant or epoxy to further bond part J to the underside of the weir cover.
- Now the enclosure assembly can be mounted onto the weir cover plate using the knuckle assembly (2xG & C). This knuckle assembly is a tight PUSH fit into both the enclosure base and the weir plate cover thus allowing the unit to be easily removed for winter stowage and/or maintenance. Do NOT glue this in place. Ref Fig. 5D
- Figure 4 outlines each part and how they fit together. For the mounting installation, I drilled a hole in my weir top cover to provide a mounting point for the mounting knuckle (This provides a 3 dimensional adjustment possibility for the housing relative to the the mounting mount)
Step 5: Configuration Server (Access Point)
All of the Monitor user settings are stored in EEPROM and can be monitored and changed via the built in web server that can be accessed when the monitor is put into Access Point (AP) mode.
To do this, the user must first press and release the RESET button then immediately after releasing, press and hold the second CONFIGURATION button for 1 to 3 seconds. On releasing the Configuration button, if fitted, each alternative LED on the bargraph will illuminate for a few seconds, meanwhile the AP will start up.
Read more: MQTT Swimming Pool Temperature Monitor