Crocodile Solar Pool Sensor

8,935

71

39

This instructable shows how to build a rather special pool sensor measuring the pool temperature and transmitting it via WiFi to Blynk App and to a MQTT broker. I call it the "Crocodile Solar Pool Sensor".

It uses the Arduino programming environment and an ESP8266 board (Wemos D1 mini pro).

What's so special about this project?

  • The look is just great
  • Fully independent from power sources (solar panel feeds the LiPo battery)
  • Low power ESP8266 WiFi connected sensor
  • Rather high precision temperature sensor
  • Data transmission of temp and voltage to Blynk APP for your mobile phone
  • Sends also a "last updated" timestamp to Blynk APP
  • Data transmission of temp and voltage to a MQTT broker
  • Celsius and Fahrenheit switchable
  • Can be reprogrammed

Your skill level: intermediate to experienced

Supplies:


For this build you will need to know how work with:

  • Arduino IDE (programming environment)
  • a soldering iron
  • a drill
  • a sharp knife
  • epoxy glue
  • hot glue
  • industrial spray foam
  • spray color

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Components Needed

These things are needed to build this nice pool sensor:

additionally:

  • Insolating foam sealant @ DIY market or here: (Amazon)
  • Waterproof paint @ DIY market or here: (Amazon)
  • Filler primer spray @ DIY market or here: (Amazon)
  • Liquid epoxy for a waterproof coating @ DIY market
  • Hot glue

You might need to use a 3D printer to print a waterproof cover for the USB port.

Step 2: Electronics

I thought it is easiest to start with some of these DIY universal prototype PCBs and I found that a 5x7cm is just perfect for this purpose.


Building steps:

  1. Prepare the D1 mini pro for using an external antenna:
    1. Unsolder 0 Ohm resistor next to ceramic antenna
    2. Turn 0 Ohm resistor downwards and solder the connection to external antenna (good explanation found here - Step5)
  2. Place the parts and decide for the layout on the prototype PCB before you start soldering
  3. Solder the the pins to the D1 mini pro
  4. Solder the standoff pins to the prototype board
  5. Solder the pins for the charger board to the prototype PCB
  6. Solder the charger board to the pins
  7. Cut the cable of the temperature sensor to a length of 20 cm
  8. Please see image above for connecting the temperature sensor
  9. Solder the cable to the solar panel
  10. DO NOT YET solder the solar panel cables to the board - these need to be glued first to the crocodile's head
  11. Follow the Fritzing schema above to solder all the remaining connections to the PCB
  12. Once all components are connected and soldered use some hot glue to fix the battery

    Please note: For putting the ESP8266 to sleep it is necessary to connect pin D1 with pin RST. Sometimes the D1 mini pro causes problems with the serial port if port D0 and RST are connected. The one I used (see Aliexpress link above) did not have this problem.
    If you are facing this problem you might need to use a jumper or a switch to deconnect the two pins for uploading new code. But (!) then you have no chance to reprogram once the crocodile head has been sealed. In this case you also do not need to bring the USB port to the outside (e.g. to drill a third hole).

Step 3: Hardware Part 1 (Preparation of the Crocodile Head)

In this step we prepare the backside of the crocodile head to get enough space for the electronics. And we are drilling some holes for the antenna, the solar panel and the USB port.

I planned my project first without the USB port. But then I thought that it would be impossible for me to do some software updates once the crocodile has been sealed again. Therefore I decided to use a short USB cable micro-USB to USB to allow an outside access to the ESP8266 board.

Next steps to do:

  • Use a sharp knife to cut a little more than 7x5 cm (size of your prototype board) off the hard surface
  • Use a spoon to remove the softer foam from the inside
  • Just make sure that you have enough space for your cables and your board
  • Try out if it fits and that there is still some space to cover it later

Now drill two or three holes into the head:

  • for the solar panel
  • for the antenna
  • (optional) for the USB port for enabling later programming


Use 2 component epoxy (5 minutes) to glue and seal these holes again. Use enough epoxy glue! Make sure that it will be waterproof afterwards!

  1. Glue the solar panel cable to the head and properly seal the hole
  2. Glue the solar panel between the eyes
  3. Glue the antenna socket to the head and properly seal the hole
  4. Glue the USB plug and properly seal the hole

To avoid any water causing corrosion to the USB port I 3D-printed a little protective cap.

Step 4: Software

You need to have a running Arduino environment. If not, please check this.

Hardware setup is straight forward (on my Mac):

LOLIN(WEMOS) D1 mini Pro, 80 MHz, Flash, 16M (14M SPIFFS), v2 Lower Memory, Disable, None, Only Sketch, 921600 on /dev/cu.SLAB_USBtoUART

Get the Arduino code here:Arduino code at Github

The code is sending the temperature and the voltage of the battery to Blynk. Just load Blynk app to your mobile phone and create a new project. Blynk will send you an Auth Token for this project. Enter this token into the Settings.h file. The default settings will send

  • the temperature to VIRTUAL PIN 11
  • the voltage to VIRTUAL PIN 12
  • the last updated timestamp to VIRTUAL PIN 13

