Log in

View Full Version : need help on how to send new data



c_moore
- 23rd September 2012, 12:51
Hello everyone,

I have a project where I read temperature and send it to the pc. I have a app that takes the data and displays it. What I need to do is only send new data in other words if the temperature changes. as it is right now I send the temp. reading every 10 seconds. I think it would be better if I only sent the data when it changed. some psudo code would really be a big help. It seems simple, but I can't seem to wrap my head around it. Thanks.

HenrikOlsson
- 23rd September 2012, 13:31
Something like this perhaps.

Main:
GOSUB GetCurrentTemperature
If CurrentTemperature <> PreviouslySentValue THEN ' Compare new value to old measurment.
GOSUB SendNewData
ENDIF
Goto Main

SendNewData:
HSEROUT..... or whatever
PreviouslySentValue = CurrentTemperature ' Store value for comparison next sample
RETURN
On the other hand, it might be good to send occasionally even if the temperature doesn't change. That way you get kind of heartbeat from the transmitter so that the receiver knows its alive.

/Henrik.

c_moore
- 23rd September 2012, 14:20
Thanks Henrik,

I will give it a try.