Not getting the temperature in the app

Change this:

#define DHTPIN 2

To this:

#define DHTPIN D2

And let us know what happens.

First, thank you very much for the help I have received. I’m very grateful.

I now switched the MKR1000 processor, to the ESP8266 mod., I applied the code below and the same problem continues, does not send the data to the app Blynk.

I switched the naming Pin “2” to “D2” on ESP8266mod gave this error:


 #define DHTPIN D2          // What digital pin we're connected to

                ^

C:\Users\ary\Desktop\ESP8266_pequena_DTH\ESP8266_pequena_DTH.ino:58:9: note: in expansion of macro 'DHTPIN'

 DHT dht(DHTPIN, DHTTYPE);

         ^

Multiple libraries were found for "BlynkSimpleEsp8266_SSL.h"
 Used: D:\OneDrive\Arduino\libraries\Blynk
 Not used: D:\OneDrive\Arduino\libraries\blynk-library-0.6.1
exit status 1
'D2' was not declared in this scope```

Here is the code that I am currently using in ESP and is occurring the same problem that occurred with the MKR100: Very strange!!!

  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  This example shows how value can be pushed from Arduino to
  the Blynk App.

  WARNING :
  For this example you'll need Adafruit DHT sensor libraries:
    https://github.com/adafruit/Adafruit_Sensor
    https://github.com/adafruit/DHT-sensor-library

  App project setup:
    Value Display widget attached to V5
    Value Display widget attached to V6
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266_SSL.h>
#include <DHT.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "_c1MjnnGjctr7oCyOMKvJNeGyVrVIVUf";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Novo-de-cima";
char pass[] = "xxxxxxxxxxxx";

#define DHTPIN 2          // What digital pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(3000L, sendSensor);
}

void loop()
{
  Blynk.run();
  timer.run();
}```

Thanks for the help, but I’m a beginner. You could explain to me better what I meant by that link.

Thanks again

What version of the ESP core have you installed in the Arduino IDE, and what board type did you choose when you compiled the code?

Personally, I’m not a fan of using the ‘D’ numbers that are screen printed on ESP8266/NodeMCU/Wemos D1 Mini boards as it affects the portability of code from one type of device to another.
I think it’s far better to use GPIO numbers and add a comment that translates this to the ‘D’ number on the board so that it makes wiring and debugging the hardware easier.

Pete.

Thank you

1- please can teach me how I see what version the IDE is using, because I have added several libraries, how should I do to fetch the version of “Core”?

2- Below photos of the board configuration.

3- Use the pin 2, where it is named in the board “IO2”.

  1. Tools/Board/Boards Manager. Scroll down to the bottom of the list and find ESP8266 by ESP Community and see what version is installed.
    2 & 3) Why are you using a bare ESP module rather than a dev board? You’ll have lots of difficulties powering the module and interfacing with a USB Com port.
    I’d recommend a NodeMCU or Wemos D1 Mini dev board…
    Which board should I choose for my first Blynk project?

Pete.

Refer to the picture, you need to set your refresh interval to PUSH

Thank you for your patience.

1-I did the search with you sent “ESP8266 by ESP Community” and found nothing. So I did the search like this: “ESP8266 by ESP” I found what is in the photo below.

2 and 3-I have an adapter that makes programming easy… See in the photo.

What am I supposed to do now?

Pete

I think I did not say, that I had already made the code and had worked, so I took to monitor a deposit that I have and after a few days ceased to work, or rather left to send the data of temperature and humidity, thought he had frozen , brought home and reboot and did not work, so the suite on/off-this was in a ESP8266. So I thought it was the sign, that’s when I switched to MKR1000 and the same thing happening to her…
In my view I think this is some interruption in the shipping phase for the Temp app. or Humi. Because when I withdraw the sensor the esp8266 accuses that it is not reading… So I conclude. He reads, but does not send, or if he sends something this interrupting…

Don’t search, scroll down to the bottom of the list.
I assume that at some point you’ve followed these instructions ?:
https://arduino-esp8266.readthedocs.io/en/2.5.2/installing.html

I’d start by soldering that module the board, otherwise you’ll never get reliable results once you start uploading and running code.

Pete.

Hi Pete,

I tried everything and I could not, solve, already tried to a plate ESP32, but the same thing happens. I think the problem is in the data transmissions…
Could you suggest to me another service similar to that of Blynk so I can try?

Thanks very much.

Ary Figueira

Well, you’ve come to the wrong place to get advice on alternatives to Blynk :grinning:
We can’t really help you if you keep jumping from one board to another, and don’t answer straightforward questions when we ask them.
The last clear piece of information we had from you was that you couldn’t get the code to compile because if didn’t like the reference to pin D2. Since then your responses have jumped all over the place and I have no idea what version of the ESP core, or now ESP32 core you are using, and what changes you’ve made to code, hardware connections and MCUs.

If you want help then you have to help us to help you.

Pete.

1 Like

I’m sorry if I offended you with any questions. I didn’t mean to.
I believe that my English does not help much for I apologize too…

I told you I had already tried on the ESP32 board.
I haven’t stopped using the ESP8266 I keep testing her. We can concentrate in the ESP8266.

Thanks

Ary

so does the code compile on the Arduino IDE? Or is it still giving errors?

Post latest version of code.

The DHT has been used successfully by many BLYNK users, so i suspect something is going wrong on your end.

1 Like

Okay, what version of the ESP core do you have installed?
What code are you using?
Does your code compile?
What board type are you using when you compile the code?
How is your DHT device connected?
What do you have set-up in your app?
If your code runs, what do you see in the serial monitor?
Does your device show as being online?

Pete.

Thank you

No, it does not give error when compiling or when uploading.

Here’s the code:

  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  This example shows how value can be pushed from Arduino to
  the Blynk App.

  WARNING :
  For this example you'll need Adafruit DHT sensor libraries:
    https://github.com/adafruit/Adafruit_Sensor
    https://github.com/adafruit/DHT-sensor-library

  App project setup:
    Value Display widget attached to V5
    Value Display widget attached to V6
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266_SSL.h>
#include <DHT.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxxxx";
char pass[] = "xxxxxxxxxxx";

#define DHTPIN 2          // What digital pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

void loop()
{
  Blynk.run();
  timer.run();
}```

So, I asked you eight questions and you’ve just provided answers to two of them.
I’ll sit back and wait until you answer the other six questions before I say any more.

Pete.

Friend, if you had paid attention, I still haven’t responded to you… I replied to the friend “Toro Blanco”.

I’m picking up your answers as soon as I have I will post.

Thank you

After you asked me, which version was using ESP Core. I came to the conclusion that there were many labraries open in my IDE. I decided unistall all and to install only I needed in this code. And what was my surprise. IT’S WORKING…

Thank you Pete and everyone who tried to help me… And I’m sorry about something…

Health and peace for all…

2 Likes

Glad you got it working.

#define DHTPIN 2          // What digital pin we're connected to

GPIO 2 is not an ideal pin to use. It requires special attention so as not to cause issues when booting/loading code. You may want to switch it to GPIO 4, and rewire the sensor.