You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • For loggers over longer periods, the power consumption - more precisely: waste - of the (sensor) peripherals becomes a great issue...

    For example: I want to have a GPS logger. The GPS module - for example, u-blox NEO 6 M - draws on start-up up to 67 mA, on average 47 mA, and in power-save mode STILL 11 mA... To survive a decent logging period, the GPS module has to be shut down completely, which means: de-powered.

    There are various options, of which the most efficient one is to use a MOSFET as switch. But there are also 'cheap' alternatives, of which one is using Espruino pin(s) to power the device. With suitable staging of power ahead of reading and writing to the peripheral, Espruino can go to sleep again and wait until the device has stabilized, or in case of the GPS, has acquired enough satellites (fix 1 or 2), before even considering processing data.

    Since an Espruino (STM32) pin can source up to 20 mA per pin and a 150 [mA] total per chip (EDIT on 2019-20-13: pin 25[ma], 120[ma] pins total, 160[ma] chip total - see this post), I gave it a try with 3 pins: PICO B7, B6, B5 set on "output" and jointly connected to the GPS module's VCC. With A4 I performed the analog read to see what is going on. Unfortunately, the voltage with 3 pins in parallel is not enough. It tanked to 2.5 V on start-up, but 2.7 V are needed, so I added one more pin - B4 - which brought it up just a tad above 2.7 V. Over time - when the GPS module has completed the hard work, it draws less power / current, and the voltage grows to 3.0..3.1 V. This project is a proof of concept. The optimal sequencing and staging of power on and power off for peripheral(s) and Espruino is not implemented yet.

    Interesting to this "project" is the fact that Espruio PICO monitores, measures and plots it's own power consumption over time in Espruino's testing feature! (Thank you, @JumJum). For enabling and using this feature see Espruino Web IDE settings and watch some "Youtube's". You will enjoy!


    W  | Espruino    | u-blox NEO 6M
    No | PICO        | adafruit bob
     1 | GND         | GND
     2 | B7,B6,B5,B4 | Vcc
     3 | A2          | TX
     4 | A3          | RX
     5 | A4          | Vcc


    // ePoweredGPS.js
    var eps = // espruino power supply
    //                               green LED2
    { _pwrPins: [ B7,  B6,  B5,  B4, B12 ]  
    , _pwr:        1 +  2 +  4 +  8 + 16
    , _voltPin: A4
    , _isOn: false
    , init: function() { this.isOn = false;
          p.reset(); pinMode(p,"output"); });
        pinMode(this._voltPin,"analog"); }
    , switch: function(b) { digitalWrite(this._pwrPins,
          (this._isOn = !!b) ? this._pwr: 0); }
    , getVolts: function() {
        var r = analogRead(this._voltPin);
        return Math.round(r * 3300) / 1000; }
    var gps = // GPS
    { _eps: null
    , _serial: Serial2
    , _gpsMod: require("GPS")
    , _isOn: false
    , _fix: 0
    , _sats: 0
    , _gps: null
    , init: function() { var _t = this;
        this._gps = this._gpsMod.connect(this._serial,
            _t._fix = d.fix;
            _t._sats = d.satellites;
      }); }
    , switch: function(b) { this._isOn = !!b;
        if (this._isOn) { this.init();
        } else { this._fix = this._sats = 0; } }
    gps._eps = eps;

    gps (singleton) object has a .switch(boolean) method to switch GPS on and off for true and false. Switching on and off includes switching on and off its Espruino Power Supply eps (with same named control method).

    1 Attachment

    • epsPoweredGPSshot.png

Avatar for allObjects @allObjects started