I'm not sure I've seen anything specific, but I guess you have three options:
Have the temperature Puck advertise its temperature, and have the second one occasionally wake up and listen
Have the receiver Puck connect and request information from the temperature Puck
Have the temperature Puck connect and 'push' data to the receiver Puck
I think either of those solutions works fine, although the first option might be easier to debug and also is probably more power efficient - especially for the sensor puck that you can't get to.
var currentTemp = 0;
function getTemp() {
NRF.findDevices(function(devices) {
var found = false;
for (var i in devices) {
if (devices[i].name!="Puck.js e782") continue;
var d = E.toString(devices[i].data);
// index of 0x1809 in advertised data
var idx = d.indexOf(String.fromCharCode(0x09,0x18));
if (idx>=0) {
currentTemp = d.charCodeAt(idx+2);
found = true;
}
}
if (found)
digitalPulse(LED2,1,50); // green = good
else
digitalPulse(LED1,1,50); // red = bad
}, 2000 /* receive for 2000ms */);
}
// look once a minute for temperature
setInterval(getTemp, 60000);
Right now it flashes green for 'got temperature' and red for 'unable to read temperature' - so it doesn't do anything with the temperature value, but it's easy enough to change.
The receiver won't be super power efficient, as it's listening for 2 seconds every 60 seconds. It should still last quite a while on a battery though.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I'm not sure I've seen anything specific, but I guess you have three options:
I think either of those solutions works fine, although the first option might be easier to debug and also is probably more power efficient - especially for the sensor puck that you can't get to.
As an example of the first idea:
Sensor:
Receiver:
Right now it flashes green for 'got temperature' and red for 'unable to read temperature' - so it doesn't do anything with the temperature value, but it's easy enough to change.
The receiver won't be super power efficient, as it's listening for 2 seconds every 60 seconds. It should still last quite a while on a battery though.