but it is easy to change these pins in the code. Just play around with all the Blynk widgets using V11, V12 and V13 - it is fun. If you are new to this just read my friend Debasish's instructable - most of this is explained there in Step19.


The software is also prepared to use a MQTT broker.

In the Settings.h there is a global variable called MQTT. This needs to be set to true or false depending if your are using MQTT or not.

In my case I am using an MQTT broker (Orange PI Zero, Mosquitto, Node-Red) and a dashboard where all my sensor data comes together. If you are new to MQTT then let Google help you to set it up.

If you are familiar with MQTT, I am pretty sure that you will understand the code.

Step 5: Hardware Part 2 (Sealing Again)

In this step we need to pack all the electronics (software loaded and tested) and seal the belly of our crocodile again. I personally see two possible solutions:

  1. Using a acrylic glass and glue it with epoxy glue waterproof to the belly. For the temperature sensor cable use a waterproof cable duct (I regret that I did not chose this option - after all I went through I would highly recommend to go this way.)
  2. Using an industrial foam and fill the gaps again, then use waterproof paint to seal. And finish it with filler and paint.

So I decided for option 2. The steps are as follows:

  1. Solder solar panel cable to the board
  2. Connect antenna cable
  3. Connect USB cable to ESP8266 board (AND NOT to the charging board)
  4. Squeeze all cable and the board into the hole
  5. Leave 5-10cm of the temperature sensor cable hanging out
  6. Use the industrial foam to fill all the gaps (Watch out - the foam expands heavily)
  7. Let it dry and cut the foam afterwards with a sharp knife
  8. Now use some waterproof paint (is used to fix roofs) and paint it all over
  9. Let it dry and use the filler paint spray to produce a hard crust (you need to do this over and over)
  10. IMPORTANT EDIT (after some weeks in the water): Apply two or three coatings all over of liquid epoxy to give a really waterproof coating.
  11. Let it dry - FINISHED!

Step 6: Appendix: Additional Displays/Sensors

If you want to go beyond displaying the pool data just on Blynk App, you can also push it to an MQTT broker. This allows you to use several more possibilities to display your pool (or other) data on different devices. One would be Node Red Dashboard on a Raspberry Pi (see picture above) or a LED matrix display. If you are interested in the LED Matrix please find the code here: https://github.com/3KUdelta/MDparola_MQTT_monitor...

By the way, I combined this project with the Solar Weather Station including a Zambretti weather forecast from this project: https://github.com/3KUdelta/Solar_WiFi_Weather_St...

The inspiration of this Solar Weather Station came from my Indian friend Debasish. Please find his instructable here: https://www.instructables.com/id/Solar-Powered-Wi...

Sensors Contest

First Prize in the
Sensors Contest

1 Person Made This Project!

Recommendations

  • Instrument Contest

    Instrument Contest
  • Make it Glow Contest

    Make it Glow Contest
  • STEM Contest

    STEM Contest

39 Discussions

0
None
3KU_Deltasteve-f-dallas

Reply 3 months ago

Shouldn't be a separate library. As I recall correctly it should be included in ESP8266WiFi library. Do you get an error?
Marc

0
None
steve-f-dallas3KU_Delta

Reply 3 months ago

Marc,

Thanks for your addition to the serial monitor. With that addition, I'm sure that I am doing something wrong in Blynk. Should the Blynk widget be a value display or another type?

Thanks again,
Steve

0
None
steve-f-dallas3KU_Delta

Reply 3 months ago

No, Marc, I didn’t get an error about libraries, but I was having some errors with the program. I deleted everything related to Arduino from my computer, added the board and other necessary libraries, and all is now great! Since I reloaded all libraries but didn’t see the wifiupd zip file, That prompted my question. Thanks as always for your stewardship!!

steve

0
None
steve-f-dallas

4 months ago

I wanted the monitor to report temp in Farenheit as well as Celsius. That was easy.
After the line PoolTemp = total / numReadings;
I modified the first line to show degrees Celsius
and added the lines to show the temp converted to Farenheit
Serial.print("Measured pool temperature c: ");
Serial.println(PoolTemp);
Serial.print("Measured pool temperature f: ");
Serial.println(PoolTemp*1.8+32);

9 replies
0
None
3KU_Deltasteve-f-dallas

Reply 4 months ago

Tank you Steve - good solution. You can also add a second variable declaration like "float PoolTempF". Assign it with PoolTempF = PoolTemp*1.8+32; and send it similar to the PoolTemp variable to BLYNK or MQTT.

0
None
3KU_Delta3KU_Delta

Reply 3 months ago

Hi Steve

I tried again and put some more debugging for the serial monitor into the code. It just works as it should. This is what you can do: Download the updated .ino file again --> it contains an output to the serial monitor of the data exactly how it is transferred to Blynk. This gives you at least the correct information what data has been sent to Blynk. If this is ok - check your settings in Blynk. Please see attached Image for correct settings.
Hope this helps. Marc

