Noob needs help with temp anywhere project

Did as instructed Thanks.

Hi Folks, I just wanted to check in again. The author made another instructible to up the project to two sensors and since that was my original intention I went ahead. I had a lot of compilation issues until I replaced his simple timer with the blynk timer that Costas used in his rework. Now it is up and running I am getting temps on both sensors, using both gauge and history graph for both.
I am still using PUSH as instructed but again seeing those pesky reconnects, but temp updates are basically o’k’ for response. My intent here is just to monitor freezer temps so I don’t really need instant responses just need to know that it hasn’t shut down and spoiling all my put asides for the winter months. LOL what led to this was last year that did happen all that hard work went in the trash.
V10 handles one and V11 the other. Anyway here is a paste of the code:

/**************************************************************
 * IoT Multiple Temperature Monitor with Blynk
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 * 
 * Multiple OneWire Sensor: DS18B20
 * Developed by Marcelo Rovai - 25 August 2017
 **************************************************************/

/* ESP & Blynk */
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
char auth[] = " token here";

/* WiFi credentials */
char ssid[] = "router identity";
char pass[] = "network password";

/* TIMER */
BlynkTimer timer;

/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h> 
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
int temp_0;
int temp_1;

void setup() 
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  DS18B20.begin();
  timer.setInterval(1000L, getSendData);
  Serial.println(" ");
  Serial.println("Testing Dual Sensor data");
}

void loop() 
{
  timer.run(); // Initiates SimpleTimer
  Blynk.run();
}

/***************************************************
 * Send Sensor data to Blynk
 **************************************************/
void getSendData()
{
  DS18B20.requestTemperatures(); 
  temp_0 = DS18B20.getTempFByIndex(0); // Sensor 0 will capture Temp in Celcius
  temp_1 = DS18B20.getTempFByIndex(1); // Sensor 0 will capture Temp in Fahrenheit

  Serial.print("Temp_0: ");
  Serial.print(temp_0);
  Serial.print(" oF . Temp_1: ");
  Serial.print(temp_1);
  Serial.println(" oF");
   
  Blynk.virtualWrite(10, temp_0); //virtual pin V10
  Blynk.virtualWrite(11, temp_1); //virtual pin V11
}

If you see anything amiss give me a shout.
Thank You for making this project a reality and I do put my money where my mouth is, I’m making a contribution to Blynk.
Regards,
Dave

You have these declared twice in your sketch which will normally stop compilation so I have removed the first set from your sketch.

1 Like

Also I think temp_0 and temp_1 should be float not int. So 24.7 degrees not 24 degrees. Unless you have removed most of the useful resolution of the DS18B20’s.

1 Like

I bet the double was just my hand tremor, as for float, I see that and will give it a whirl this afternoon.
10Q

Float is good, I like the resolution. May I ask, Yes, I did a lot of searching first, If, in the future I would want a notification (not important which kind) that the temp in my freezer has gone above its normal limit would it be wiser to make changes in the code if this is possible or to try to use another party like ifttt to make the notification.
The only project I could find here was:

I’m going to print out his code and compare it with the code you helped me with on this project to see if I can pick out where I need to go. I also went into Blynk docs and couldn’t find anything familiar there either, I was looking in notifications but then got interested and started reading from the top figuring it was overdue. I would think it a natural progression from a simple (lol, not for me!) temp reader to a temp reader that warns you that whatever you are monitoring has gone awry.

Unlike getting the temp monitor running before we leave, this second layer is on the longer range plan, But it does bring to mind when we were actually home and the freezer stopped and neither of us noticed it until it was too late, what a mess that was.

P.S. I bought a bunch of tokens!
P.P.S. Everyone is very impressed with the design and appearance of the Blynk app.

The more logic you move out from hardware - the less chance for the mistake in the code. You can also use Eventor to change notification type on the fly.

1 Like

@David_Vinch there are at least 3 ways to receive notifications:

  1. 3rd party solutions like IFTTT.
  2. Eventor.
  3. Code.

They all have advantages and disadvantages. Personally I’m not really interested in 3rd party solutions unless they provide something that Blynk doesn’t offer.

Eventor is probably the best solution for you as you are just learning how to code. The only issue I have with Eventor is that it’s not available in published apps. Or perhaps I should say it’s available to the developer of the app but not the user of the app. Probably not an issue for you but will be for Blynkers looking to market their products.

1 Like

