Hi everyone,
I have been trying to log values using Arduino WiFi Shield. It is plugged into Arduino Mega.
I let it log for a few hours to check if it runs smoothly.
But after a few logs it just stops sending data. sometimes, it stop after 20 minutes and sometimes it stops after 4-5 hours. I can't identify the problem. Do you anyone have a solution or suggestion for this?
In the serial monitor no error message is displayed as well.
Thank you.
system
February 3, 2016, 1:09pm
2
The Arduino Wifi shield, with unknown firmware version number, is attached to an Arduino running some undefined code, powered some undefined way.
After some period of time, the behavior of the system changes.
You want us to tell you why. Hardly seems possible to me.
system
February 3, 2016, 1:24pm
3
That is NOT the way to post code! Use code tags.
Do NOT post code with big chunks commented out. Use the delete key to get rid of that crap.
The below are the codes. The arduino is connected to a 12V supply and the firmware version is 1.1.0.
#include <dht.h>
#include <SPI.h>
#include <WiFi.h>
#define dht_dpin A0
dht DHT;
char ssid[] = “mywifi”;
int status = WL_IDLE_STATUS;
char server[] = "api.pushingbox.com";
WiFiClient client; //define 'client' as object
boolean DEBUG= true;
void setup()
{
Serial.begin(9600);
while (!Serial) {
;
}
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv != "1.1.0") {
Serial.println("Please upgrade the firmware");
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to open SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid);
delay(10000);
}
Serial.print("You're connected to the network");
}
void loop()
{
DHT.read11(dht_dpin);
double temp = DHT.temperature;
double hum = DHT.humidity;
delay(5000);
Serial.println("connecting...");
if(temp>=30)
{
if (client.connect(server, 80))
{
logData();
delay(70);
DEBUG = true;
}
else
{
Serial.println("connection failed");
}
// loop
while(DEBUG)
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
if (!client.connected())
{
Serial.println();
Serial.println("disconnecting.");
Serial.print("Current temperature = ");
Serial.println(DHT.temperature);
Serial.print("Current humidity = ");
Serial.println(DHT.humidity);
client.stop();
DEBUG=false;
}
if (client.connect(server, 80))
{
sendtemptoPushBullet();
delay(70);
DEBUG=true;
}
while(DEBUG)
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
if(!client.connected())
{
Serial.println("disconnecting from pushbullet");
client.stop();
DEBUG=false;
}
}
}
}
else
{
if (client.connect(server, 80))
{
logData();
delay(70);
DEBUG = true;
}
else
{
Serial.println("connection failed");
}
// loop
while(DEBUG)
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
if (!client.connected())
{
Serial.println();
Serial.println("disconnecting.");
Serial.print("Current temperature = ");
Serial.println(DHT.temperature);
Serial.print("Current humidity = ");
Serial.println(DHT.humidity);
client.stop();
DEBUG=false;
}
}
}
if(hum>=90)
{
if(client.connect(server, 80))
{
sendhumtoPushBullet();
delay(70);
DEBUG=true;
}
while(DEBUG)
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
if(!client.connected())
{
Serial.println("disconnecting from pushbullet");
client.stop();
DEBUG=false;
}
}
}
delay(120000);
}
void logData()
{
double temp= DHT.temperature;
double hum = DHT.humidity;
delay(1000);
Serial.println("connected");
client.print("GET /pushingbox?devid=");
client.print(“mydeviceid”);
client.print("&tempData=");
client.print(temp);
client.print("&humData=");
client.print(hum);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("User-Agent: Arduino");
client.println();
}
void sendtemptoPushBullet()
{
Serial.print("Sending notification to pushbullet");
client.print("GET /pushingbox?devid=");
client.print(“mydeviceid”);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("User-Agent: Arduino");
client.println();
}
void sendhumtoPushBullet()
{
Serial.print("Sending notification to pushbullet");
client.print("GET /pushingbox?devid=");
client.print(“mydeviceid”);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("User-Agent: Arduino");
client.println();
}
Thank you.
Hi Surendhar,
Please note that there is a separate area of the forum which is dedicated to the ArduinoWifi Shield. This is not the right place to be posting your question. Please refer to the forum guidelines before posting.
Cheers,
William
Hi william,
Thanks for the info. Will post it in the arduino wifi shield page.
cheers,
Surendhar
No problem, Surendhar. Hope you find the answer.. this makes things easier for everyone!