Is it possible to make the LED blink while charging the battery using analog pin

I have a circuit where, if the battery is lower than 3v, a LED turns on. The battery is connected to a TP4056 charging module. Can I make this LED blink when I am charging?

#define red   9
#define lipo  A0
 
float lipoV = 0;
 
void setup() {
  pinMode(red,OUTPUT);
  pinMode(lipo,INPUT);
}
 
void loop() {
  lipoV = analogRead(lipo);
  Serial.println(lipoV);
  if(lipoV<700){
    digitalWrite(red,HIGH);
  } else {
    digitalWrite(red, LOW);
  }
}

if(lipoV<614){

Hello mezoo330

Take a look at the BlinkWithOutDelay example from the IDE.
With this example, you can easily build a blink timer that can react to the measured voltage values.

Have a nice day and enjoy coding in C++.

if your TP4056 module have DW01A protection circuit it will probably cutoff discharge at 3.0V

1. How much is the Battery Voltage? How much is its Ah capacity?
2. Does B+/B- indicate that these are the Postive/Negative terminals of the Battery?

3. You need to monitor the charging current of the Battery. LED1 will keep blinking as long as charginhg is not close to zero. The following circuit may be employed.

1- lipo battery 3.7 350 mah
2- yes
3- can not do this by monitering the voltage?

The amp is a good idea however the 741 Amp will not work, it is not a single voltage amplifier. The data sheet shows + and - 10V as the minimum voltage. It also will fall about 2V from each rail. There are many single supply op amps that would work nicely. https://www.ti.com/lit/ds/symlink/lm741.pdf?ts=1699348456919&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FLM741%253Futm_source%253Dgoogle%2526utm_medium%253Dcpc%2526utm_campaign%253Dasc-null-null-GPN_EN-cpc-pf-google-wwe%2526utm_content%253DLM741%2526ds_k%253Dlm741cn%2Bdatasheet%2526DCM%253Dyes%2526gad_source%253D1%2526gclid%253DCjwKCAiA3aeqBhBzEiwAxFiOBhlT1jyetoGtLCLnSiiFae1Zh-edpIKBMzSor7IJUm6dci9RARplzRoCcRAQAvD_BwE%2526gclsrc%253Daw.ds

If you like my circuit, then we can try:
Place the 0.05 ohm resistor at the negative side of the Battery. Start the Charger. With a DVM, measure the voltage across R1 and report it to decide if we need the amplifier or not.

Practicaly, 741 works at a single supply with some offset which can be nullified in software.

To the original question(see the topic heading),
No, the LED won't flash, because your Arduino isn't powered.

To those who would defend, we often note on this forum that incomplete schematics mislead. Who knows exactly what the power configuration is for this circuit? Only the OP. All others are assuming, and we know where that leads.
To the OP, you may assume I'm just being difficult, but the sad reality is, we very often discover the roots of posted problems lie in the details not given, or deliberately held back, "in order to simplify". In this case, I'm very curious to see the whole circuit configuration.

2 Likes

This is a complete schematic (Fig-1):


Figure-1:

1 Like

Hello GolamMostafa

A short and quick question before the coffee break:

What is the technical reason for an op-amp?

To amplify the (tiny) voltage drop across R1.

From post #6, Capacity, C = 350 mah
Charging current (rule of thumb) = C/4 = 87 mA
VR1 = Vin = 87x.05 = 4.35 mV
Vo = 4.35 x 20 = 80.70 mV (max) when the ADC's resolution with 1.1V Ref is: 1.07 mV

I think 741 is not going to help much, the OP might need to use a high gain instrument amplifier like INA101(Fig-1):


Figure-1:

1 Like

@GolamMostafa Inferred, I presume, due to the use of Serial.print() in the code? I missed that. My bad.
Thanks.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.