Thanks Dmitriy, Thanks Costas,
I thought I’d give it a whirl I tried it with DHT and DS18B20, the errors returned were the same except the name DHT or DS18B20.

Arduino: 1.8.3 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

tempwarning:22: error: 'DHT' was not declared in this scope (NOTE: if I coded in DS18B20 and ran it I got the same message with the different name.)

 int temp_0 = DHT.readTemperature();

              ^

tempwarning:23: error: 'Blynk' does not name a type

 Blynk.virtualWrite(v10, t)

 ^

tempwarning:25: error: 'Blynk' does not name a type

 Blynk.virtualWrite(v11, t)

 ^

In file included from C:\Users\longb\Documents\Arduino\tempwarning\tempwarning.ino:30:0:

C:\Users\longb\Documents\Arduino\libraries\Arduino-Temperature-Control-Library-master/DallasTemperature.h:43:30: error: expected ')' before '*' token

     DallasTemperature(OneWire*);

                              ^

C:\Users\longb\Documents\Arduino\libraries\Arduino-Temperature-Control-Library-master/DallasTemperature.h:45:21: error: 'OneWire' has not been declared

     void setOneWire(OneWire*);

                     ^

C:\Users\longb\Documents\Arduino\libraries\Arduino-Temperature-Control-Library-master/DallasTemperature.h:225:5: error: 'OneWire' does not name a type

     OneWire* _wire;

     ^

tempwarning:32: error: 'OneWire' does not name a type

 OneWire oneWire(ONE_WIRE_BUS);

 ^

tempwarning:33: error: 'oneWire' was not declared in this scope

 DallasTemperature DS18B20(&oneWire);

                            ^

tempwarning:34: error: redefinition of 'int temp_0'

 int temp_0;

     ^

tempwarning:22: error: 'int temp_0' previously defined here

 int temp_0 = DHT.readTemperature();

     ^

exit status 1
'DHT' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Here is the code:

/**************************************************************
 * IoT Multiple Temperature Monitor with Blynk
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 * 
 * Multiple OneWire Sensor: DS18B20
 * Developed by Marcelo Rovai - 25 August 2017
 **************************************************************/

/* ESP & Blynk */
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
char auth[] = " ";

/* WiFi credentials */
char ssid[] = "";
char pass[] = "";

/* TIMER */
BlynkTimer timer;
int temp_0 = DHT.readTemperature();
Blynk.virtualWrite(v10, t)
int temp_1 = DHT.readTemperature();
Blynk.virtualWrite(v11, t)


/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include<DallasTemperature.h> 
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
int temp_0;
int temp_1;

void setup() 
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  DS18B20.begin();
  timer.setInterval(1000L, getSendData);
  Serial.println(" ");
  Serial.println("Testing Dual Sensor data");
}

void loop() 
{
  timer.run(); // Initiates Blynk Timer
  Blynk.run();
}

/***************************************************
 * Send Sensor data to Blynk
 **************************************************/
void getSendData()
{
  DS18B20.requestTemperatures(); 
  temp_0 = DS18B20.getTempFByIndex(0); // Sensor 0 will capture Temp in Fahrenheit
  temp_1 = DS18B20.getTempFByIndex(1); // Sensor 1 will capture Temp in Fahrenheit

  Serial.print("Temp_0: ");
  Serial.print(temp_0);
  Serial.print(" oF . Temp_1: ");
  Serial.print(temp_1);
  Serial.println(" oF");
   
  Blynk.virtualWrite(10, temp_0); //virtual pin V10
  Blynk.virtualWrite(11, temp_1); //virtual pin V11

I am in the process of reading the docs, just haven’t got that far.
Any suggestion is appreciated, This is a node mcu project with two DS18B20 sensors giving readouts to blynk through the cloud. Before I made this edit the code compiled and runs perfectly.
There’s no hurry or fuss over this, I just got curious.
Dave

You can’t have these with your library and variable declarations.

If you want notifications use your working sketch and add the Eventor and Notify widgets to your project. Then work through what is available with Eventor.

1 Like

That is so cool, who would’ve thought it’d be so easy. I added eventor, notify, and email and told it to warn me if things got above the usual. I did this with both of my projects. I like how you can just shut it off when unnecessary.
I just tested it by opening my garage door in project#2 and viola, notified and mailed, just like that.
Costas you are the man!
Now I need to buy more energy!

1 Like

First, Happy Thanksgiving! The most difficult day for Turkeys and Vegetarians!

UPDATE to project:
The idea is to add a DHT22 to my previous two DS18b20 board project. I looked at a lot of projects, printed them and tried to figure out how to combine to add this functionality, I’m still struggling with it weeks later so I hope you can get me going, here’s the code and the problem:

The problem: class Hardware Serial has no member named “print1n”
the Serial.print1n(“Failed to read from DHT sensor!”); was highlighted

If I’m completely off the mark, I don’t expect you to do it all for me, maybe point me in the right direction?

I tried looking this up but I’ve got to admit the answers went over my head.

Thanks Dave



/**************************************************************
   IoT Multiple Temperature Monitor with Blynk
   Blynk library is licensed under MIT license
   This example code is in public domain.

   Multiple OneWire Sensor: DS18B20
   Developed by Marcelo Rovai - 25 August 2017
 **************************************************************/

/* ESP & Blynk */
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
char auth[] = " ";

/* WiFi credentials */
char ssid[] = "";
char pass[] = "";

/* TIMER */
BlynkTimer timer;

/*DHT22 Sensor */
#define DHTPIN 12 //pin gpio 12 in sensor
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);