IMG_3132.PNG
0
None
steve-f-dallassteve-f-dallas

Reply 4 months ago

Hi Marc,

I'm still working on the housing for the pool sensor; so far, I've gone through 3 different chlorinators; as you know, floating chlorinators want to admit water, while I want to keep water out.

On another topic, every time the temperature is taken and sent to blynk, I want to increment an integer variable by 1. In this way, I can see whether the reading is a new one.

I've created a small program that works in incrementing a variable, but, since your code does not use a void(loop), my code does not work with your code.

Here's the short code for incrementing:

int x;
int y = 1;
void setup() {
Serial.begin(115200);
Serial.println();
}

void loop() {
y = x ++;
Serial.print("incrementing y");
Serial.println(y);
delay (500);
}

As always, thanks in advancer for your help.
Steve

0
None
3KU_Deltasteve-f-dallas

Reply 4 months ago

Hi Steve
the loop() does not work because we go to deep sleep in order to save energy. The loop() function will empty the battery within hours. Btw. In your example, you do not need x. The right way would be y = y +1; or just Serial.println(y++);

I see two possible solutions (in preferred order):
1.) Send a timestamp. High level: go online, get actual time via ntp, send timestamp to Blynk, go to sleep
2.) Your idea with increment: Define a file on SPIFF, read variable from file, increment, write variable, go to sleep

I think the timestamp is better because you can immediately see when the last update was made. Since I am using Node-Red for all my incoming data I do this check there. It is not that difficult for me to do 1.) but I need some time because I am pretty busy currently. Keep you posted.

Marc

0
None
3KU_Delta3KU_Delta

Reply 4 months ago

Just updated to Version 1.3 which includes the timestamp solution. You need to add 4 more libraries:
<WiFiUdp.h> // For NTP Signal fetch
<EasyNTPClient.h> // For NTP Signal read https://github.com/aharshac/EasyNTPClient
<TimeLib.h> // For converting NTP time https://github.com/PaulStoffregen/Time
<Timezone.h> // http://github.com/JChristensen/Timezone JUST IGNORE COMPILE WARNING!

Please note that there are some more settings to do in Settings.h.
Enjoy, Marc
0
None
steve-f-dallas3KU_Delta

Reply 4 months ago

Marc,
Thanks again for the update...but if your code allows sleep, let me know.

I know that pins rst and d0 are connected because using your version 1.2 works great.

I think I've copied your main code as well as your settings.h and my serial print only shows one set of readings and the sleeps forever.

As always, thanks in advance,
Steve

0
None
3KU_Deltasteve-f-dallas

Reply 4 months ago

Hi Steve
I am not sure if I understand your question. V1.2 and V1.3 use the identical code to put everything to deep sleep and wakes up again within the time in minutes you have set in Settings.h. This only works if RST and D0 are connected. With these settings it should work and the board wakes up after the given time. Try to do a manual reset (button) to test a restart and observe if everything is ok. If this is the case double check the connection between RST and D0.
Hope that solves the problem. Marc

0
None
steve-f-dallassteve-f-dallas

Reply 3 months ago

Marc,
Another anomaly. Time is fine in serial monitor but is intermittently not present, or inaccurate in blynk. I've copied code directly from GitHub several times. The only difference in my code is the addition of TempF (which we discussed a while ago). I've tried changing the virtual port on Blynk, the sleep time, and time zones and it's still flaky. I'd appreciate any suggestions.

Thanks again,
Steve

0
None
whatsupskip

3 months ago

One big problem with project is the sensor. These DS18b20, while waterproof, are not salt and chlorine waterproof for extended periods of time. I used one for this application and the water proofing failed and then caused electrolysis in the main circuit. I am going to try again with nail polish over the joins and an extra heat shrink tubing. I doubt this will work for a long time though (more than one year). I suspect the best option is to place the sensor in a small plastic tube and fill it with water proof epoxy.

1 reply
0
None
3KU_Deltawhatsupskip

Reply 3 months ago

Hi I agree. I am using oxygen instead of chlorine and also ran into this problem. This is why I changed the description to use liquid epoxy. I completely covered the whole croc with epoxy. This is working now for weeks.

0
None
3KU_Delta

4 months ago

Strange, the instructables platform rotated some to the pics today. Hmm?

0
None
3KU_Delta

4 months ago

Hey guys - just got notified that I won a FIRST PRIZE for this instructable.

Thank you for voting! I am really happy about this.

Marc

1 reply
0
None
steve-f-dallas3KU_Delta

Reply 4 months ago

CONGRATULATIONS!! THANKS FOR ALL YOUR HELP AND SUGGESTIONS!!
I learned a great deal as I followed your instructable.

Steve

0
None
KushagraK7

4 months ago

This can also serve the purpose of keeping kids away from the pool.