07-11-2016, 04:01 AM
(07-08-2016, 09:45 AM)Artyom Wrote:Bty, another info might be helpful is that the Temperature/Humidity sensor will do a I2c clock stretching when the host request to read the reading from the sensor. This is because the sensor require about 100~200ms to convert the reading to digital data. If you did not implement clock stretching in you I2c communication, you will receive the wrong reading.(07-07-2016, 09:13 PM)khgoh Wrote: Hi,Thanks for answer. But I already find solution...)))
Below is the program section taken from the WifiAppDemo. ( I will post the full source code later in the wiki page)
tmpH is the MSB and tmpL is the LSB of the temperature or humidity reading from the device, if current pClientProp->i2ccmdstep is under step3, the tmpvalue is humidity reading, or else is the temperature reading. The calculation is in the if-else loop.
tmpvalue=(double)(256*tmpH)+tmpL;
if (pClientProp->i2ccmdstep==step3)
{
//Humidity reading
pDrvHumidity->humidity=(float)(125*tmpvalue/65536)-6;
DMgr_RecNextStep(pClientProp,&DrvHumidity_refresh);
}
else {
//temperature reading
pDrvHumidity->temperature=(float)(175.72*tmpvalue/65536)-46.8;
pDrvHumidity->dataready=1;
DMgr_SendDone(pClientProp);
}
Just uploaded the full source code for the Wifi Remote I2c Server and the Demo App. The link in the wiki are,
http://wiki.pine64.org/index.php/Wifi_Re...c#Download
../KH Goh