Override or inhibit initVariant() at start up

svedblen
Posts: 3
Joined: Wed Sep 11, 2024 6:31 am

Override or inhibit initVariant() at start up

Postby svedblen » Wed Sep 11, 2024 6:55 am

Hi!

I intend to use an Adafruit Feather ESP32-S2 due to, among other things, its capability to drive an OLED through its STEMMA QT connector, for which it uses the PIN_I2C_POWER pin to power I2C devices. This way the OLED will power off when the MCU is put in deep sleep (I hope). I have already tried to achieve this with other boards and an ordinary GPIO pin but that does not work with my SH1107 128x128 OLED. It apparently draws too much current, even if I increase the pin strength/capability to 3 (40 mA). So I hope the ESP32-S2 will do the trick.

As i can see on GitHub (https://github.com/espressif/arduino-es ... ariant.cpp)the ESP32-S2 initVariant() method is where that pin is set high, and this happens right before the call to setup().

This is all fine, but I would like to be able to delay PIN_I2C_POWER going high to a later stage, own my own choice. This due to the way I want the thing to behave after wakeup from deep sleep.

I could of course just set PIN_I2C_POWER low first thing in setup, thus neutralizing initVaraint(). But I do not want the OLED to flicker at startup, and perhaps it will not, but I still would like to do this in a controlled way. And I am generally interested in educating myself.

So finally, here is my question; Is there a way to either override initVariant() or make it not be called?

Cheers!

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

Re: Override or inhibit initVariant() at start up

Postby lbernstone » Wed Sep 11, 2024 7:54 am

The typical way you would control the power flow would be have a transistor (or mosfet eg 2N7002) gated from a gpio pin, which then allows power to run from the main power bus. Trying to run >40mA power through a gpio is going to generate a lot of heat in the cpu, and is simply beyond the specs of the device. Look on Google, you should find lots of examples.

svedblen
Posts: 3
Joined: Wed Sep 11, 2024 6:31 am

Re: Override or inhibit initVariant() at start up

Postby svedblen » Wed Sep 11, 2024 3:29 pm

Yes I know that, but I want to avoid that. Instead I think that the Feather ESP32-S2 will solve that for me. The description of the OLED I am using shows a setup like that, with the OLED powered through STEMMA QT/Qwiic (https://www.adafruit.com/product/5297). So my problem is not how to power the display but how to delay the power up to a later stage. The ESP32-S2 will set the I2C Power pin high in the initVariant() method which seems to be called juts before setup() is called. So I want to install my own version of initVariant() or in some other way inhibit the pin from going high at that point. That is what I wonder if anyone has any ideas about.

Cheers!

Who is online

Users browsing this forum: No registered users and 46 guests