Close

Got it working better

A project log for HouseRemote

Remotely monitor and control appliances from anywhere!

mcunerdmcu_nerd 05/13/2015 at 19:410 Comments

Well I did find a work-around to the issue by adding the following lines after the results of the photoresistor and temperature are sent to clear the incoming serial buffer (a delay was also needed):

delay(250);
while(Serial.available())
  Serial.read();

When I tried things on my Raspberry Pi, the above fix worked but I was still having issues with not getting a response message/data at times. The work-around was putting the the serial interaction in a while loop until I finally get the return data:

if (isset($_POST['button1']))
{
while( empty($read)){
$serial->deviceOpen();
$serial->sendMessage("9");
//usleep(200000);
$read = $serial->readPort();
$serial->deviceClose();
}
}

A side-effect of this work-around is a slightly longer wait to get something such as a temperature value.

Discussions