Hello, Feed stops about once a week, requiring me to sign out and then sign in to get it working.
The blue dashes across the top turn red. Is this normal or is there something I can do ?
Thanks Much, T
Stops approximately once a week
Re: Stops approximately once a week
Re: Stops approximately once a week
Re: Stops approximately once a week
Re: Stops approximately once a week
tj1 wrote:answered questions two months ago. no reply ?
Re: Stops approximately once a week
[code]
/***************************************************
Adafruit ESP8266 Sensor Module
Must use ESP8266 Arduino from:
https://github.com/esp8266/Arduino
Works great with Adafruit's Huzzah ESP board:
----> https://www.adafruit.com/product/2471
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Tony DiCola for Adafruit Industries.
MIT license, all text above must be included in any redistribution
****************************************************/
// Libraries
#include "ESP8266WiFi.h"
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
#include "DHT.h"
// DHT 22 sensor
#define DHTPIN_IN 5
#define DHTPIN_OUT 4
#define DHTTYPE_IN DHT22
#define DHTTYPE_OUT DHT22
// WiFi parameters
#define WLAN_SSID "*********"
#define WLAN_PASS "***************"
// Adafruit IO
#define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883
#define AIO_USERNAME "tj1"
#define AIO_KEY "76060e2caa594895982dae3c8e4db024"
// DHT sensor
DHT dht_IN(DHTPIN_IN, DHTTYPE_IN, 15);
DHT dht_OUT(DHTPIN_OUT, DHTTYPE_OUT, 22);
// Functions
void connect();
// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;
// Store the MQTT server, client ID, username, and password in flash memory.
const char MQTT_SERVER[] PROGMEM = AIO_SERVER;
// Set a unique MQTT client ID using the AIO key + the date and time the sketch
// was compiled (so this should be unique across multiple devices for a user,
// alternatively you can manually set this to a GUID or other random value).
//
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
//****************************** Feeds ***************************************/
// Setup feeds for temperature & humidity
Adafruit_MQTT_Publish temperature_IN = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/Temperature_IN");
Adafruit_MQTT_Publish humidity_IN = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/Humidity_IN");
Adafruit_MQTT_Publish temperature_OUT = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/Temperature_OUT");
Adafruit_MQTT_Publish humidity_OUT = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/Humidity_OUT");
/*************************** Sketch Code ************************************/
void setup() {
// Init sensor
dht_IN.begin();
dht_OUT.begin();
Serial.begin(115200);
Serial.println(F("Adafruit IO Example"));
// Connect to WiFi access point.
Serial.println(); Serial.println();
delay(10);
Serial.print(F("Connecting to "));
Serial.println(WLAN_SSID);
WiFi.begin(WLAN_SSID, WLAN_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(F("."));
}
Serial.println();
Serial.println(F("WiFi connected"));
Serial.println(F("IP address: "));
Serial.println(WiFi.localIP());
// connect to adafruit io
connect();
}
void loop() {
// ping adafruit io a few times to make sure we remain connected
if(! mqtt.ping(3)) {
// reconnect to adafruit io
if(! mqtt.connected())
connect();
}
// Grab the current state of the sensor
int humidity_IN_data = (int)dht_IN.readHumidity();
int temperature_IN_data = (int)dht_IN.readTemperature ();
// ///////////////////////////////////////////////
// Grab the current state of the sensor
int humidity_OUT_data = (int)dht_OUT.readHumidity();
int temperature_OUT_data = (int)dht_OUT.readTemperature ();
// ////////////////////////////////////////////////
// Publish data
if (! temperature_IN.publish(temperature_IN_data * 1.8 +32))
Serial.println(F("Failed to publish temperature IN"));
else
Serial.println(F("Temperature IN published!"));
if (! humidity_IN.publish(humidity_IN_data))
Serial.println(F("Failed to publish humidity"));
else
Serial.println(F("Humidity IN published!"));
//delay (5000);
// /////////////////////////////////////////////////////////
// Publish data
if (! temperature_OUT.publish(temperature_OUT_data * 1.8 +32))
Serial.println(F("Failed to publish temperature OUT"));
else
Serial.println(F("Temperature OUT published!"));
if (! humidity_OUT.publish(humidity_OUT_data))
Serial.println(F("Failed to publish humidity OUT"));
else
Serial.println(F("Humidity OUT published!"));
// /////////////////////////////////////////////////////////////
// Repeat every 1000 seconds (16.6 min.)
delay(1000000);
}
// connect to adafruit io via MQTT
void connect() {
Serial.print(F("Connecting to Adafruit IO... "));
int8_t ret;
while ((ret = mqtt.connect()) != 0) {
switch (ret) {
case 1: Serial.println(F("Wrong protocol")); break;
case 2: Serial.println(F("ID rejected")); break;
case 3: Serial.println(F("Server unavail")); break;
case 4: Serial.println(F("Bad user/pass")); break;
case 5: Serial.println(F("Not authed")); break;
case 6: Serial.println(F("Failed to subscribe")); break;
default: Serial.println(F("Connection failed")); break;
}
if(ret >= 0)
mqtt.disconnect();
Serial.println(F("Retrying connection..."));
delay(5000);
}
Serial.println(F("Adafruit IO Connected!"));
}
[/code]
Re: Stops approximately once a week
// Repeat every 1000 seconds (16.6 min.)
delay(1000000);
// ping adafruit io a few times to make sure we remain connected
if(! mqtt.ping(3)) {
// reconnect to adafruit io
if(! mqtt.connected())
connect();
}
Re: Stops approximately once a week