How to measure outside Pool Temperature? Battery driven and Wireless

Tags: #<Tag:0x00007f616e4eed60> #<Tag:0x00007f616e4eec20>

Hi all,

I am looking for a Pool Temperature sollution. It has to be battery driven and wireless. I’d prefer Z-Wave.
I did not find any yet. I tried Fibaro FGBS222 with a DS18B20 Temp Sensore in a waterproof enclosure. That works, but only fo a day or so. The FGBS222 just does not work on battery power. I heard about the Fibaro Door Sensor 101 which had the possibility to attach an external Temp Sensor. But It´s no longer sold…

Any ideas?

Help is greatly apreciated.

Cheers
Reinhard

Wemos Lolin pro Esp32-DS18B20-Movil Battery-Mqtt

:wink:

Ok, I understand the idea, but can you elaborate a little bit?

1° EMQx - MQTT Broker --> https://docs.emqx.io/tutorial/latest/en/quick_start/run_first.html
2° MQTT-WIFI-DALLAS DS18B20 .ino :slight_smile: (adapt the wifi libraries from 8266 to esp32)

/********************************************
            Smart Thermostat - Wrele

  NODEMCU ESP8266-01s + Rele Shield
  _____________________________________
  OTA feature
  Hostname: "Wrele"
  GPIO 0     PIN  DS18B20 // Bibliotecas OneWire y Dallastemperature
  GPIO 2     PIN RELE
  Webserver: "debug & State"
  OTA Port: 8622
  
  MQTT Client! PubSub von //https://github.com/knolleary/pubsubclient  / https://pubsubclient.knolleary.net/api.html#connect1
  
  Remote debug on TELNET: Wrele
  ______________________________________

  ---Pablo R. Pescador---

*********************************************/
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <PubSubClient.h> 
#include <OneWire.h>
#include <DallasTemperature.h>



String ssid = "wifi_router";
String password  = "pass_router";

int period=35000;
int period1=30000;
unsigned long time_now=0;
unsigned long time_now1=0;

long lastReconnectAttempt = 0;

//--4 x Dallassensor
const int pinDatosDQ = D3;
// Instancia a las clases OneWire y DallasTemperature
OneWire oneWireObjeto(pinDatosDQ);
DallasTemperature sensorDS18B20(&oneWireObjeto);
// Variables con las direcciones únicas de los 4 sensores DS18B20
DeviceAddress sensorVL = {0x28, 0xAA, 0xA9, 0xC2, 0x1D, 0x13, 0x02, 0x2C};
DeviceAddress sensorKW = {0x28, 0x13, 0xF4, 0xB5, 0x32, 0x14, 0x01, 0xAD};
DeviceAddress sensorWW = {0x28, 0x4A, 0xC1, 0xAD, 0x32, 0x14, 0x01, 0x67};
DeviceAddress sensorRL = {0x28, 0xAA, 0xD1, 0x81, 0x3B, 0x14, 0x01, 0xDE};

//---------MQTT Client


const char* mqtt_server = "ip_broker";
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
String myIPrele;

byte willQoS = 3;
const char* willTopic = "ds1820b20";
const char* willMessage = "0";
boolean willRetain = true;
String received;
unsigned long lastmsg;
//end---------MQTT Client

//---------PIN RELE 
const int Wrele = D4;
char buffer[20]={0};
//-------------------------------------------------------------------SETUP
void setup() {
  Serial.begin(115200);
  pinMode (Wrele, OUTPUT);
  Serial.println("Booting");
  delay(100);
  digitalWrite(Wrele, LOW);
  //----------------------------WIFI    
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  WiFi.hostname("cli-rele");
  Serial.println("Ready");
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
  Serial.println("Connection Failed! Rebooting...");
  delay(5000);
  ESP.restart();
  }
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  sprintf(buffer, WiFi.localIP().toString().c_str());  
  Serial.println(myIPrele);
  
  

//------------------------- MQTT Client
  client.setServer(mqtt_server, 1893);
  client.setCallback(callback);
  client.connect("Cli-rele", "user_mqq", "pass_mqtt");
  client.subscribe("broker/kessel/rele/estado");
  client.subscribe("mcureset");
  if(client.connected()){
  client.publish("broker/kessel/estado", "1",true);
  client.publish("client", "cli-rele");
  }
//end------------------------- MQTT Client

