ESP8266 Does not seem to be working

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Arduino_JSON.h>
#include <DHT.h>

#define DHTTYPE DHT22

char auth[] = "not important";

char ssid[] = "nor is this";
char pass[] = "or this";

String data;

const int dht_pin = 1;
DHT dht(dht_pin, DHTTYPE);
float dht_humidity;
float dht_temp;

void setup() {
  Serial.begin(9600);
  delay(1000);

  Blynk.begin(auth, ssid, pass);
  Serial.println("Connecting.");
  Blynk.run();
  
  dht.begin();

  dht_humidity = dht.readHumidity();
  dht_temp = dht.readTemperature();
    
  Blynk.virtualWrite(V5, dht_humidity);
  Blynk.virtualWrite(V6, dht_temp);
  Serial.println(dht_temp + dht_humidity);
  Serial.println("Sent data");

  //ESP.deepSleep(600e6); End time
  ESP.deepSleep(10e6);
}

void loop() {
  //Not called.
}

So I have started a project with an esp8266 and blynk, and am simply trying to log values from a dht22 to a graph. Unfortunately, the deep sleep in the esp8266 doesn't work. I do have the RST pin connected to D0, so I don't think that is it. Any solutions or problems with my code would be appreciated, thanks!

Hi Rob,

google is your friend

here is demo-code from a tutorial.

Your code about deepsleep looks similar to the demo-code.
You haven't written what the problem is.

I sugest that you test the different functionlalities on its own in smaller testprograms

I mean

-testing if deep-sleep works at all
with a small testprogram that does nothing more than testing deep-sleeping and awaking

  • testing the DHT on its own does reading the dht-sensor work?
    with a small program that does nothing else but reading the dht sensor and print the data to the serial monitor

  • testing does sending values to blink work
    with a small program that does nothing else but sending data to blynk
    As a quick guess: I think your ESP8266 must be connected to your WLAN-router as a bare minimum

best regards Stefan

Yes, sorry I did use a tutorial from google, but what is happening (which I forgot to add :frowning: ) is that the deep sleep only happens once, then I have to press reset for it to do anything. Thanks for the reply!

I'm not a deepSleep expert,
but this sketch blinks my LED (1 sec on, off, dS 14 sec, . . .)

void setup() 
{
  pinMode(9, OUTPUT);
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9,LOW);
  ESP.deepSleep(14e6); 
}


void loop() 
{
}

Maybe your RST wire (a "jumper"?) is NG.

robtherobot:
Yes, sorry I did use a tutorial from google, but what is happening (which I forgot to add :frowning: ) is that the deep sleep only happens once, then I have to press reset for it to do anything. Thanks for the reply!

same answer as before:
Test each function seperately.
Then add only one thing and test again if this combination works.
If I should find out I would have to do the same procedure
best regards Stefan

Have you done this to see where the hang up is on the 2nd boot?

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Arduino_JSON.h>
#include <DHT.h>

#define DHTTYPE DHT22

char auth[] = "not important";

char ssid[] = "nor is this";
char pass[] = "or this";

String data;

const int dht_pin = 1;
DHT dht(dht_pin, DHTTYPE);
float dht_humidity;
float dht_temp;

void setup() {
  Serial.begin(9600);
  delay(1000);
Serial.println("A");
  Blynk.begin(auth, ssid, pass);
Serial.println("B");
  Serial.println("Connecting.");
  Blynk.run();
Serial.println("C");
 
  dht.begin();
Serial.println("D);
  dht_humidity = dht.readHumidity();
Serial.println("E");
  dht_temp = dht.readTemperature();
   Serial.println("F");
  Blynk.virtualWrite(V5, dht_humidity);
Serial.println("G");
  Blynk.virtualWrite(V6, dht_temp);
Serial.println("H");
  Serial.println(dht_temp + dht_humidity);
Serial.println("I");
  Serial.println("Sent data");

  //ESP.deepSleep(600e6); End time
  ESP.deepSleep(10e6);
}

void loop() {
  //Not called.
}

I did try before, but any serial messages I send seem corrupted or just don't send - it is rather infuriating

anyway a short description like

any serial messages I send seem corrupted or just don't send

does not give all the information you have.
You should post the complete output of the serial monitor as a code-section
regardless of beeing "corrupted" or not
We don't have any "backdoors" to your computer-system to get this informations illegally from you.
And we don't have glas-spheres either
So open the serial monitor
press the reset-button and hold the reset-button down
while you are still holding the reset-button down
click on clear output-button of the serial monitor
then release the reset-button

The ESP8266 resets and boots up starting to send serial data
mark every single byte even the rubbish and copy & post it

best regards Stefan

on older ESP8266-boards If you change the baudrate to 74880 you can see what the board is sending on bootup.

you coded

char auth[] = "not important";
char ssid[] = "nor is this";
char pass[] = "or this";

do you really expect that this works?
did you setup your local Blynk-server and configured auth ssid and pass like this?

Of course a lot of things can happen that the connection could fail.
I'm sure that the Blynk-library has possabilities to check for all kinds of common failures
like:

  • wrong auth,
  • wrong ssid etc. etc.

So you should read how you can get information through your code about possible failures.

I found several things that make your code stop by the method described in my footnote.
So read my footnote and take it to your heart.

best regards Stefan

robtherobot:
I did try before, but any serial messages I send seem corrupted or just don't send - it is rather infuriating

I did not know that or I'd not waste my/your time with doing the already done. It is vital that you help us help you figure this dang thing out and without the proper information, how can we do that?
Show the printout of the garbage.

After testing where the code stops working
I used the search-function of the blynk-community website with this keywords to search

code stops at Blynk.begin(

I looked up the very first hit and in the third post a very fundamental thing how Blynk works is explained.

best regards Stefan

StefanL38:
on older ESP8266-boards If you change the baudrate to 74880 you can see what the board is sending on bootup.

you coded

char auth[] = "not important";

char ssid[] = "nor is this";
char pass[] = "or this";



do you really expect that this works?
did you setup your local Blynk-server and configured auth ssid and pass like this?

Of course a lot of things can happen that the connection could fail.
I'm sure that the Blynk-library has possabilities to check for all kinds of common failures
like: 
- wrong auth, 
- wrong ssid etc. etc. 

So you should read how you can get information through your code about possible failures.

I found several things that make your code stop by the method described in my footnote.
So read my footnote and take it to your heart.

best regards Stefan

Removed it from the code because it had auth token and passwords.

Hi,
Have you been able to JUST make the 8266 go to sleep, wake up, flash a LED a couple of times, then go back to sleep and repeat?

Try this first to make sure you know to do the basic sleep/wakup/sleep cycle.

For the moment FORGET the rest of your project, lets get the basics working first.
I know this sounds slow and laborious, but developing a project in stages helps to reduce troubleshooting.

Tom... :slight_smile:

robtherobot:
Removed it from the code because it had auth token and passwords.

beeing that short on words is just waisting time.
If you want real help you have to provide real detailed information.
With this tiny bit of information about the actual status of your project
the advise is really short: make the basic example blink onboard LED of your ESP32-board
blink 3 times go to sleep - repeat work
If it does not work post your "Just-Blink-LED-deep-sleep-code"
best regards Stefan