Hi,
I have bought a Linkit one and the Grove Starter Kit for Linkit one. In my sketch I am using the Barometer Sensor and the Temperature Humidity Pro. I read their values and send them via wifi to pubnub.
The problem is that the Temperature Humidity Pro is very unreliable. I often get no value for temperature and humidity and I don’t know why?
When I use the example sketch from the Grove Linkit One Starter package the sensor works fine.
My loop:
[code]void loop()
{
temperature = myBarometer.bmp085GetTemperature(myBarometer.bmp085ReadUT()); //Get the temperature, bmp085ReadUT MUST be called first
pressure = myBarometer.bmp085GetPressure(myBarometer.bmp085ReadUP());//Get the temperature
altitude = myBarometer.calcAltitude(pressure); //Uncompensated caculation - in Meters
atm = pressure / 101325;
Serial.print("Temperature: ");
Serial.print(temperature, 2); //display 2 decimal places
Serial.println("deg C");
Serial.print("Pressure: ");
Serial.print(pressure, 0); //whole number only.
Serial.println(" Pa");
Serial.print("Ralated Atmosphere: ");
Serial.println(atm, 4); //display 4 decimal places
Serial.print("Altitude: ");
Serial.print(altitude, 2); //display 2 decimal places
Serial.println(" m");
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float t = 0.0;
float h = 0.0;
if(dht.readHT(&t, &h))
{
Serial.print("temperature = ");
Serial.println(t);
Serial.print("humidity = ");
Serial.println(h);
}
String upload_Wifi = "[{\"values\":[" + String(temperature) + "," + String(pressure)+ "," + String(altitude)+ "," + String(atm)+ "," + String(t)+ "," + String(h)+ "], \"data\":\"hello1\"}]";
const char* upload_char = upload_Wifi.c_str();
LWiFiClient *client;
client = PubNub.publish(channel, upload_char, 60);
if (!client) {
Serial.println("publishing error");
delay(1000);
return;
}
while (client->connected()) {
while (client->connected() && !client->available()); // wait
char c = client->read();
Serial.print(c);
}
client->stop();
Serial.println();
delay(60000L);
}[/code]
I would be very grateful if you could help me!