Adafruit ATHX0 module crashes ESP8266S

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
kereme
 
Posts: 6
Joined: Thu Jun 06, 2013 10:40 am

Adafruit ATHX0 module crashes ESP8266S

Post by kereme »

I built an arduino system around the ATHX0 and 0.91" OLED module. The code runs on arduino Uno. I tried to port it to ESP01S somehow the ATHX0 code causes the arduino to crashdump.

Heres the output:

Code: Select all

14:10:38.319 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
14:10:38.319 -> 
14:10:38.319 -> Soft WDT reset
14:10:38.319 -> 
14:10:38.319 -> >>>stack>>>
14:10:38.319 -> 
14:10:38.319 -> ctx: cont
14:10:38.319 -> sp: 3ffffdf0 end: 3fffffd0 offset: 01a0
14:10:38.319 -> 3fffff90:  3fffdad0 0000001c 3ffee690 40201bf4  
14:10:38.352 -> 3fffffa0:  3fffdad0 00000000 3ffee690 40201069  
14:10:38.352 -> 3fffffb0:  feefeffe feefeffe 3ffee6e4 40202268  
14:10:38.352 -> 3fffffc0:  feefeffe feefeffe 3fffdab0 40101001
14:10:38.352 -> <<<stack<<<
14:10:38.352 -> 
14:10:38.352 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
14:10:38.385 -> 
14:10:38.385 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
14:10:38.385 -> 
14:10:38.385 -> load 0x4010f000, len 3424, room 16 
14:10:38.385 -> tail 0
14:10:38.385 -> chksum 0x2e
14:10:38.385 -> load 0x3fff20b8, len 40, room 8 
14:10:38.385 -> tail 0
14:10:38.385 -> chksum 0x2b
14:10:38.425 -> csum 0x2b
14:10:38.425 -> v000435d0
14:10:38.425 -> ~ld

User avatar
kereme
 
Posts: 6
Joined: Thu Jun 06, 2013 10:40 am

Re: Adafruit ATHX0 module crashes ESP8266S

Post by kereme »

This is about WDT. I believe the library for ATH causing the trigger of WDT. Is there a way to prevent this?

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Adafruit ATHX0 module crashes ESP8266S

Post by adafruit_support_carter »

Are you using this Arduino library?
https://github.com/adafruit/Adafruit_AHTX0

And if so, are you seeing the same WDT issue running one of the examples from the library?
https://github.com/adafruit/Adafruit_AH ... r/examples

User avatar
kereme
 
Posts: 6
Joined: Thu Jun 06, 2013 10:40 am

Re: Adafruit ATHX0 module crashes ESP8266S

Post by kereme »

Hello,

Thanks for the reply. Yes I tired to use both AHT10 and AHTX0 libraries from adafruit. but I get the exact same result with both. My research online led me to believe that the difference with Arduino UNO and ESP01s is the latter has a built-in WDT I believe it is causing the problem. As I told earlier the same code works on arduino UNO.

Heres my code:

Code: Select all

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#include <Adafruit_AHT10.h>

Adafruit_AHT10 aht;

void dispdrawchar(String tempStr, String hmdStr) {
  display.clearDisplay();

  display.setTextSize(2);      // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE); // Draw white text
  display.setCursor(0, 0);     // Start at top-left corner
  display.print("Tm:" + tempStr + " " + char(247)+"C");
  display.setCursor(0, 18);  
  display.print("rH:" + hmdStr + " %");
  display.display();
}

void setup() {
  Serial.begin(115200);
  delay(4000);
  Serial.println("Prog Started");
  
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  Serial.println("SSD1306 initialized");  

  if (! aht.begin()) {
    Serial.println("Could not find AHT10? Check wiring");
    while (1) delay(10);
  }
  Serial.println("AHT10 found");
}

void loop() {
  sensors_event_t humidity, temp;
  aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data  
  Serial.print("Temperature: "); Serial.print(temp.temperature,1); Serial.println(" degrees C");
  int rcvTemp=round(temp.temperature*10);
  Serial.print("Humidity: "); Serial.print(humidity.relative_humidity,0); Serial.println("% rH");
  dispdrawchar (String(rcvTemp/10)+"."+String(rcvTemp%10), String(round(humidity.relative_humidity)));
  delay(500);
}

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Adafruit ATHX0 module crashes ESP8266S

Post by adafruit_support_carter »

Can you link to the product page for the specific sensor being used.