//----------------------------OTA config
  ArduinoOTA.setPort(8266);
  ArduinoOTA.setHostname("Cli-rele");
  // No authentication by default
  // ArduinoOTA.setPassword("admin");
  // Password can be set with it's md5 value as well
  // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
  // ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
  ArduinoOTA.onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH) {
      type = "sketch";
    } else { // U_SPIFFS
      type = "filesystem";
    }
    // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
    Serial.println("Start updating " + type);
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) {
      Serial.println("Auth Failed");
    } else if (error == OTA_BEGIN_ERROR) {
      Serial.println("Begin Failed");
    } else if (error == OTA_CONNECT_ERROR) {
      Serial.println("Connect Failed");
    } else if (error == OTA_RECEIVE_ERROR) {
      Serial.println("Receive Failed");
    } else if (error == OTA_END_ERROR) {
      Serial.println("End Failed");
    }
  });
  ArduinoOTA.begin();
 //End----------------------------OTA config
//----------Sensores Dallas  
  sensorDS18B20.begin();
  //Serial.println("Buscando dispositivos...");
  //Serial.println("Encontrados: ");
  //Serial.print(sensorDS18B20.getDeviceCount());
  //Serial.println(" sensores");
  
  
}
//-------------------------------------------------------------------end SETUP

//-------------------------------------------------------------------MQTT CLient Callback
void callback(char* topic, byte* payload, unsigned int length) {
//  Serial.print("Mensaje MQTT [");
//  Serial.print(topic);
//  Serial.print("] ");
  for (int i = 0; i < length; i++) {
//    Serial.print((char)payload[i]);
  }
//  Serial.println();

  // Switch on the LED if an 1 was received as first character
  if ((char)payload[0] == '0') {
    digitalWrite(Wrele, LOW); 
  }
  if ((char)payload[0] == '1') {
    digitalWrite(Wrele, HIGH);
   // lastmsg = millis(); //es para apagar la caldera en caso de emergencia de no conexion.
  }
  if ((char)payload[0] == '2') {
   valoresDS18B20();    
  }
  if ((char)payload[0] == '9') {
   client.publish("Rele", "RESET"); 
   ESP.restart();    
  }

}
boolean reconnect() {
  if (client.connect("Cli-rele", "mqtt_user", "mqtt_pass")) {
    // Once connected, publish an announcement...
    client.publish("client", "Cli-rele");
    client.publish("broker/kessel/estado", "1",true);
    // ... and resubscribe
    client.subscribe("broker/kessel/rele/estado");
    client.subscribe("mcureset");
    }
  return client.connected();
  }
//-------------------------------------------------------------------MQTT CLient Reconnect



void loop() {
  delay(100);
  ArduinoOTA.handle();
 //-------------------------MQTT Handle 
 
 if (!client.connected()) {
    digitalWrite(Wrele, LOW);
    Serial.println(" :( ");
    long now = millis();
    if (now - lastReconnectAttempt > 5000) {
      lastReconnectAttempt = now;
      
        Serial.println("cada 5 seg");
      // Attempt to reconnect
      if (reconnect()) {
        Serial.println("Reconectando");
        lastReconnectAttempt = 0;
      }
    }
  } else {
    // Client connected
    client.loop();
    
  }
//  if(millis() > time_now + period)
//    {
//      time_now = millis();
//     if (client.connected()){
//     client.publish("broker/kessel/estado", "1");
//     }
//   }
   if(millis() > time_now1 + period1)
    {
     time_now1 = millis();
      valoresDS18B20();
     }
   
//  if(digitalRead(Wrele)==HIGH){
//   if(millis() > lastmsg + 15000){
//    Serial.println("Apage caldera");
//    digitalWrite(Wrele, LOW);
//   }
//  }

}

void valoresDS18B20(){
    // Mandamos comandos para toma de temperatura a los sensores
//  Serial.println("Mandando TEmperaturas de sensores");
  sensorDS18B20.requestTemperatures();
  float tempVL = sensorDS18B20.getTempC(sensorVL);
  float tempRL = sensorDS18B20.getTempC(sensorRL);
  float tempWW = sensorDS18B20.getTempC(sensorWW);
  float tempKW = sensorDS18B20.getTempC(sensorKW);
  // Leemos y mostramos los datos de los sensores DS18B20 por dirección única

  client.publish("broker/kessel/dallas/VL",String(tempVL).c_str());
  client.publish("broker/kessel/dallas/RL",String(tempRL).c_str());
  client.publish("broker/kessel/dallas/WW",String(tempWW).c_str());
  client.publish("broker/kessel/dallas/KW",String(tempKW).c_str());
    
//  Serial.print("Temperatura sensor VL: ");
//  Serial.print(sensorDS18B20.getTempC(sensorVL));
//  Serial.println(" C");
//  Serial.print("Temperatura sensor RL: ");
//  Serial.print(sensorDS18B20.getTempC(sensorRL));
//  Serial.println(" C");
//  Serial.print("Temperatura sensor WW: ");
//  Serial.print(sensorDS18B20.getTempC(sensorWW));
//  Serial.println(" C");
//  Serial.print("Temperatura sensor KW: ");
//  Serial.print(sensorDS18B20.getTempC(sensorKW));
//  Serial.println(" C");
//  delay(1000);

}

