-->
Page 3 of 6

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

PostPosted: Sun Jul 19, 2015 1:53 pm
by burkmurray
Strange that SHT2x.GetHumidity() did not cause the watchdog timer error, or a hang


What happens if you switch the order (call GetTemperature before GetHumidity) in the loop? Does the error follow GetTemperature?

You can add print statements to your library to track the problem.

You might want to double-check your wiring first, though. Are you using an external power supply? I don't have an ESP-01 to test, but my ESP-12 can't do much more than blink when it's powered through my USB-serial cable - it resets as soon as it can't get enough current.

ETA: Also, are you sure you need those pull-ups on your I2C lines?

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

PostPosted: Sun Jul 19, 2015 6:16 pm
by PaulRB
Thanks.

i'll try swapping the temp & humid reads.

Just using the usb-ttl adaptor's 3.3V supply at the moment. I have a separate supply ready to use when i get to switching the wifi on. The sht21 sensor uses less current than an led. What message do you see when the esp resets due to insuficient current?

i2c pullups: its normal to include them. You can often get away without them on Uno and other '328-based Arduino because the internal pull-ups are enabled by the wire library. I will try removing them though.

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

PostPosted: Wed Jul 22, 2015 10:27 am
by certeza
It might help to insert a delay between Wire.endTransmission and Wire.requestFrom.
Worked for me but not all of the time. In a loop of 40 requests 4 still gave a wrong temperature value.
Furthermore, request the humidity value before the temperature value.

Code: Select all   ....
    Wire.endTransmission();     

    delay(100);

    Wire.requestFrom(0x40, 3);
    ....

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

PostPosted: Thu Jul 23, 2015 2:01 pm
by PaulRB
I added a tactile switch and 10K pullup as a reset button and swapped the SPDT switch for another tactile button, as I have seen used with ESP8266 elsewhere. This has made working with the ESP easier.
20150723_194639.jpg

20150723_193305.jpg


I noticed that the serial port reported by Ubuntu kept swapping between /dev/ttyUSB0 and /dev/ttyUSB1. I think this must have been because the ESP was drawing too much current from the USB-Serial adaptor's feeble 3.3V output, causing it to reset each time the ESP restarted, as burkmurray suspected. So I have added a power supply for the ESP and sure enough this has stopped the USB/Serial adaptor from resetting every few seconds and Ubuntu reports it as /dev/ttyUSB0 all the time.

As suggested I tried swapping the order of reading the temp and humidity:
Code: Select allStarting Wire...
Wire Started
Temperature(C): 128.86     Humidity(%RH):
 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x40100000, len 28780, room 16
tail 12
chksum 0x24
ho 0 tail 12 room 4
load 0x3ffe8000, len 1332, room 12
tail 8
chksum 0x8a
load 0x3ffe8540, len 1708, room 0
tail 12
chksum 0x21
csum 0x21


As with the humidity reading I was getting earlier, that temp of 128.86 also corresponds to a read of all "1"s on the i2c bus. And now the watchdog reset happens when the attempt is made to measure the humidity.

Thanks for the suggestion, certeza, I will try adding your suggested delay next.