Photon Stuck in green breathing after uploading a new app. Initially appears to connect to the cloud and then disconnects. Looking for help in clearing the app to determine what went wrong. Believe I may have pushed the delay in my app a little too far.
// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"
// This #include statement was automatically added by the Particle IDE.
#include "PietteTech_DHT/PietteTech_DHT.h"
// system defines
#define DHTTYPE DHT22 // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPIN 2 // Digital pin for communications
#define DHT_SAMPLE_INTERVAL 60000 // Sample every minute
//declaration
void dht_wrapper(); // must be declared before the lib initialization
// Lib instantiate
PietteTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);
// globals
unsigned int DHTnextSampleTime; // Next time we want to start sample
bool bDHTstarted; // flag to indicate we started acquisition
int n; // counter
//this is coming from http://www.instructables.com/id/Datalogging-with-Spark-Core-Google-Drive/?ALLSTEPS
char resultstr[64]; //String to store the sensor data
//DANGER - DO NOT SHARE!!!!
char auth[] = ""; // Put your blynk token here
//DANGER - DO NOT SHARE!!!!
char VERSION[64] = "0.04";
#define READ_INTERVAL 60000
void setup()
{
Blynk.begin(auth);
DHTnextSampleTime = 0; // Start the first sample immediately
Particle.variable("result", resultstr, STRING);
Particle.publish("DHT22 - firmware version", VERSION, 60, PRIVATE);
}
// This wrapper is in charge of calling
// must be defined like this for the lib work
void dht_wrapper() {
DHT.isrCallback();
}
void loop()
{
Blynk.run(); // all the Blynk magic happens here
// Check if we need to start the next sample
if (millis() > DHTnextSampleTime) {
if (!bDHTstarted) { // start the sample
DHT.acquire();
bDHTstarted = true;
}
if (!DHT.acquiring()) { // has sample completed?
float temp = (float)DHT.getCelsius();
int temp1 = (temp - (int)temp) * 100;
char tempInChar[32];
sprintf(tempInChar,"%0d.%d", (int)temp, temp1);
Particle.publish("The temperature from the dht22 is:", tempInChar, 60, PRIVATE);
//virtual pin 1 will be the temperature
Blynk.virtualWrite(V1, tempInChar);
//google docs can get this variable
sprintf(resultstr, "{\"t\":%s}", tempInChar);
float humid = (float)DHT.getHumidity();
int humid1 = (humid - (int)humid) * 100;
sprintf(tempInChar,"%0d.%d", (int)humid, humid1);
Particle.publish("The humidity from the dht22 is:", tempInChar, 60, PRIVATE);
//virtual pin 2 will be the humidity
Blynk.virtualWrite(V2, tempInChar);
n++; // increment counter
bDHTstarted = false; // reset the sample flag so we can take another
DHTnextSampleTime = millis() + DHT_SAMPLE_INTERVAL; // set the time for next sample
}
}
}
One possible problem could be the Blynk.begin(auth) line. I tested that with no auth string or an incorrect auth string, and I got the breathing green after initially connecting. You should put some Serial print statements in a couple of places to see what parts of your code are executing.
After Edit:
I just found a DHT22 in my stuff, and I tested your code. It works fine for me with a proper auth code.
Maybe it gets stuck in some loop inside dht22 library and connectivity to the cloud is lost. I remember I faced something similar some time ago but I don’t remember where exactly.
At this point I’d just like to get the app off so I try again. How can I stop this app and get it to connect to the ide again so I can make some changes?