I try to power a ili9341 connected to esp32 s3 with a solarpannel and a battery. The setup should work for a long time, so i try to have the display led shut down when it isnt needed. At first i powered the display through one of the gpios (6). This does work, but i noticed that after some time, the display wont start anymore, even when there should be enough power. I suspect that its because powering directly trough the gpio isnt optimal so i tried to go for a transistor. I used a PN2222A transistor and connected it as following, but now the display led wont start at all. Do you have any suggestions on what i did wrong ith the transistor or i there is any other way to power the setup consistently, given that the battery has enough power? Thanks for your help.
ESP32 Connections:
PN2222 Transistor:
Base: Connect to the ESP32 GPIO pin (7) through a 220 ohm resistor.
Collector: Connect to the backlight pin (LED/BL) of the ILI9341 display.
Emitter: Connect to the ground (GND).
ILI9341 Display:
VCC: Connect to the 3.3V pin of the ESP32.
GND: Connect to the ground (GND) pin of the ESP32 and the emitter of the PN2222 transistor.
Backlight Pin (LED/BL): Connect to the collector of the PN2222 transistor.
TP4056 Charger Module and Battery:
IN+ and IN-: Connect to the 5V Solar Panel.
BAT+ and BAT-: Connect to the 3.7V LiPo battery.
OUT+ and OUT-: Connect to the ESP32's VIN and GND (if using a development board that regulates the battery voltage to 3.3V).
It sounds like your setup with the PN2222A transistor might have some issues in how the transistor is connected or controlled. Here are a few points to check and suggestions to troubleshoot the issue:
Transistor Configuration:
Make sure the transistor is connected correctly:
Base to GPIO pin 7 through a 220 ohm resistor.
Collector to the LED/BL pin of the ILI9341 display.
Emitter to ground (GND).
Powering the ILI9341:
Ensure that the ILI9341 display's VCC is connected to the 3.3V pin of the ESP32, not directly to the 5V pin unless the display can handle 5V on VCC.
Controlling the Transistor:
Ensure the GPIO pin is correctly configured as an output and is driven high to turn on the transistor (and thus the backlight). If the GPIO pin is low, the transistor will not allow current to flow to the backlight.
Transistor Specifications:
Verify that the PN2222A can handle the current required by the ILI9341 backlight. If the backlight requires more current than the transistor can handle, it may not work correctly.
Alternative Approach:
You might consider using a MOSFET instead of a BJT transistor. MOSFETs generally have lower on-resistance and can handle higher currents more efficiently.
Here’s a step-by-step approach to troubleshoot the issue:
Verify Connections:
Double-check all connections to ensure they match the described configuration.
Test the GPIO Pin:
Write a simple program to toggle the GPIO pin high and low. Use a multimeter to measure the voltage at the base of the transistor to ensure it’s receiving the correct signal.
Test the Transistor:
Disconnect the backlight pin and connect an LED with a current-limiting resistor between the collector and VCC to see if the transistor switches the LED on and off correctly when the GPIO pin is toggled.
Check Power Supply:
Ensure the power supply (battery + solar panel + charger module) is providing stable and sufficient voltage/current to the system.
Here is a simple Arduino-like code snippet to toggle the GPIO pin:
void setup() {
pinMode(7, OUTPUT); // Set GPIO 7 as an output
}
void loop() {
digitalWrite(7, HIGH); // Turn on the backlight
delay(1000); // Wait for 1 second
digitalWrite(7, LOW); // Turn off the backlight
delay(1000); // Wait for 1 second
}
Using this code, you can measure the voltage at the base of the transistor with a multimeter to ensure it's toggling correctly.
If everything seems correct and it still doesn’t work, consider using a logic-level MOSFET like the IRLZ44N. Here’s how you would connect it:
MOSFET Connections:
Gate: Connect to the ESP32 GPIO pin (7) through a 220 ohm resistor.
Drain: Connect to the LED/BL pin of the ILI9341 display.
Source: Connect to ground (GND).
This setup should be more efficient and capable of handling higher currents required by the backlight.