You are reading a single comment by @furuskog and its replies. Click here to read the full conversation.
  • Im trying to broadcast ble data with the esp32. But its not implemented yet the console informs me. Didnt you guys say it worked now?

    var high = 0.5;
    var low = 0.0;
    
    function map_value(val, in_min, in_max, out_min, out_max){
      var result = (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
      
      if(result < out_min) {
        return out_min;  
      } 
      else if(result > out_max) {
        return out_max;
      }
      
      return result;
    }
    
    function onTimer() {
      var h = analogRead(D35);
      var hp = map_value(h, low, high, 0, 100);
      var percentage = hp.toFixed(0)+"%";
      
      NRF.setServices({
        0xBCDE : {
          0xABCD : {
            value : percentage,
            readable : true
          }
        }
      });
      console.log("Soil moister", percentage);
    }
    
    // Update soil moister every 2 seconds
    setInterval(onTimer, 2000);
    // Update soil moister immediately
    onTimer();
    

    Console

    
    Soil moister 0%
    WARNING: has connected not implemented yet
    
    
About

Avatar for furuskog @furuskog started