Noob needs help with temp anywhere project

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

Thanks for all the great hints.

This is another new experience for me and I need help again.
The above code compiled after your suggestions but after I uploaded it nothing happened, esp did not go online.
The new dht22 was connected
Sketch uploaded
Power restored
Nothing

To check:
I reloaded the original two wire ds18 sketch leaving the dht 22 connected and the original sketch runs well online.
What direction will the next step be in figuring out what is wrong?

UPDATE Iā€™ve made some changes and will upload it tomorrow to see if it works.
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>
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
char auth[] = " ";

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

/* TIMER */
BlynkTimer timer;

/* 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 sensors(&oneWire);
float temp_0;
float temp_1;

/* DHT22 Sensor */
#include <SPI.h>
#include <DHT.h>
#define DHTPIN 12    //D4 on board)
#define DHTTYPE DHT22
DHT dht (DHTPIN, DHTTYPE);

void setup() 
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  sensors.begin();
  sensors. setResolution(10);
  timer.setInterval(3000, readTemp);
  Serial.println(" ");
  Serial.println("Testing Dual Sensor data");
}

/***************************************************
 * Send Sensor data to Blynk
 **************************************************/
void readTemp()
{
sensors.requestTemperatures();
temp_0 = sensors.getTempFByIndex(0);
temp_1 = sensors.getTempFByIndex(1);
sensors.requestTemperatures();
float floatTempF = sensors.getTempFByIndex(0);
char t_buffer[15];
dtostrf (floatTempF, 8, 9, t_buffer);
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Temp_0: ");
Serial.print(temp_0);
Serial.print(" oF . Temp_1: ");
Serial.print(temp_1);
Serial.println(" 0F");

Blynk.virtualWrite(10, t_buffer); // Freezer temp
Blynk.virtualWrite(11, t_buffer); // Refrigerator temp
Blynk.virtualWrite(12, t); //DHT22 Temperature vp12
Blynk.virtualWrite(13, h); //DHT22 Humidity vp13
}
void loop() 
{

 Blynk.run();
 timer.run();
}

This is the all new code, the previous would not go online at all.
What I am trying to do is to add a DHT22 to my existing 2 wire DS18B20 project.
This code goes online but the refrigerator temp virtual pin 11 reads the same as the freezer temp virtual pin 10 and nothing reads at all from the DHT22
Does anyone see where I messed up?
As always, Thanks, Dave