• Okay - so I tried a different tack. I had it do what I ultimately wanted it to do - wake on button, turn on wifi, send a GET request, turn off wifi and go to sleep. I had hoped to send the battery voltage with the GET request, but it looks like E.getBattery is only for the Pico.

    Is there a way to read the battery voltage level?

    I saved the code given below, and checked the power consumption - and low and behold - it appears to sleep at 0.64 mA !

    I am using a LiPo 3.7V 500mAh battery. I have it wired to the + and - terminal. Should I wire it to the 3.3V instead and skip the power regulator to possibly save power (hopefully without nuking the chip).

    I'm also ordering more Espruino's from Adafruit, as this is getting very exciting!

    Thanks,
    Narath

    
    var wifi = require("Wifi");
    var http = require("http");
    
    pinMode(A0, 'input_pulldown');
    
    var webhook_url = "WEBHOOK URL HERE";
    
    function wifiOff() {
      console.log("Trying to turn wifi off");
      wifi.disconnect();
      A13.read();
    }
    
    function wifiOn(callback) {
      console.log("Trying to turn wifi ON");
      wifi.connect("WIFI", {"password": "PASSWORD"},
                   function(ap){ 
        console.log("connected");
        callback();
      });
    }
    
    function get(url, done){
      console.log("GET");
      http.get(url, function(res) {
        res.on('data', function(data) {
          console.log("HTTP> "+data);
        });
        res.on('close', function(data) {
          console.log("Connection closed");
          done(data);
        });
      });
    }
    
    function onInit() {
      wifiOff();
    }
    
    setSleepIndicator(LED1);
    
    function doneClick(data) {
      console.log("Done! Go to sleep");
      wifiOff();
      setDeepSleep(1);
    }
    
    function sendClick() {
      console.log("Trying to connect");
      wifiOn(function(){
        get(webhook_url, doneClick);
      });
    }
    
    setWatch(function() {  
      sendClick();
    }, A0, {repeat: true, edge: 'rising', debounce: 10});
    
    setDeepSleep(1);
    
  • Thr 2020.03.05

    'I am using a LiPo 3.7V 500mAh battery. I have it wired to the + and - terminal. Should I wire it to the 3.3V instead and skip the power regulator to possibly save power (hopefully without nuking the chip).'

    I'll defer to @Gordon for the designer recommendation.

    LiPo and Lion have a tendancy to allow for a higher voltage when fully charged. I don't know if All the external parts have the same non 3V3 rating tolerance, protected by the regulator.

    IMO I wouldn't risk a $40 board without a definitive response from the designer, but what about a Buck 3V7 to 3V3 down converter? (I've orderd parts to make some test circuit current comparisons but the Corvid-19 has most of that delayed right now)


    '3.3 is a 3.3v output from the on-board Voltage regulator'

    The pin adjacent to B3 is an output.

    Note 'On-board 3.3v 250mA voltage regulator, accepts voltages from 3.5v to 5v' at:

    http://www.espruino.com/WiFi

    The schematic implies connections at VDD are 3V3

    https://github.com/espruino/EspruinoBoar­d/blob/master/WiFi/pdf/espruino_wifi_sch­.pdf


    'it appears to sleep at 0.64 mA'

    Your 0.64 vs 0.05

    'Current draw in sleep: < 0.05mA - over 2.5 years on a 2500mAh battery'
    http://www.espruino.com/WiFi

    Maybe time for that (0.05) test to be re-visited? or at least what the setup was then



    An Interesting read - regulator power consumption:

    Pixl and MDBT42Q deep sleep power figures?

    Post #15 thru post #17 answers the statement on floating pins I posed earlier in post #29 but for nRF devices and not STM devices, so not sure it would apply here with WiFi.

About

Avatar for narath @narath started