GPIO to Power a Sensor

tony@shatalmic.com
Posts: 12
Joined: Sun Dec 16, 2018 4:06 am

GPIO to Power a Sensor

Postby tony@shatalmic.com » Sat Feb 23, 2019 8:08 pm

I have a magnetic sensor on my board. Currently it is powered directly by the 3.3v rail.

I have found that when I update the firmware using OTA the sensor doesn't work until I power cycle the whole system. I suspect that the magnetic sensor is just in a state that it needs to be reset.

I know I could add a FET or transistor with a GPIO to be able to power cycle the sensor, but was wondering if I couldn't just power the sensor directly from a GPIO. That way I could just set the pin low and then high to cycle power on the sensor.

The data sheet says the average current draw during normal operation is 3.7 mA and the note says this is the peak during ADC operations for about 270 microseconds, so I guess that is the max.

I read a post that says the max current draw on the esp32 GPIO is 40 mA, so it seems this would be fine. I just didn't want to bank on it without asking someone.

ESP_Sprite
Posts: 9043
Joined: Thu Nov 26, 2015 4:08 am

Re: GPIO to Power a Sensor

Postby ESP_Sprite » Mon Feb 25, 2019 2:30 am

Yes, you should be able to do this.

tony@shatalmic.com
Posts: 12
Joined: Sun Dec 16, 2018 4:06 am

Re: GPIO to Power a Sensor

Postby tony@shatalmic.com » Mon Feb 25, 2019 2:29 pm

Thank you. Can you think of any side effects or down sides?

ESP_Sprite
Posts: 9043
Joined: Thu Nov 26, 2015 4:08 am

Re: GPIO to Power a Sensor

Postby ESP_Sprite » Tue Feb 26, 2019 7:07 am

For one sensor? Not really. I wouldn't go overboard with this technique and try to pull 40mA from every single available GPIO as that'll probably heat up the chip a fair bit, but for one sensor, you should be good to go.

Who is online

Users browsing this forum: No registered users and 70 guests