Hello everyone,
I am trying to modify the Ruuvitag+ so that I can get all the reading of the weather station plus the status of a door using a door contact connected to the Ruuvitag. The intention is to use one set of those per room to monitor the room environment and window status throughout the house. I want this data to be forwarded as MQTT-messages so I can use this information in OpenHAB.
As I see it now I would like to send the following information:
- Temperature
- Humidity
- Pressure
- Battery
- Door/window status
I installed Espruino on the tag and I am able to read all the data except the door status (not looked into this yet) and print them to console.log. The following code works to some extent:
var Ruuvitag = require("Ruuvitag");
Ruuvitag.setEnvOn(true);
setInterval(function(fn){
var temperature = [Math.round(Ruuvitag.getEnvData().temp)];
var pressure = [Math.round(Ruuvitag.getEnvData().pressure)];
var humid = [Math.round(Ruuvitag.getEnvData().humidity)];
console.log("Temperature: " + temperature);
console.log("Pressure: " + pressure);
console.log("Humidity: " + humid);
console.log("Battery [V]: " + NRF.getBattery());
NRF.setAdvertising({
0x1809 : temperature,
0x2A6F : humid,
0x2A6D : pressure
});
},10000);
From Espruinohub on my Raspberry Pi 3 I can see that it receives data:
e4:12:a1:06:c9:01 - RuuviTag c9 (RSSI -84)
1809 => {“temp”:24}
2a6f => {“type”:“Buffer”,“data”:[55]}
2a6d => {“type”:“Buffer”,“data”:[2]}
For the temperature it creates a MQTT-message with the topic “/ble/temp/
e4:12:a1:06:c9:01” and the payload “24”. For the other data nothing is sent. So I know the transmission is working and the problem is with the advertising of the data.
Can anyone advise me on how to do the.setAdvertising correct for those data?
I tried to read on BLE UUID etc. and found some information but was not able to send the data in the correct format. One thing I tried was this (testing with the temperature since this was working with the above code):
NRF.setAdvertising({
0x1809 : { // Health Thermometer
0x2A6E: {value : [E.getTemperature().toFixed(2)]}
},
});
},10000);
But this produces already on the console the following warning:
Uncaught TypeError: If specifying an object, it must be of the form {data : ..., count : N} - got {
"10862": [ 24 ]
}
at line 38 col 3
});
Any help is appreciated.