You are reading a single comment by @furuskog and its replies. Click here to read the full conversation.
  • 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(fu­nction(g) {
     gatt = g;
     return gatt.getPrimaryService("00001204-0000-10­00-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/m­iflora/blob/master/miflora/miflora_polle­r.py, Any sudgestions?

About

Avatar for furuskog @furuskog started