Skip to content

jaisor/SmartPoolThermometer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart Pool Thermometer

Dash PoolPhoto

Requirements

  • Floating water-tight pool sensor
  • Temperature and other telemetry (internal battery voltage) readings submitted over Wifi via MQTT at reasonable intervals (~5min)
  • Low power consumption, battery powered with solar recharge during the day
  • Device initial configuration via self-hosted AP (ESP8266ST_XXXXX / password123) / IP (192.168.4.1)
  • Device resets to (factory) defaults by 3 power-cycles within 2 seconds of boot
  • Device configurable over MQTT and capable of OTA firmware updates
  • Data visualization - MQTT - Prometheus - Grafana dashboard

Notes

Code is compatible with both ESP8266 and ESP32 boards, but ESP8266 draws significantly less power (4mA) during deep sleep

Sensor

ESP8266 / ESP32 Development

USB driver for Windows required: Silicon Labs CP210X

Recommended: VSCode + PlatformIO

Bill of materials (BOM)

Schematic

Schematic Board

Enclosure

Case

All parts print without support in the default orientation.

  • Box - White PETG or something UV and heat resistant. 4 walls and top/bottom layers. 10-30% infill should be enough.
  • Lid - White PETG or something UV and heat resistant. 100% Infill
  • Gasket - TPU or something flesible to act as a gasket. 100% Infill
  • AnchorLoop - TPU, optional, can be used to tie the thermometer in the sunny side of the pool if needed.

Build & Assembly

First - drop a brass knurled insert in each of the box bolt holes. The inserts can be driven into the plastic easily with a soldering iron. Make sure they are fairly flush with the surface. Do not lower too much as to compromise the outer wall. Close the threads with throw-away set of bolts during the next phase of waterproofing.

Waterproofing

Below was my process for the several prototypes I made and the final version. It might be overkill, but I have not experienced a single water leak after weeks in the pool.

  1. Coat the box with ... epoxy like coating. Heavier on the bottom and sides of the box. Very light on the top and the lid as to not compromise dimensional fit. Wipe any excess around the top and lid if concerned, when this stuff hardens it is very difficult to correct (sanding and headaches). Mask off the inside of the box where the board and battery will go.
  2. Insert the thermometer sensor in the box and mask it off with tape about 10mm away from the box. Glue without any gaps and apply some silicone on the top side when the glue is dry. Wait for the silicone to dry/cure.
  3. Glue the solar panes, ensure no gaps on the back side. Mask off with tape the effecive area of the solar panel.
  4. Spray (rubber coating), thicker on the bottom and around the unmasked part of the sensor, thinner on top and on the lid to ensure the parts fit snuggly but still fit.

Circuit board layout

  • Ensure the output of the TP4056 board goingto the ESP8266 is 5v with the little adjuster provided

Assembly

Battery and case go on the bottom. The temp sensor in the designate hole pushed all the way down and sealed with appropriate waterproof sealer / adhesive. The solar panels should be glued and then water proof sealed too. The linked prototype board fits inside well and can be screwed with some 1mm screws or glued or taped down.

Data visualization

Useful articles and guides:

The following instructions are better suited for a "local" install - desktop, raspberry pi, server on LAN. Deployments expected to communicate over public internet should use appropriate encryption and authentication configuration. Large-scale deployments might also want to leverage a docker-compose, Terraform, etc.

MQTT broker

docker run -dit \
    --name=mqtt-mac \
    --restart=unless-stopped \
    -p 1883:1883 \
    -v "$APPROPRIATE_VAR_PATH/mosquitto:/mosquitto" \
    eclipse-mosquitto:latest

MQTT JSON exporter

Subscribes to a topic, parses JSON received from that topic and populates Prometheus with the compatible JSON values. https://github.com/tg44/mqtt-prometheus-message-exporter

docker run -dit --restart unless-stopped -p 9324:9000 --name mqtt_json \
    -v "$APPROPRIATE_VAR_PATH/mqtt_json:/data" \
    -e CONF_PATH=/data/exporter.conf \
    ghcr.io/tg44/mqtt-prometheus-message-exporter:latest

MQTT REST API for Alexa

docker run -dit --restart unless-stopped -p 3443:3443 \
  -e MQTT_SERVER="$MQTT_SERVER" \
  -e MQTT_TOPIC="$MQTT_TOPIC" \
  -e HTTPS_PRIVATE_KEY_PATH="$PATH_TO_KEY" \
  -e HTTPS_CERTIFICATE_PATH="$PATH_TO_CERT" \
  -e API_KEY="$API_KEY" \
  jaisor/mqtt-rest-api:latest

Prometehus

prometheus/config.yml

scrape_configs:

# Prometehus itself
  - job_name: 'prometheus'
    scrape_interval: 30s
    static_configs:
      - targets: ['localhost:9090']

# MQTT exporter
  - job_name: 'mqtt'
    scrape_interval: 30s
    static_configs:
    - targets: ['<HOSTNAME>.local:9344']
docker run -dit --restart unless-stopped -p 9090:9090 \
    --name prometheus-mac \
    -v "$APPROPRIATE_VAR_PATH/prometheus:/data" \
    prom/prometheus:latest \
    --config.file="/data/config.yml" \
    --storage.tsdb.path="/data/prometheus"

Grafana

docker run -dit --restart unless-stopped -p "3000:3000" --name grafana-mac grafana/grafana:latest

Dashboard

Dash