/* DS18B20 Sensor */
#include <OneWire.h>
#include<DallasTemperature.h>
#define ONE_WIRE_BUS 2 // DS18B20 on arduino pin2 corresponds to D4 on physical board
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float temp_0;
float temp_1;


void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  DS18B20.begin();
  dht.begin();

  timer.setInterval(1000L, getSendData);
  Serial.println(" ");
  Serial.println("Testing Dual Sensor data");
}
void loop()
{
  timer.run(); // Initiates BlynkTimer
  Blynk.run();
}



/***************************************************
   Send Sensor data to Blynk
 **************************************************/
void getSendData()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(true);
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  
  temp_0 = DS18B20.getTempFByIndex(0); // Sensor 0 will capture Temp in Fahrenheit
  temp_1 = DS18B20.getTempFByIndex(1); // Sensor 1 will capture Temp in Fahrenheit

  Serial.print("Temp_0: ");
  Serial.print(temp_0);
  Serial.print(" oF . Temp_1: ");
  Serial.print(temp_1);
  Serial.println(" oF");

  Blynk.virtualWrite(10, temp_0); //virtual pin V10
  Blynk.virtualWrite(11, temp_1); //virtual pin V11
  Blynk.virtualWrite(12, t);
  Blynk.virtualWrite(13, h);
}

You have some strange characters here that managed to comment out essential parts of your DHT code :wink:

What you want is this (I added indication of the FIXED lines)

/*DHT22 Sensor */  //  <---- FIXED * 
#define DHTPIN 12 //pin gpio 12 in sensor
#define DHTTYPE DHT22    //  <---- FIXED #
DHT dht(DHTPIN, DHTTYPE);
1 Like

OMG I stared at this for days, I can’t type.

Uh-oh, did the repair, replaced the carat ^ with star* and star* with hashtag#
and still the same error in the same line.
I’ll keep looking for more errors.

you do not have dht.begin(); line in your setup().

check carefully the dht11 example in sketch builder to find out how it should look like!

2 Likes

thanks for taking a look, I went there and looked at the example. first I tried just copying the dht.begin to my code and that didn’t help so I typed in all the parts that looked relevant and now have a different problem.
I pasted the revised code above, doing away with the previous to save space. Right now the problem seems to revolve around:
Serial.print1n(“Failed to read from DHT sensor!”); being highlighted
concerning a: "class HardwareSerial has no member named “print1n”.
I’ll keep digging and any help is greatly appreciated!

Are we looking at a font or typo issue again? That should be a lowercase l (L) and not a #1 in Serial.println()

1 Like

Yes, now it compiles.
Thank you.
1(#one), l(lower case L) on my laptop, very confusing when in Arduino Code.
p.s. fixed the code above, so someone doesn’t copy my mistake.

1 Like

on windows you can ctrl+scroll in arduino ide to change the editor font. also, can do that in file->preferences.

use a large font, otherwise you will have lots of trouble with syntax errors like this!

@David_Vinch, highly recommend to you this theme for arduino ide. it has WAY better syntax highlighting and more contrast, no more typos:

it is VERY easy to “install”, however, instead of deleting the original “theme” folder, just rename it to “themeOLD”, in case you need to revert to the original theme.

instruction shere:

1 Like