Hello, I am using MKR1000, The device send only twice to the platform and stops,
I am uploading the values of DHT11 sensor.
THE CODE:
#include <UbidotsArduino.h>
# include <SPI.h>
# include <WiFi101.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
#define ID "ID-variable" //variable ID
#define TOKEN "TOKEN" // Profile Token
char ssid[] = "NAME" ; //wifiname
char pass[] = "PASSWORD" ; //wifipass
int status = WL_IDLE_STATUS;
Ubidots client(TOKEN);
void setup(){
Serial.begin(9600);
Serial.println("DHTxx test!");
dht.begin();
while (status != WL_CONNECTED){
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
delayMicroseconds(500); //wait
}
}
void loop(){
// Wait a few seconds between measurements.
delay(1500);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hic);
Serial.print(" *C ");
Serial.print(hif);
Serial.println(" *F");
client.add(ID, h);
client.sendAll();
}