[SOLVED] Noob can't make ESP8266-1 Standalone+DHT11 work

Hi,

I’m struggling to get a basic sketch (blynk_esp8266_dht11_instructable.ino) to work in the app (IOS 9.1). I’ve tested different combinations of widgets and pins but I never get any data in the app.
From what I can decipher from the logs the ESP gets connected correctly, I get sensor readings and I seem to get an 200 ok (for something).

I really think there’s something very simple that I’ve missed, but I can’t see what it could be. I’m using the same setup I had previously with thingspeak which works perfectly fine.

Could any of you experts point me in the right direction?

"YeØþÿ¬‘ZøÚŸÍ$þ[219] Connecting to hawkmarsh
[4317] Connected to WiFi
[4317] My IP: 192.168.0.53
[4317] Blynk v0.3.2-beta
[5001] Connecting to cloud.blynk.cc:8442
[5153] <msg 2,1,32
<2553df9b0fbxxxxxxxxxxxxxxxxxxxxx
[5269] >msg 0,1,200
[5270] Ready (ping: 1ms).
[5270] <msg 17,1,76
<ver

Hi,

I’ve knocked together a quick script, I’ve not got any ESP-1’s (or any near me at the minute to test it on). I’ve based it from memory of a simlar script I have running at home. So hopefully it will work and point you in the right direction.

/**************************************************************
 * 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
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            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 runs directly on ESP8266 chip.
 *
 * You need to install this for ESP8266 development:
 *   https://github.com/esp8266/Arduino
 *
 * Please be sure to select hte right ESP8266 module
 * in the Tools -> Board menu!
 *
 * Change WiFi ssid, pass, and Blynk auth token to run 
 *  hopefully it should upload your DHT11 Temp and 
 * Humidity as well as the ESP8266 Uptime - cam1985
 * :)
 **************************************************************/

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>

#define DHTPIN 2
#define DHTTYPE DHT11

DHT_Unified dht(DHTPIN, DHTTYPE);

#define VPIN_TEMP V1
#define VPIN_HUMIDITY V2
#define VPIN_UPTIME V5

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

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, "ssid", "pass");

  dht.begin();
}

BLYNK_READ(VPIN_TEMP)
{
  // This command writes DHT11 Temperature to Virtual Pin (1)
  sensors_event_t event;
  dht.temperature().getEvent(&event);
  if (!isnan(event.temperature)) {
    Blynk.virtualWrite(VPIN_TEMP, event.temperature);
  }
}

BLYNK_READ(VPIN_HUMIDITY)
{
  // This command writes DHT11 Temperature to Virtual Pin (1)
  sensors_event_t event;
  dht.humidity().getEvent(&event);
  if (!isnan(event.relative_humidity)) {
    Blynk.virtualWrite(VPIN_HUMIDITY, event.relative_humidity);
  }
}

BLYNK_READ(VPIN_UPTIME)
{
  // This command writes ESP8266's uptime in seconds to Virtual Pin (5)
  Blynk.virtualWrite(VPIN_UPTIME, millis() / 1000);
}

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

If there are any problems with the code let me know and I’ll help sort it. :slight_smile:

Regards,
Cam

Hi,

Thanks for the quick response. I tried your code and it runs fine, but I still don’t see any data in the App. The default blynk debug doesn’t show much so I don’t know if the requests are received correctly.

I’ve set up the App like this and tried different timers but nothing.

Thanks,
J

Hi,

Can somebody please help me with this?

I’ve now tried several different sketches and I still can’t get any data to the the IOS App.

I’ve also tested to set up a local Blynk server on RPI. I can see in the server logs that both HW and Device are logged in. I can also see data being populated in /data.

Contents of 1887108056_v4.csv:
34.0000,1449782703483
34.0000,1449782793506
34.0000,1449782823510
34.0000,1449783264523

Are there any know issues with IOS9.2?

BR,
Johan

So you have widget with V4 pin and don’t see anything? Try sending something simple like Blynk.virtualWrite(V4, 10); Is it appears?

Hi,

No, added as you said but still nothing in the APP. The CSVs (for pin 4, 5 and 10) still gets filled with data and according to the logs, my IOS device should be connected.

Let me know if there is further debug or logs that could be checked to see whats going on,

pin10 (sending value 10 every 10 sec):
10,1449813693929
10,1449813703967
10,1449813714204
10,1449813723931
10,1449813733965
10,1449813744302
10,1449813753936
10,1449813763965
10,1449813774693
10,1449813783917
10,1449813793968
10,1449813804798
10,1449813813937
10,1449813823982
10,1449813834393

