1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

ESP8266/DHT22 'strange' happening

Discussion in 'Microcontrollers' started by Nigel Goodwin, May 23, 2017.

  1. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,210
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    I'm still playing with DHT22 temperature/humidity sensors, and still trying to find a graphing solution I'm happy with - the one below is OK, apart from I can't get date/time X scale displays.

    The two graphs are:
    1) Top Graph - An ESP01 and DHT22, powered via a USB lead and FTDI board from my PC, it's actually in the attic sat about a foot from my left elbow at this very moment. It reads temperature, humidity, and internal supply voltage every ten minutes, and uploads via my WiFi to a PHP/MYSQL database.

    2) Bottom Graph - a Wemos Mini and DHT22, powered from an AA sized Lithium Ion cell - this is in the eaves of the house, about six foot behind me a this moment. The 'wall' between eaves and attic is insulated, as is the ceiling below the eaves - one point of this exercise is to compare the readings under the eaves, and in the attic - to make me happy after the hard work fitting the insulation :D This runs the same software as the ESP01, and uploads to the same PHP/MYSQL database, with a different device ID.

    Due to my mentioned graphing problems it currently displays only daily readings, and the X axis numbers are the sample reading numbers, auto-incremented as each reading is added to the database.

    My question is regarding the bottom graph, and why it's died - fair enough I thought, the battery has run down - but a second look shows that it's still making temperature readings, while all others have ceased (these are humidity, battery voltage, WiFi connection, and RSSI). So I'm a little puzzled by that? Obviously I could just fetch the unit from under the eaves (but it's damned hot in there! :D) and measure the battery, but I'm loath to do that yet as it would negate the test somewhat. So has anyone got any ideas?, I thought perhaps the heat had got too much for it?, but why would the temperature reading still work?.

    My current plan is to see what it's like in the morning, as it cools down over night.

    For those who have read my previous DHT22 ramblings, I still have the HC-12 wireless ones running (using PIC16F1827's), and until recently these were being read by a PC and graphed via Lazarus (still with X-axis scaling problems though). However, last Sunday I spent some time programming a Wemos Mini, this now replaces the PC, it reads the DHT22/H-12's via it's own HC-12, and then uploads the readings direct to ThingSpeak - here's a link to a webpage displaying those readings:

    http://www.lpilsley.co.uk/new1.htm

    Obviously the readings could just as easily be uploaded to my MYSQL database (and may well be later), but I'm still trying to find a nice graphing solution.
     

    Attached Files:

    • Like Like x 1
  2. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,210
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    Well, thought I'd check before I go to bed, and as the temperature has fallen it's started giving the rest of the readings again - looks like it might be a temperature issue.

    DHT22_2.png
     
    • Like Like x 1
  3. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,794
    Likes:
    134
    Location:
    morristown,tn
    so many things to do with these I wish i had more time to play with the esp
    Nigel are you using the arduino ide to program the esp.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,210
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE

    Yes I am, there's a lot more code available for the Arduino IDE.

    This morning it's all working well again?, be interesting to see what happens if it gets hot this afternoon.
     
  6. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,645
    Likes:
    246
    Location:
    North west UK
    I just posted another thread which could be related, I have an issue with a esp serving a webpage, the esp will randomly refuse to serve the page and the browser defaults with a no connect (but if you leave the page open its ok for days).
    The only thing I can think of is the rf is dropping out, but that would mean the connect counter would increment, it isnt, maybe the rf drops low enough to refuse connection but not enough to disconnect.
    Theres info on the web about the ubiquitous bypass cap, and some on faulty i2c prom chips, and some info about clearing the esp's memory and re-programming, to prevent random resets.
    It would seem that esp's have a stability issue, have you placed delay or yield in your code?, you need to to pass proc time to the server.
    It will be interesting to see if you find the cause to your problem.
    Are you using google graphs?, I'm just trying to suss out how to use ajax to create the data array for ggraphs.
     
    Last edited: May 24, 2017
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,210
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    The graphs above are using phpgraphlib.php, and run on a server at my website, the graphs in the link above are from ThingSpeak.

    The same effect occurred today again, but for a much shorter interval, graph below:

    I'm completely bemused as to what's causing it, the entire data string is uploaded in one piece, but only the first two parts (the source ID number 5, and the temp) of it actually gets stored in the MYSQL database, here's the actual line in the ESP8266 code:

    http.begin("http://www.lpilsley.co.uk/???????.php?ipsrc=5&temp="+ temp + "&humi="+ humi + "&batt=" + vstr + "&wifi="+ conn + "&rssi="+ rstr);

    I've redacted the actual php file name that it feeds :D

    The code does actually output information via the serial port (USB on the Wemos), but it's not where I can access the port.

    The code also use 'deepsleep', so it resets before each reading.

    DHT22_3.png
     
  8. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,645
    Likes:
    246
    Location:
    North west UK
    Ok I see.
    The code I'm playing with is independent, the page is written in html/css/javascript, the page containing the google graph is uploaded to the browser by the esp, then the browser requests data from the esp server periodically via the javascript , I can get it to work with an array variable, but havent quite sussed how to get the graph to load its own data via xml.

    Sounds like something isnt setup right at the server end, one thing with google graphs if you give it a nan it totally freaks out and refuses to draw anything even the axes, and my dht 11's give a nan reading every minute or so, probably got the tune value a bit off, I had to put some code in mine to detect a nan and replace it with the previous value to keep the graph on the page, maybe summat like this is happening with you.
     
  9. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,210
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    Well, needless to say, it happened again today :D

    Rather than the graph, here's the relevant part of the MYSQL database, interestingly it died at 34 degrees timed at 14:46, when the previous reading was 34.1 and it worked OK :D

    DHT22_4.png
     
  10. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,645
    Likes:
    246
    Location:
    North west UK
    I think you'd better brave the 35 degrees and get the thing down from there, and hook it up to a serial port and see if the values drop on serial too, then you'll know if its aquisition or network.
     
  11. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,210
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    I will eventually, but one of my current goals is seeing how long the batteries last, so I'll probably wait until that happens.

    In any case, I'm going away next week :D
     
  12. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,645
    Likes:
    246
    Location:
    North west UK
    I've just been looking at some esp code that increases stability of net software.
    It checks to see of the lan is connected and reconnects if not, then checks to see if a client is connected, if so then it waits for 250mS and drops out if no data appears, then checks to see if an incoming request actually has a valid path, and drops out if not, these 3 things are sposed to increase long term reliability.
    I'm going to implement them in my code which keeps messing up.
    I've noticed a few times on my virgin network something/one tries to connect to the esp, maybe some kind of bot this could well put a spanner in the works.
     
  13. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,210
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    Well, as the battery had finally gone flat I retrieved it to charge it up - and as I'd got another similar Wemos running (but uploading to a comma delimited file, and running from a larger 18650 battery) I reprogrammed that and stuck it under the eaves instead.

    So we'll see what happens now, if it ever gets hot enough again :D
     
  14. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,645
    Likes:
    246
    Location:
    North west UK
    I'm putting one in our greenhouse now, so we'll see how hot that gets.
    It is its own website, the graph covers the last 24 hours.
    The issues with the silo tower esp was due to router settings, that and it goes into power save if unused, so I'll just add a clock sync to it or something that uses the connection.
     
    Last edited: Jun 9, 2017
  15. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,210
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    Well I've got a different ESP module running under the eaves now, and it's not died since - and it hit 41.2 degrees this afternoon about 17:45

    The original one is still working fine in the spare room, where it doesn't get so hot :D
     
  16. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,645
    Likes:
    246
    Location:
    North west UK
    The one in my greenhouse has survived similar tenps and been Ok.

    And I found the issue with the Esp in the silo tower, its too far from the router, I temporarily moved it nearer and plugged it into a usb socket, and now it access's every time.
     

Share This Page