-
-
-
-
-
@jefure thank you very much I will look in to that this when my soil sensors arrive from eBay
-
Thank you @Jean-Philippe_Rey maybe I will! ;-)
-
-
-
-
-
@Jean-Philippe_Rey Hello how is it gooing with the chirp? Anyhing new? Can you provide a closeup on the chirp and the pico so i can do the same?
-
-
@Wilberforce thank you very much for the help. With a little googling and some other tutorials about the sensor in python I finally had success.
This is the code I used to get the correct values.
var currentSevice = false; function getData() { var gatt; NRF.connect("C4:7C:8D:62:0D:5A").then(function(g) { gatt = g; return gatt.getPrimaryService("00001204-0000-1000-8000-00805f9b34fb"); }) .then(function(service) { currentService = service; return service.getCharacteristic("00001a00-0000-1000-8000-00805f9b34fb"); }) .then(function(characteristic) { return characteristic.writeValue([0xa0, 0x1f]); }) .then(() => { return currentService.getCharacteristic("00001a01-0000-1000-8000-00805f9b34fb"); }) .then((characteristic) => { return characteristic.readValue(); }) .then(function(value) { console.log("temperature: ", value.getInt16(0, true)/10); console.log("Sunlight: ",value.getInt32(3,true)); console.log("Moister: ", value.getUint8(7,true)); console.log("Fertility: ", value.getUint16(8,true)); console.log(JSON.stringify(value.buffer)); gatt.disconnect(); console.log("Done!"); }) .catch(function(error){ console.log("error", error); }); } setWatch(function() { getData(); }, BTN, { repeat:true, edge:"rising", debounce:50 });
-
//In python temperature, sunlight, moisture, fertility = unpack('<hxIBHxxxxxx',data)
Format C Type Python type Standard size
h short integer 2
x pad byte no value
I unsigned int integer 4
B unsigned char integer 1
H unsigned short integer 2How can I do this with the ArrayBuffer in JavaScript?
var data = new ArrayBuffer([215, 0, 0, 208, 13, 0, 0, 20, 53, 1, 2, 60, 0, 251, 52, 155]); // 21.5 C, type h var temp = data[0]/10; // ~ 3500 lux, data[2],data[3],data[4], 0,208,13, type I //var sunlight = ? // 20 %, data[7], type B var moister = data[7]; // 315, data[8], data[9], type H //var fertility = ?
I wonder if there is an easy solution to this?
-
-
Finally some success
var currentSevice = false; function getData() { var gatt; NRF.connect("C4:7C:8D:62:0D:5A").then(function(g) { gatt = g; return gatt.getPrimaryService("00001204-0000-1000-8000-00805f9b34fb"); }) .then(function(service) { currentService = service; return service.getCharacteristic("00001a00-0000-1000-8000-00805f9b34fb"); }) .then(function(characteristic) { return characteristic.writeValue([0xa0, 0x1f]); }) .then(() => { return currentService.getCharacteristic("00001a01-0000-1000-8000-00805f9b34fb"); }) .then((characteristic) => { return characteristic.readValue(); }) .then(function(value) { console.log(value); gatt.disconnect(); console.log("Done!"); }) .catch(function(error){ console.log("error", error); }); } setWatch(function() { getData(); }, BTN, { repeat:true, edge:"rising", debounce:50 });
Output
DataView { "buffer": new ArrayBuffer([207, 0, 0, 209, 12, 0, 0, 24, 124, 1, 2, 60, 0, 251, 52, 155]) }
Next is to format the values but I save that for this weekend :)
-
@Gordon thanks. I will go through it step and try the things you mentioned. It sounds like it will work. Looks like I have something to tinker with this weekend to :)
-
-
Im trying to connect to a MI FlowerCare sensor. Im having a issue thoe.
function getData() { var gatt; NRF.connect("C4:7C:8D:61:FB:E0").then(function(g) { gatt = g; return gatt.getPrimaryService("00001204-0000-1000-8000-00805f9b34fb"); }).then(function(service) { return service.getCharacteristic("00001a01-0000-1000-8000-00805f9b34fb"); }).then(function(characteristic) { return characteristic.readValue(); }).then(function(value) { console.log(value); gatt.disconnect(); console.log("Done!"); }).catch(function(error){ console.log("error", error); }); } setWatch(function() { getData(); }, BTN, { repeat:true, edge:"rising", debounce:50 });
I get error disconnected it seems that the flower sensor gets disconnected (I get error disconnected) :) in order to save battery there is a automatic disconnect after like 2 secs. Is there something I can do? Is my code correct ? I got the values using the gatttool on a raspberry Pi. I also found some clues here: https://github.com/open-homeautomation/miflora/blob/master/miflora/miflora_poller.py, Any sudgestions?
-
@Gordon ok will do
-
Im trying to connect to a MI FlowerCare sensor. Im having a issue thoe.
function getData() { var gatt; NRF.connect("C4:7C:8D:61:FB:E0").then(function(g) { gatt = g; return gatt.getPrimaryService("00001204-0000-1000-8000-00805f9b34fb"); }).then(function(service) { return service.getCharacteristic("00001a01-0000-1000-8000-00805f9b34fb"); }).then(function(characteristic) { return characteristic.readValue(); }).then(function(value) { console.log(value); gatt.disconnect(); console.log("Done!"); }).catch(function(error){ console.log("error", error); }); } setWatch(function() { getData(); }, BTN, { repeat:true, edge:"rising", debounce:50 });
I get error disconnected it seems that the flower sensor gets disconnected (I get error disconnected) :) in order to save battery there is a automatic disconnect after like 2 secs. Is there something I can do? Is my code correct ? I got the values using the gatttool on a raspberry Pi. I also found some clues here: https://github.com/open-homeautomation/miflora/blob/master/miflora/miflora_poller.py, Any sudgestions?
(Update)
function getDevices() { var devices; NRF.findDevices(function(d) { devices = d; console.log(devices); }, 1000); } setWatch(function() { getDevices(); }, BTN, { repeat:true, edge:"rising", debounce:50 });
Outputs :::::::
Before watering
BluetoothDevice { "id": "c4:7c:8d:61:fb:e0 public", "rssi": -50, "services": [ "fe95" ], "data": new ArrayBuffer([2, 1, 6, 3, 2, 149, 254, 21, 22, 149, 254, 113, 2, 152, 0, 183, 224, 251, 97, 141, 124, 196, 13, 7, 16, 3, 0, 0, 0]) }
After watering
BluetoothDevice { "id": "c4:7c:8d:61:fb:e0 public", "rssi": -52, "services": [ "fe95" ], "data": new ArrayBuffer([2, 1, 6, 3, 2, 149, 254, 19, 22, 149, 254, 113, 2, 152, 0, 129, 224, 251, 97, 141, 124, 196, 13, 8, 16, 1, 67]) }
So now I'm wondering if I can get the moister value from the data ArrayBuffer?
-
-
@navas Well I ended up spending my hard earned money on a puck but I don't think I'm going to regret it. I figured that it would cover my user case. Thanks for the advice any way. :)
True that