Code:

    /**************************************************************
     * 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
     *   Blynk community:            http://community.blynk.cc
     *   Social networks:            http://www.fb.com/blynkapp
     *                               http://twitter.com/blynk_app
     *
     * Blynk library is licensed under MIT license
     *
     *
     **************************************************************
     * 
     * 
     *
     * WARNING :
     * For this example you'll need SimpleTimer library:
     *   https://github.com/jfturcot/SimpleTimer
     * Visit this page for more information:
     *   http://playground.arduino.cc/Code/SimpleTimer
     *
     * DHT11 ----pin 12
     *  
     *
     **************************************************************/
    #define BLYNK_DEBUG
    #define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    #include <SimpleTimer.h>
    #include <DHT.h>
    //dht11 DHT;
    #define DHTPIN 2     // what pin we're connected to

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

    DHT dht(DHTPIN, DHTTYPE, 15);


    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "ccc1a602eb7f4dabb853758ad3b36280"; //insert here your token generated by Blynk

    SimpleTimer timer;

    void setup()
    {
      Serial.begin(9600); // See the connection status in Serial Monitor

      dht.begin();
      delay(10);
      
      Blynk.begin(auth, "ssid", "pass", IPAddress(192,168,000,005)); //insert here your SSID and password
     
      // Setup a function to be called every second
      timer.setInterval(10000L, sendUptime);
    }

    // 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 sendUptime()
    {
    //Read the Temp and Humidity from DHT
      float h = dht.readHumidity();
      float t = dht.readTemperature();
      Blynk.virtualWrite(4, h);
      Blynk.virtualWrite(5, t);
      Serial.print("Humidity: "); 
      Serial.print(h);
      Serial.print(" %\t");
      Serial.print("Temperature: "); 
      Serial.print(t);
      Serial.print(" *C ");
    }


    void loop()
    {
      Blynk.run(); // Initiates Blynk
      timer.run(); // Initiates SimpleTimer
    //  int chk; 
    //  chk = dht.read();    // READ DATA
     
      
    }

@discfunctional did you specify IP address of local server in mobile app?

Also look strange… Don’t think this is an issue. But please use

IPAddress(192,168,0,5)

Also do you see any “ESP not in network” messages in app?

Hi,

I don’t see any information in the app after login. So it seems to be able to be log in and I only see a message once I shut down the server.

I’ve changed IP but I don’t think it makes a difference since it’s clearly logging the data to the server.

Are there any known/similar issues with Blynk v0.3.2-beta?

I only have an Iphone 6, is there any other way to simulate the frontend part, like a webclient?

[11162] Connected to WiFi
[11162] My IP: 192.168.0.53
[11163] Blynk v0.3.2-beta
[11163] Connecting to 192.168.0.5:8442
[16164] Connecting to 192.168.0.5:8442
[16196] <msg 2,1,32
<ccc1a602eb7f4dabb853758ad3b36280
[16212] >msg 0,1,200
[16213] Ready (ping: 8ms).
[16213] <msg 17,1,76
<ver…

You didn’t answer my question -

Here http://docs.blynk.cc/images/custom.png

@Dmitriy Yes of course, otherwise I wouldn’t be able to log in. :wink:

//J

Hm… Ok. Could you please in that case take latest library from trunk? https://github.com/blynkkk/blynk-library button “Download zip”

@Dmitriy, now running 3.2-beta, still no data in the app. And honestly I don’t see what difference the lib version would make. There is data being populated in the csv-files.

You are right. My fail. Do you use latest version of the app? Also do you see some errors in local server log? Does button widget works for you?

@Dmitriy Is the ./log/blynk.log the local server log.? If so then - No no issues reported. However I’ve noticed that the server has stopped a few times. It doesn’t seem stable on RPi.

I will try to run a sketch with only button widget, one thing I haven’t tried yet. I thought it would be so simple to get the DHT sensor data to the the app. It’s worked like a ‘hello world’ for all other setups i’ve done - my own front end, thingsspeak, etc.

//J

Yes. Also there is a user specific file ‘./log/users/your_user_name.log’.

It is stable. Zero reports for more than 8 months of work. Do you know why server was stopped?

It is. The question is - what is wrong with exactly your setup. You are using latest app., right?
Also you pressed “play” button on app after setup, right?

@Dmytro, Now it works! Did a clean install of the app, restarted iphone and a new project with only a button widget and it worked directly. Then went back to my DHT project and it also worked.

Thanks!

2 Likes

Fuh. Glad it finally works.

Total Noob question here.

@dysfunctional tried your code but getting to following error when compiling:

Multiple libraries were found for “SimpleTimer.h”

exit status 1
‘sendUptime’ was not declared in this scope

Not sure what I have done wrong but I’ve downloaded the simple timer libraries from https://github.com/jfturcot/SimpleTimer and the dht libraries from https://github.com/adafruit/DHT-sensor-library.

Sam.

@samyt since the sketch was posted Arduino has ‘moved on’. From version 1.6.6 the functions have to be in order so when setup() is processed there is no sendUptime() function available. Move the function to come before setup().

Have you installed the 5 libraries provided by Blynk? One of them is SimpleTimer but normally you would manually install the 5 libraries and NOT through library manager. DHT library can be done with the manager but not the other 5 as it is a single zip file with all 5 libraries.

Structure for the libraries is included with the release notes at https://github.com/blynkkk/blynk-library/releases/tag/v0.3.4