Are you using the latest release of the Arduino library? There is no file named Adafruit_AHT10.h:

Code: Select all

#include <Adafruit_AHT10.h>
in the latest release:
https://github.com/adafruit/Adafruit_AHTX0

User avatar
kereme
 
Posts: 6
Joined: Thu Jun 06, 2013 10:40 am

Re: Adafruit ATHX0 module crashes ESP8266S

Post by kereme »

Hi,

I tried to run the sample code. First I needed to add a delay(2000) before the first Serial.println because ESP8266 uses TX/RX in combination with GPIO ports. Soif I do not add the delay loop I cannot get any output.

Then I printed SCL and SDA they output 4 and 5 which causes the device cannot communicate with AHT10. Although I modified them inside the code the adafruit library disregards it. How can I set the parameters for SDA SCL pins?

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Adafruit ATHX0 module crashes ESP8266S

Post by adafruit_support_carter »

The SDA and SCL pins are set in the ESP8266 Board Support Package specific to your board. They are not set in the library.

None of the examples in the current library release show this:

Code: Select all

#include <Adafruit_AHT10.h>
so it's not clear what library (or version) you are using.

User avatar
kereme
 
Posts: 6
Joined: Thu Jun 06, 2013 10:40 am

Re: Adafruit ATHX0 module crashes ESP8266S

Post by kereme »

Hello,

The code is working. When AHT10 is reachable there is no problem. But if it is not attached I get the WDT error.
Heres the entire code:

Code: Select all

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_AHTX0.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

Adafruit_AHTX0 aht;


void setup() {
  pinMode(LED_BUILTIN, OUTPUT);  
  Serial.begin(115200);
  delay (4000);
  Wire.begin (2,0);
  while (!Serial) {
    ; // wait for serial port to connect
    
  }
  Serial.println("ESP01-t/h-V1.00i"); 
  if (!aht.begin()) {
    Serial.println("Could not find AHT10 sensor!");
    while (1);{
      delay(1000);
      digitalWrite(LED_BUILTIN, LOW); 
      delay(1000);
      digitalWrite(LED_BUILTIN, HIGH);    
      Serial.println("X AHT10");
    }
  }
  
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  display.setBrightness(128);  
  
  display.clearDisplay();
  display.display();
  
}

void loop() {
  sensors_event_t humidity, temp;
  int tempi, rheli;
  aht.getEvent(&humidity, &temp);

  // Print to serial port
  Serial.print("Temperature: ");
  Serial.print(temp.temperature);
  Serial.print(" ");
  Serial.print(char(247)); 
  Serial.print("C | Humidity: ");
  Serial.print(humidity.relative_humidity);
  Serial.println(" %");
  

  // Display on OLED
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  tempi = round(temp.temperature*10);
  display.print("Tm:" + String(tempi/10)+"."+String(tempi%10)+" "+char(247)+"C");
  display.setCursor(0,18);
  rheli = round(humidity.relative_humidity); 
  display.print("rH:"); 
  display.print(rheli,1);
  display.print(" %");
  display.display();

  delay(2000); // wait a few seconds between readings
}



Here is the code snippet where the code crashes. It should keep blinking the LED if AHT10 is not accessible.

Code: Select all

 if (!aht.begin()) {
    Serial.println("Could not find AHT10 sensor!");
    while (1);{
      delay(1000);
      digitalWrite(LED_BUILTIN, LOW); 
      delay(1000);
      digitalWrite(LED_BUILTIN, HIGH);    
      Serial.println("X AHT10");
    }
  }
  
But I only get the output of the first line. Then WDT kicks in and all I get is WDT crashes and starts to send crashdump:

Code: Select all

Could not find AHT10 sensor!

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Soft WDT reset

>>>stack>>>

ctx: cont
sp: 3ffffdf0 end: 3fffffc0 offset: 01a0
3fffff90:  3fffdad0 3ffee5b8 3ffee6f4 40201091  
3fffffa0:  feefeffe 00000000 3ffee748 40203af4  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

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

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v000460d0
~ld


User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Adafruit ATHX0 module crashes ESP8266S

Post by adafruit_support_carter »

Remove the ; here:

Code: Select all

    while (1);{

User avatar
kereme
 
Posts: 6
Joined: Thu Jun 06, 2013 10:40 am

Re: Adafruit ATHX0 module crashes ESP8266S

Post by kereme »

ooops! My bad thanks.. Arduino uno and ESP01 was not that different after all. I was causing the WDT not the library.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”