Build your own Wifi operated water thermometer [Homeyduino – English version]

Build your own Wifi operated water thermometer [Homeyduino – English version]

Build your own water- or regular thermometer that you can read out digitally via WiFi and even use as a trigger for your Homey Pro or Homey Bridge.

After a lot of trying and experimenting, we’ve finally managed to make a functioing DIY WiFi Water Thermometer today. This DIY project took way longer to complete than anticipated. I had already started this over two months ago but at the time I ran into some problems, especially with coding. Today, because of the bad weather, I figured it was time to give it another go, and to my surprise it actually worked.

On Amazon they sell all ready functioning water thermometers, but where’s the fun in that?

Via Homey Insights, Homey will hopefully show a nice temperature trend with fluctuations during the year. This way you can easily keep track when the water temperature is high enough for the Koi to breed. Or you can set this temperature as a trigger in Homey, to not forget to cover it against freezing over.

Replicating this project will take you no more than 15 minutes of your time and with a total cost of around $ 10,-.

Below you can read what you need and how to connect it.

Normal thermometer or thermometer with hygrometer

With the code below you can also make a normal thermometer, just follow all the steps as described below, except for throwing it into the water. Rather build a thermometer and humidity sensor (hygrometer) in one?We’ve got you covered!

The WiFi Water Thermometer hangs in the planter and can be read on Homey or telephone.  |  Huisvandaag.nl
Pond WiFi water thermometer that can be read via Homey

The necessities on Amazon or Aliexpress:

If you prefer to buy on Aliexpress, you can use these links:

Also necessary, but only to be configured once, a computer or laptop with installed:

Connect

Follow the diagram below to connect the sensor to your board. The image below shows an Arduino Uno but connecting to an ESP8266 NodeMCU or D1 Mini is almost the same, voltage also works at 3.3V.

Connection diagram DS18B20 sensor on Arduino board |  Huisvandaag.nl
Connection diagram DS18B20 sensor on Arduino board is almost the same on an ESP8266
DS18B20 sensor connected and tested |  Huisvandaag.nl
DS18B20 sensor connected and ready to test

Code 

Below is the code as I compiled it myself from code already available for Arduino and Homeyduino. It works, but since I have little or no experience with coding myself, this can most probably be done more efficiently.If you do have this knowledge and have suggestions, please let me know!  

Uploading is done via Arduino IDE, if you are not familiar with this, read here for an extensive manual. Make sure you have selected the right board in settings in Arduino IDE and that you upload the code at 115200 baud. If your ESP8266 board doesn’t work, you can try flashing it first with the  NodeMcu Flasher.

// Code for Homeyduino made by Smart Home Blog https://huisvanvandaag.nl. 
// Take a look at my site for more Homeyduino en other Smart Home projects.

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <Homey.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS D3 // in case this doesn't work replace D3 with: 0, which is the GPIO pin number

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

 float Celcius=0;
 float Fahrenheit=0;
 
 void wifi() {
  if (WiFi.status() != WL_CONNECTED) {
    WiFi.begin("<SSID>", "<PASSWORD>");
    uint8_t timeout = 30;
    while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
      if (timeout<1) break;
    }
    if (WiFi.status() == WL_CONNECTED) {
      //Print IP address
      Serial.print("Verbonden met WiFi! (");
      Serial.print(WiFi.localIP());
      Serial.println(")");
    }
  }
}

void setup(void){
  Serial.begin(115200); // In case it doesn't work, change baud to 9600
  Homey.begin("SENSOR NAME"); // Fill in sensor name
  Homey.setClass("sensor");
  Homey.addCapability("measure_temperature");
    }

void loop(void)
{ 
  wifi();
  Homey.loop();
 // unsigned long currentMillis = millis();
  sensors.requestTemperatures(); 
  Celcius=sensors.getTempCByIndex(0);
  Fahrenheit=sensors.toFahrenheit(Celcius);
  Serial.print(Celcius);
  Serial.print (" C ");
  Homey.setCapabilityValue("measure_temperature", (int) Celcius); 
  delay(1000);
}

To test

After you have successfully uploaded the code, we will try and test it. Put the sensor in a glass of water and open the Serial Monitor in Arduino IDE, click Tools and then the Serial Monitor or hotkey CTRL+SHIFT+M.

A new screen will then open on which you can read the values ​​from the sensor. If you see values ​​that don’t seem to be correct, such as -126 or something like that, you have to upload the code again.

Here you can read the values ​​of your newly made sensor.  |  Huisvandaag.nl
Here you can read the values ​​of your newly made sensor.

DS18B20 sensor in box by the pond |  Huisvandaag.nl
Now that the sensor has been tested and works, it’s time to confirm the outside.
DS18B20 sensor in closed box |  Huisvandaag.nl
DS18B20 sensor in (water) tight box near pond with the sensor in the water of the planter.

And Voila 

Your home-made WiFi Water Thermometer is now up and running and you should be able to read it from anywhere in the world via the internet or, if desired, even used as a trigger in your Homey flows. As mentioned above, I use it for reading the pond. Let me know what applications can you think of for this handy WiFi thermometer.

The WiFi Water Thermometer hangs in the planter and can be read on Homey or telephone.  |  Huisvandaag.nl
The WiFi Water Thermometer is in the back of the pond and can be read via Homey Pro or via the Homey Bridge.

More projects coming soon! Sign up here so you don’t have to miss anything!

Mike | Huisvanvandaag

Geef een reactie

Het e-mailadres wordt niet gepubliceerd.

Aanbevolen
The CO2 sensor had been on the wish list for quite some time. Why you…
Translate »