• I want to control the power for a display with using an electronic switch.

    what i know / want to do:

    • Espruino is powered by a CR2032 coin cell (3v, 230mAh) at BAT_IN and GND
    • i want to use a GPIO to control the power of the display connected to VBAT and GND
    • the display works from 1,9v - 3,3v and uses 8mA current
    • i can't use the GPIO alone to drive the display, there is not enough current when using the battery (direct use of VBAT works), actually i will measure it this evening, it works when the Espruino is driven via USB

    so far i am just searching and learning (i have absolutely no idea of electronics and it is a wide field for a beginner) and as far as i understand a NPN mosfet would fit here, the big question is - which one should i choose or is there a better way to switch the power for the display?

  • Well, a GPIO line should really be good enough. Could it perhaps be a timing issue, as displays often need a few msec after being powered on before they're ready?

    You've also got to be careful that you don't power them up via their IO lines first (eg, if you init SPI beforehand)

    I think you actually want a P channel mosfet (which pull the voltage 'up' to 3.3v when the gate is pulled down) - but hopefully you don't need that and it's some other problem :)

  • Is that the correct connection for a coin cell? Shouldn't a coin cell that will never go above 3.3v be connected to the 3.3v rail directly, to spare you from the regulator dropout?

  • Shouldn't a coin cell that will never go above 3.3v be connected to the 3.3v rail directly, to spare you from the regulator dropout?

    Good point - if you're sure it'll never go above 3.3, and you're not planning on having it in while USB is plugged in then yes - and it should save you 0.3v or so.

  • ...I'm sure you have looked at GPS powered by Espruino pin(s).

  • Could it perhaps be a timing issue, as displays often need a few msec
    after being powered on before they're ready?

    checked that and upped the waiting times, had no success

    You've also got to be careful that you don't power them up via their
    IO lines first (eg, if you init SPI beforehand)

    thanks for the tip, changed the code

    Shouldn't a coin cell that will never go above 3.3v be connected to
    the 3.3v rail directly

    the coin cell shall power the Espruino Pico and the display as well, i am not sure about this 3.3v rail, what do you mean?

    ...I'm sure you have looked at GPS powered by Espruino pin(s).

    thx for the link, i am not sure that is the problem here, as one pin should be more than enough
    but that kept me thinking, the display needs 8 pins for proper operation (SPI Clock and MOSI, and 6 more pins for e.g. chipselect)

    maybe the lot of pins draw too much current so the direct connection to VBAT is needed? is there enough voltage?

    ok i used a multimeter - was my first time btw, it seems more of a problem with voltage, the whole circuit is around 2,3v, but the typical operation voltage for the display goes from min. 2,4v to 3,3v

  • You have the power suply pin and you have the control/signal/data exchange pins. Latter are not a power draw issue as long as you do not add extra load - such as 'low' value resistors from display output pins, for example, MISO, to ground.

    @Gordon thus mentioned that the control lines - (output) pins from Espruino to connected to display - should not power the display while power is off. Therfore, when powering up espruino and initializing AND before powering down the display,, these pins have all to be set input float ("input"). Only AFTER display is powered up, pins and communication - SPI - can be initialized and set.

    Note that for proper working, signal lines do not need to go up to voltage supplied to display, but (certainly) should not be higher (otherwise they will power the display in one way or the other, or at least, try to...). The signal lines have only to reach a high or low as input specs with given supply voltage are specified, and that's true for both Espruino and display.

  • the coin cell shall power the Espruino Pico and the display as well, i am not sure about this 3.3v rail, what do you mean?

    Usually, you have 5v coming in from USB... That goes through a voltage regulator which brings it down to 3.3v. The problem is the voltage regulator 'loses' a bit of voltage, so say you have input voltage V, the voltage coming out is either 3.3v, or V-0.3v is V is less than 3.6v.

    So if you feed it from 3v, the 3.3v rail only gets 2.7v. To fix that, you can just cut out the voltage regulator and connect the 3v battery straight to the 3.3v rail.

    What type of display is it? Could it be that the display is actually working, but the contrast is different because it's running off lower voltage?

  • i thought when using the VBAT pin i get the (raw) battery voltage from BAT_IN? i uploaded a picture to show what i mean

    Therfore, when powering up espruino and initializing AND before
    powering down the display,, these pins have all to be set input float
    ("input"). Only AFTER display is powered up, pins and communication -
    SPI - can be initialized and set.

    thanks, that explained some weird behaviour

    anyways it seems i found the cause for the root problem, i am using an e-paper display (SSD1606 controller with GDE021A1 display), but in a convenient ready-to-use module, which includes all the needed stuff (capacitors, etc.) for a proper working SSD1606 controller

    well this module draws up to 25 mA current (at least that is what my multimeter showed me), it really works perfectly when driven by VBAT (e.g. CR2032 or 2x AA eneloops)

    ok now i could use more pins like @allObjects proposed, but i will need a lot of pins for the final project (DCF77, e-paper display, maybe bluetooth BLE), i will find out if that is possible with one CR2032 :-)

    the topic for electronic switches seems to be quite complicated so i take my time and start learning, i will try it with a mosfet


    1 Attachment

    • temp_pins.jpg
  • i thought when using the VBAT pin i get the (raw) battery voltage from BAT_IN?

    Yes. If you connect the battery to BAT_IN, that voltage appears on VBAT. However, on 3.3v (the pin next to it) you'll get 3.3v OR 0.3v less than VBAT, whichever is smaller - because the voltage regulator always drops a little bit of voltage.

    I'd definitely suggest a P channel MOSFET. Things get tricky when you have voltages above 3.3v (because the Pico's outputs only do 3.3v), but because you're running everything at 3.3v it's just a matter of connecting one between 3.3v, the Pico, and the display. Have you seen http://www.espruino.com/mosfets ?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

electronic switch to control battery from Espruino GPIO

Posted by Avatar for MichaelPralow @MichaelPralow

Actions