3° esp32 -->link

4°Lern HOW DeepSleep ESP32 -->link
5° Baterry–>link

6° Cafe!!! :wink:
7° Mqtt binding–>link, Bridge, and generic thing config

Can you add a solar power system?

Hi,
I use the Fibaro Door Sensor 101 (bought a used one on ebay) with an external Temp Sensor.
But I’m also looking for a better solution:
Problems:

  • battery lasts only 4 weeks with temperature measurement each 2 hours
  • temperature report sometimes does not happen a few days, maybe due to the long wireless distance.

I use a Fibaro Smart Implant to control the heating temperatures also with external sensors, but this one needs power supply, but I’d also prefer a battery solution…

Can you add a solar power system?

Well, I think technically that would be possible. But, I had to attach it to the pool side somewhere. And with the kids running around… It just does not sound like a good solution.

Thanks for your review of the 101. I thought about buying one on ebay too, but did not get into it yet. Think I will stay away from it now.

I presume from your OP you’re not interested in DIY, but just in case: you can DIY this quite cheaply using the MySensors framework. There’s examples of temperature sensors running for a couple of years on 2x AA batteries…

It’s definitely not as easy as plug and play though!

@pablopescador
Thank you for the insight. Sounds like the best solution so far. The only thing I am not familiar with is the esp32. Does it have to be the Wemo esp32. I found the Firebeetle esp32. Which is more expensive, but available in a couple of days from Germany, instead of 2 Month from China. Should work too is my understanding.
Anyway, I’ll try this setup and report later.

take a look this–>solar solution for Battery combination link

These are my thoughts on the subject:

  • use rtl_433, works very well for me
  • i query some temperature sensors and 433 MHz buttons
  • I have not tested the 433 MHz pool thermometer yet
  • But all in all it is a very cheap solution.

rtl_433 protocol …

“[56] TFA pool temperature sensor” or
“[109] WT0124 Pool Thermometer”

rtl_433
Integration in OH
TFA Pool Thermometer
–> One of them should work…
or
Pool Thermometer

EDIT:

“[56] TFA pool temperature sensor” … this protocol is probably an older model than the one mentioned on the homepage, see here.

According to this link this TFA-Dostmann Pool Thermomenter should be recognized as WT0124/WT0122 -> protocol [109]

1 Like

I built a wireless solution using Wemos D1 mini and a 50mm DS18B20 temperature probe. I then cut the plumbing after the return pump and inserted a T socket with thread, then installed the probe (Better than wires dangling in the pool) and connected it to the Wemos. It sends temp readings using MQTT. I can share the code if you like.

If you have a pool, you should have a pump somewhere, right? So electricity shouldn’t be a problem…

just stumbled upon that last week:
Operating ESP8266 425 days on two AA batteries to transmit sensor value

see modifications in comments to get power consumption down even further

Hope that helps…

If a little tinkering is not a problem, I would definitely use an ESP8266 (ESP-12F or ESP-07 with external antenna).

The ESP-32 are much more expensive, you don’t need the hardware, and there is less support from the community.

I would probably take a Wemos D1 Mini for testing and then switch to a naked ESP-12F to save power. The D1 Mini already has voltage converters and so on on the board, which don’t exactly save power.

With it I just realized a “smart” doorbell and after 3 months the two AA batteries are still full.

I can support you if you want to go that way.

EDIT
I never used it myself, but espeasy should be easy to use and supports the DS18B20 sensors and Mosquitto:

https://www.letscontrolit.com/wiki/index.php/ESPEasy

1 Like

If you don’t fancy the MySensors route from my earlier post, then I have to agree with @sdda and recommend an esp8266 over the more capable esp32. I’d probably just flash it with Tasmota, which has all the MQTT and sensor stuff built in too, but that’s probably because I’ve never used ESPEasy…!

I agree, Tasmota is a really good piece of software but I don’t know how it’s handling deep sleep. Which is extremely important when running an ESP chip on batteries.

1 Like

I’ll admit that I’ve never needed to use it, but have noticed it mentioned in the docs before: https://tasmota.github.io/docs/DeepSleep/

I thank you all for your help and suggestions.
I have my sensor working now. I ended up with a ESP32 Firebeetle with a 2000mAh LiPo Battery. I just finished my coding and put the sensor to work. So I dont know how long the battery will last. We’ll see.
I am using the deep sleep mode and sending the sensor value every 10 Minutes.

1 Like