-->
Page 1 of 6

Help with esp8266 sketch please: SHT21 temp/humid sensor

PostPosted: Fri Jul 17, 2015 1:55 pm
by PaulRB
Hello all, can someone please help with my first esp8266 sketch? OK... second sketch, I got "blink" working!

Here is my sketch:
Code: Select all/****************************************************************
 * ReadSHT2x
 *  An example sketch that reads the sensor and prints the
 *  relative humidity to the PC's serial port
 *
 *  Tested with:
 *    - SHT21-Breakout Humidity sensor from Modern Device
 *    - SHT2x-Breakout Humidity sensor from MisensO Electronics
 ***************************************************************/

#include <Wire.h>
#include <SHT2x.h>


void setup()
{
  Serial.begin(115200);
  delay(5000);
  Serial.println("Starting Wire...");
  Wire.begin(2, 0);
}

void loop()
{
  Serial.print("Humidity(%RH): ");
  Serial.print(SHT2x.GetHumidity());
  Serial.print("     Temperature(C): ");
  Serial.println(SHT2x.GetTemperature());
 
  delay(1000);
}


And here is the output:
Code: Select allStarting Wire...
Humidity(%RH): 118.99     Temperature(C):
 ets Jan  8 2013,rst cause:4, boot mode:(3,0)

wdt reset
load 0x40100000, len 28780, room 16
tail 12
chksum 0x50
ho 0 tail 12 room 4
load 0x3ffe8000, len 1332, room 12
tail 8
chksum 0x06
load 0x3ffe8540, len 1700, room 0
tail 4
chksum 0x1d
csum 0x1d


The humidity value is clearly nonsense. The after the "Temperature(C):" appears, there is a pause of around 1s before the rest of that error message appears.

Thanks,

Paul

Re: Help with esp8266 sketch please: SHT21 temp/humid sensor

PostPosted: Fri Jul 17, 2015 5:12 pm
by PaulRB
Here are a couple of pics in lieu of a schematic.
20150717_200327.jpg
20150717_200520.jpg

Re: Help with esp8266 sketch please: SHT21 temp/humid sensor

PostPosted: Sat Jul 18, 2015 1:19 am
by PaulRB
In case you were wondering, the component with the red top is a SPDT switch. In one position it grounds the GPIO line for programming. In the other position it connects the GPIO line as one of the I2C lines.

Re: Help with esp8266 sketch please: SHT21 temp/humid sensor

PostPosted: Sat Jul 18, 2015 2:09 pm
by PaulRB
Hmm... reading this thread, it sounds like the message I am seeing is a "watchdog timer reset", which fires if my loop() does not complete in 1 second, or at least call wtd_feed() at least once per second.

I suspect the SHT2x.GetTemperature() is taking more than a second to complete, and so... WOOF!

So I need to either find a way to speed up SHT2x.GetTemperature() , or change it to call wtd_feed() while it is running.

This is the library I am using.