Xinyuan-LilyGO / LilyGO-T-A76XX

LilyGo A7670 A7608 SIM7672 series
MIT License
96 stars 42 forks source link

analogRead when battery powered #81

Closed GabrielZre closed 2 months ago

GabrielZre commented 4 months ago

Hi, when I powered A7608E-H from Usb C cable I got an accurate values on 3.55, but when switched into battery source (18650 3.6), then the values are not even close. How should I get this value? Is it constant? I don't think so if the battery source really makes difference.

rawVoltageValue = analogRead(voltagePin);
voltageValueArduino = (rawVoltageValue * 3.55) / 4095.0; // 3.55 ok with USB C 

additionally, when my voltage Is 2.45, then te analogRead(voltagePin) gives 2829 instead of 3000+

next example (powered from USB-C): multimeter measurements: 1.65V

rawVoltageValue = analogRead(voltagePin); // (VOLTAGEPIN = 0)
voltageValueArduino = (rawVoltageValue * 3.3) / 4095.0;

analogRead gives output: rawVoltageValue: 1845 voltageValueArduino: 1.49

So the question is - why the output differs and depends on the power source?

UPDATE: After changing the pin from 0, to 34, and reading 2 values - from PIN 34 and 32, I am expecting from rawCurrent 1.65V (32) and from rawVoltage 2.42V (34), but for example when I set voltage to 3.3, then rawCurrent(analogRead) is 1.49

With these settings, after changing the pin, the output is as before with 3.55 and 3.57, I don't have an idea why it works, why they are not the same, and why 3.3 is not enough... voltageValueArduino = (rawVoltageValue 3.785) / 4095.0; // (pin34) (2.42V when 3.785 - ok with multimeter) currentValueArduino = (rawCurrentValue 3.57) / 4095.0; // (pin32) (1.65V when 3.57 - ok with multimeter)

The values are repeatable ( changing pins 32/34 doesn't make difference, so connection should be okay ) and furthermore, now the output is the same, power source doesn't matter

lewisxhe commented 3 months ago

VOLTAGEPIN = 0? Where did you know that ADC Pin is 0? There are two versions of A7608, one version has a battery voltage divider circuit (using GPIO35), and the other one has, which version do you use?

GabrielZre commented 3 months ago

A7608E-H, actually I compared few pins and changed this pin 0 to 35, so now I am using pin 34 and 35, the values are equals now

W dniu wt., 5.03.2024 o 10:14 Lewis He @.***> napisał(a):

VOLTAGEPIN = 0? Where did you know that ADC Pin is 0? There are two versions of A7608, one version has a battery voltage divider circuit (using GPIO35), and the other one has, which version do you use?

— Reply to this email directly, view it on GitHub https://github.com/Xinyuan-LilyGO/LilyGO-T-A76XX/issues/81#issuecomment-1978286316, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY36AINDTTLCSLYSYTWS7SDYWWEHNAVCNFSM6AAAAABDABASJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZYGI4DMMZRGY . You are receiving this because you authored the thread.Message ID: @.***>

lewisxhe commented 3 months ago

A7608 uses GPIO35. You can check the schematic diagram. The voltage dividing resistor is connected to GPIO35.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.