Temp monitor + wemos + blynk

I have installed a hot water temp monitor on my hot water heater’s flue gas piping as its get hot when the hot water heater is running and cools down when the hot water heater is offline. This way I can tell when the hot water heater is online or offline.

I had set a temp limit in the code which when exceeded, it notifies me that the hot water tank is online. I want to however change the temp limit in my code by using a slider widget so I can adjust the temp limit right from the blynk app.

With the temp limit set in the code, the notification widget worked fine, however after I added the slider widget, it doesnt notify me that the tank is online. Not sure what I am doing wrong.


#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp8266.h>
#include "DHT.h"
#define DHTTYPE DHT22
#define DHTPIN 2 //pin gpio 12 in sensor
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;



//connect DHT22 leg 1 to 5v on wemos, leg 2 to d4 ( # 2 in code) on wemos, leg 4 to ground on wemos)
// blynk two guages, v0 pin and v1 pin

char auth[] = "xxxxx";


float t;
float h;
bool temperatureMoved = true;
int maxvalue = 0;


#ifndef STASSID
#define STASSID "xxxx"
#define STAPSK  "xxxx"
#endif

const char* ssid = STASSID;
const char* password = STAPSK;



void setup() {
  Serial.begin(9600);
  Blynk.begin(auth, ssid, password);
  dht.begin();
  timer.setInterval(2000, sendUptime);

  Serial.begin(115200);
  Serial.println("Booting");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }


  // Port defaults to 8266
  // ArduinoOTA.setPort(8266);

  // Hostname defaults to esp8266-[ChipID]
  ArduinoOTA.setHostname("hot water tank flue gas temp");

  // 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_FS
      type = "filesystem";
    }

    // NOTE: if updating FS this would be the place to unmount FS using FS.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();
  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}


BLYNK_WRITE(V2)
{
   maxvalue == param.asInt();
}


void sendUptime()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  Blynk.virtualWrite(V0, t); // virtual pin
  Blynk.virtualWrite(V1, h); // virtual pin

  if ((t < maxvalue) && (temperatureMoved == true)) {
    temperatureMoved = false;
    Blynk.notify(String("STAND BY mode. Flue Temp:") + t + String("C"));
  }
  if ((t >= maxvalue) && (temperatureMoved == false)) {
    temperatureMoved = true;
    Blynk.notify(String("Water heater ON. Flue Temp:") + t + String("C"));
  }
}

void loop() {
  ArduinoOTA.handle();
  Blynk.run();
  timer.run();
}


What version of the Blynk library are you using?

Pete.

So I am not sure where to check blynk library version.

However I went to Arudino - > Library Manager → Search for Blynk → Found Blynk by Volodymyr Shymanskyy Version0.6.1 installed.

I also checked the play store, the blynk app version is the latest also.

That’s fine. Notifications don’t work if you have one of the beta versions installed, so wanted to rule that out as a potential cause.

Pete.

Have you tried Serial.print(maxvalue); to check if the value is changing as the slider changes?

Have you confirmed you have set the correct Vpin and have the widget connected to the correct device in the project?

cul

billd

i have selected the correct vpin and have the widget connected to the correct device.

Serial print prints only zero so the slider is not giving value to the code seems to be the issue.

BLYNK_WRITE(V2)
{
   maxvalue == param.asInt();
If i do a serial print here of maxvalue, the slider value prints in the serial monitor.
}

however when I put the same serial monitor in void Senduptime() function, maxvalue is not recalled

I’m not clear where in your void Senduptime() function you’re putting this serial print, and whether you are moving the slider widget first to set a maxvalue value.

As you don’t have a BLYNK_CONNECTED callback function with a Blynk.syncVirtual(V2) command in it, maxvalue will be zeto until you move the slider widget.

Also, I don’t think notifications are the best way of telling you about whether the boiler is running. I would have used a an LED widget and maybe a SuperChart widget set to binary mode to see the boiler’s behaviour over time.

Pete.

I tried your suggestion but it is still not working



BLYNK_WRITE(V2)
{
  maxvalue == param.asInt();

}

BLYNK_CONNECTED() 
{
Blynk.syncVirtual(V2);
}


void sendUptime()
{

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  Blynk.virtualWrite(V0, t); // virtual pin
  Blynk.virtualWrite(V1, h); // virtual pin
  Blynk.syncVirtual(V2, maxvalue);
   Serial.println(V2, maxvalue);
    Serial.println(maxvalue);
     Serial.println(t);

The output on serial monitor is get is


0
23.60

0
23.60

0
23.60

0
23.60

0
23.60

0
23.60

There should only be one = sign . . .

maxvalue = param.asInt();

cul
billd

1 Like

Well spotted @Bill_Donnelly!

Pete.