0

Intermittent stalling of code
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Intermittent stalling of code

by RedSafety on Mon Feb 04, 2019 12:43 pm

Hi,
The following code (See “My Sketch” below) will run for hours with no problems then it will halt for no external reason.
Checking via the serial monitor you can see via log sheet below between 17:30:27 and 17:30:30 the code completes OK but next time it is triggered (17:35:30) the programme stalls, I am presuming during wait for connection, signified by the printing of full stops until I remove power to my ESP32. When power is reconnected it will work OK for another unspecified length of time before stalling again.
As you can see I have used your Deepsleep example as the bases of my “sketch”.
FYI, the above problem has happen on two different ESP32 configurations.
Could you please advise how to resolve this issue?

Best regards

Log sheet
17:30:27.044 -> rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
17:30:27.044 -> configsip: 0, SPIWP:0xee
17:30:27.044 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
17:30:27.044 -> mode:DIO, clock div:1
17:30:27.044 -> load:0x3fff0018,len:4
17:30:27.044 -> load:0x3fff001c,len:952
17:30:27.044 -> load:0x40078000,len:6084
17:30:27.044 -> load:0x40080000,len:7936
17:30:27.044 -> entry 0x40080310
17:30:27.317 -> Adafruit IO Environmental Logger
17:30:27.351 -> Connecting to Adafruit IO...
17:30:27.351 -> AdafruitIO::connect()
17:30:27.624 -> ...
17:30:30.554 -> Adafruit IO connected.
17:30:30.656 -> Reading Sensors...
17:30:30.692 -> Air: 23.00(C)
17:30:30.692 -> 10CM: 22.75(C)
17:30:30.725 -> 30CM: 22.62(C)
17:30:30.760 -> sending value to feed
17:30:30.760 -> Setup ESP32 to sleep for every 300 Seconds
17:30:30.760 -> Going to sleep now

17:35:30.245 -> ets Jun 8 2016 00:22:57
17:35:30.245 ->
17:35:30.245 -> rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
17:35:30.245 -> configsip: 0, SPIWP:0xee
17:35:30.245 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
17:35:30.245 -> mode:DIO, clock div:1
17:35:30.245 -> load:0x3fff0018,len:4
17:35:30.245 -> load:0x3fff001c,len:952
17:35:30.245 -> load:0x40078000,len:6084
17:35:30.245 -> load:0x40080000,len:7936
17:35:30.245 -> entry 0x40080310
17:35:30.519 -> Adafruit IO Environmental Logger
17:35:30.554 -> Connecting to Adafruit IO...
17:35:30.554 -> AdafruitIO::connect()
17:35:30.760 -> ......................................... repeated until turned off……..

My “Sketch”.
// Adafruit IO Environmental Data Logger
// Tutorial Link: https://learn.adafruit.com/adafruit-io- ... ty-monitor
//
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
//
// Written by Brent Rubell for Adafruit Industries
// Copyright (c) 2018 Adafruit Industries
// Licensed under the MIT license.
//
// All text above must be included in any redistribution.

/************************** Adafruit IO Configuration ***********************************/

// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"

/**************************** Sensor Configuration ***************************************/
// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP 300 /* Time ESP32 will go to sleep (in seconds) */

// Data wire is connected to GPIO15
#define ONE_WIRE_BUS 15
// Setup a oneWire instance to communicate with a OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);


DeviceAddress AirSensor = { 0x28, 0xC8, 0xCD, 0x83, 0x1E, 0x13, 0x1, 0xE6 };
DeviceAddress SensorCm10 = { 0x28, 0x3F, 0x84, 0xE6, 0x1A, 0x13, 0x1, 0x84 };
DeviceAddress SensorCm30 = { 0x28, 0xAA, 0xDD, 0x8D, 0x13, 0x13, 0x2, 0xD0 };
/**************************** ***************************************/
// Delay between sensor reads, in seconds
#define READ_DELAY 10

float AirData;
float DataCm10;
float DataCm30;
/**************************** Setup ***************************************/
void setup() {
// start the serial connection
Serial.begin(115200);

// wait for serial monitor to open
while (!Serial);

Serial.println("Adafruit IO Environmental Logger");
sensors.begin();
sensors.setResolution(AirSensor, 11);

/**************************** Calls***************************************/

// connect to the Adafruit IO Library
connectAIO();

//DS18B20 Sensor code
SensorCode();

// set up and write to deepsleep feed
feedWrite();


/**************************** Sleep***************************************/


/*
wake up source

*/
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) +
" Seconds");
Serial.println("Going to sleep now");
delay(1000);
esp_deep_sleep_start();
Serial.println("This will never be printed");
}

/****************************LOOP NOT USED ***************************************/
void loop() {

}

/**************************** S1 ***************************************/

void connectAIO() {
Serial.println("Connecting to Adafruit IO...");
io.connect();

// wait for a connection
while (io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}

// we are connected
Serial.println();
Serial.println(io.statusText());

}
/**************************** S2 ***************************************/
void feedWrite(){


AdafruitIO_Feed *AirS = io.feed("airs");
AdafruitIO_Feed *SCM10 = io.feed("scm10");
AdafruitIO_Feed *SCM30 = io.feed("scm30");
Serial.println("sending value to feed");

// send data to feed
AirS->save(AirData, 0, 0, 0, 1);
SCM10->save(DataCm10, 0, 0, 0, 1);
SCM30->save(DataCm30, 0, 0, 0, 1);
// write data to AIO
io.run();
}
/**************************** DS18B20***************************************/
void SensorCode(){
Serial.println("Reading Sensors...");
//Serial.print("Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
//Serial.println("DONE");
/**************************** Air***************************************/
Serial.print("Air: ");
Serial.print(sensors.getTempC(AirSensor));
Serial.println("(C) ");

AirData = sensors.getTempC(AirSensor);
/**************************** 10CM***************************************/
Serial.print("10CM: ");
Serial.print(sensors.getTempC(SensorCm10));
Serial.println("(C) ");

DataCm10 = sensors.getTempC(SensorCm10);
/**************************** 30CM***************************************/
Serial.print("30CM: ");
Serial.print(sensors.getTempC(SensorCm30));
Serial.println("(C) ");

DataCm30 = sensors.getTempC(SensorCm30);
}

RedSafety
 
Posts: 13
Joined: Mon Jan 14, 2019 4:26 pm

Please be positive and constructive with your questions and comments.