Hi I’m sure it’s me but I’ve got 2 imps measuring temp & temp + humidity both deep sleep for 5mins wake do an I2C read. Now and then I get a missed reading it’s as if the imp has slept before completing it’s reads and output port sets.This is happening on both imps with different code but is apparent in server logs and my cloud DB. Is it the wee sleep used I2C write-delay-read?
Also get diffrent sleep state log entries
Power state: online=>offline
Power state: online=>asleep (very occasionally preceded by sleeping until 1353860557000)
Sunday, November 25, 2012 15:51:58: Power state: offline=>online
Sunday, November 25, 2012 15:51:58: Device booting
Sunday, November 25, 2012 15:51:58: Device configured to be "Temp/Humidity v1.1"
Sunday, November 25, 2012 15:51:58: temp 16.4C humidity 72.9%
Sunday, November 25, 2012 15:51:58: Power state: online=>offline
// no reading
Sunday, November 25, 2012 15:57:04: Power state: offline=>online
Sunday, November 25, 2012 15:57:04: Device booting
Sunday, November 25, 2012 15:57:04: Device configured to be "Temp/Humidity v1.1"
Sunday, November 25, 2012 15:57:04: Power state: online=>offline
`// Temperature and Humidity Monitor using Honeywell HIH6130 sensor
hardware.configure(I2C_12);
local i2c = hardware.i2c12;
// Output to web service
local _wsOut = OutputPort(“wsOut”,“string”);
imp.configure(“Temp/Humidity v1.1”, [],[_wsOut]);
function getDateTime(){
local _iTime = date(time()).year + “-” + (date(time()).month+1) + “-” + date(time()).day + “T” + (date(time()).hour) + “:” + date(time()).min+ “:” + date(time()).sec;
return _iTime;
}
function getsample() {
// Start conversion
i2c.write(0x4e, “”);
// Wait at least 36ms
imp.sleep(0.05);
// Read out temperature and humidity, zero length subaddress means the write
// subaddr phase will be totally skipped and we’ll just do the read
local th = i2c.read(0x4e, “”, 4);
// Form temp and humidity
local temperature = ((((th[2] << 6 ) | (th[3] >> 2)) * 165) / 16383.0) - 40;
local humidity = ((((th[0] & 0x3F) << 8 ) | (th[1] )) / 163.83 );
// log and print
server.log(format(“temp %.1fC humidity %.1f%%”,temperature, humidity));
local tempOut=format("%.1f",temperature);
local _httpOut=“l|023|”+tempOut+"|"+getDateTime()+"|studyTemp2|C";
_wsOut.set(_httpOut);
local humOut=format("%.1f",humidity);
local _httpOut=“l|024|”+humOut+"|"+getDateTime()+"|studyHumidity|%";
_wsOut.set(_httpOut);
}
// Get a sample, then sleep
getsample();
imp.onidle(function() { server.sleepfor(300); });
`
Thanks
Lawrence