Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By burkmurray
#23603 There are a bunch of problems with I2C in the current release, many of which are cleared up in the staging package:

http://arduino.esp8266.com/staging/pack ... index.json

My accelerometer resets constantly with the current release, and works fine with the staging code. Might be worth a try. Just plug that URL into your board manager.

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


Probably not the problem. Even if your sensor is slow to refresh, the I2C read shouldn't take more than a few ms.
User avatar
By PaulRB
#23625
burkmurray wrote:There are a bunch of problems with I2C in the current release, many of which are cleared up in the staging package:

http://arduino.esp8266.com/staging/pack ... index.json

Well, with that installed, I'm now getting a different error:
Code: Select allHumidity(%RH): 118.99     Temperature(C):
ctx: cont
sp: 3ffe9bd0 end: 3ffe9dc0 offset: 01b0

>>>stack>>>
3ffe9d80:  3fffdc20 3ffe8cce 3ffe9e18 402025a4 
3ffe9d90:  3fffdc20 00000000 3ffe9e18 40202182 
3ffe9da0:  00000000 00000000 3ffe9de4 40201e9a 
3ffe9db0:  00000000 00000000 3ffe8da0 40100118 
<<<stack<<<

 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1464, room 16
tail 8
chksum 0x7a
csum 0x7a

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


Probably not the problem. Even if your sensor is slow to refresh, the I2C read shouldn't take more than a few ms.


Reading the code in the library I'm using, it sends a request for a reading (humid or temp) to the sht21, then hangs in an empty while loop until the correct number of bytes have been received back from the device. So the reading might take only ms, but the waiting could be longer.

Code: Select all/*
  SHT2x - A Humidity Library for Arduino.

  Supported Sensor modules:
    SHT21-Breakout Module - http://www.moderndevice.com/products/sht21-humidity-sensor
   SHT2x-Breakout Module - http://www.misenso.com/products/001
   
  Created by Christopher Ladden at Modern Device on December 2009.
  Modified by Paul Badger March 2010
 
  Modified by www.misenso.com on October 2011:
   - code optimisation
   - compatibility with Arduino 1.0

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <inttypes.h>
#include <Wire.h>
#include "Arduino.h"
#include "SHT2x.h"



/******************************************************************************
 * Global Functions
 ******************************************************************************/

/**********************************************************
 * GetHumidity
 *  Gets the current humidity from the sensor.
 *
 * @return float - The relative humidity in %RH
 **********************************************************/
float SHT2xClass::GetHumidity(void)
{
   return (-6.0 + 125.0 / 65536.0 * (float)(readSensor(eRHumidityHoldCmd)));
}

/**********************************************************
 * GetTemperature
 *  Gets the current temperature from the sensor.
 *
 * @return float - The temperature in Deg C
 **********************************************************/
float SHT2xClass::GetTemperature(void)
{
   return (-46.85 + 175.72 / 65536.0 * (float)(readSensor(eTempHoldCmd)));
}


/******************************************************************************
 * Private Functions
 ******************************************************************************/

uint16_t SHT2xClass::readSensor(uint8_t command)
{
    uint16_t result;

    Wire.beginTransmission(eSHT2xAddress);   //begin
    Wire.write(command);               //send the pointer location
    delay(100);
    Wire.endTransmission();                  //end

    Wire.requestFrom(eSHT2xAddress, 3);
    while(Wire.available() < 3) {
      ; //wait
    }

    //Store the result
    result = ((Wire.read()) << 8);
    result += Wire.read();
   result &= ~0x0003;   // clear two low bits (status bits)
    return result;
}

SHT2xClass SHT2x;


I have had this sensor and library working fine on Nano 3, and bare ATMega328 on breadboard, and now I come to remember, a Spark Core as well.

I wonder if ESP8266 will see the demise of the Spark Core, and its 'Particle' descendants...

Thanks for your attempts to assist so far.
User avatar
By PaulRB
#23628 I re-installed the original board manager from http://arduino.esp8266.com/package_esp8266com_index.json, and then I tried putting a delay(1) into the empty while loop:
Code: Select all    Wire.requestFrom(eSHT2xAddress, 3);
    while(Wire.available() < 3) {
      delay(1); //wait
    }

This seems to have cured the watchdog timer error. But now the program just hangs when SHT2x.GetTemperature() is called. Strange that SHT2x.GetHumidity() did not cause the watchdog timer error, or a hang.

However, that humidity value of 118.99 corresponds exactly to reading only "1"s over the i2c bus, so I suspect the bus just isn't working at all.