Monitoring battery voltage with LC

Status
Not open for further replies.

32bits

Member
A few questions for a remote sensor project using an LC. I have an LC waking from deep sleep reading a Bme280 sensor, every 2 minutes, sending the data and going back to sleep. I would like to read the battery voltage powering the LC (3 x 1.5v AA batteries) by the LC ADC and include this data to send. Looking at the ADC example and reading the ADC lib does the LC having no ref voltage out create a problem? And can the 4.5v battery voltage be fed to a potential divider and then read by the LC ADC to give full scale reading? Sorry if these are basic questions but I have not used an ADC before.
 
Using the 3.3V of the LC is fine though you won't get super accurate results. Using a VRef would be better. Not sure you need the accuracy though.
 
design the divider for low current draw on the battery - in an almost identical situation where i needed
to read batt v up to at least 14v (there was an ulta low iq regulator between batt and tlc) i used
2.2 meg batt to analog in and 470 k analog in to gnd so that the batt current drawn by the divider
was 6-7 ua. to prevent dynamic effects with such high impedances i also put 0.1ufd analog in to gnd.
i did not need any bandwidth. the effect of analog input bias current on the divider was very small
and was a don't care for me.
 
Thanks for the feedback, analog&RFmodels do you have some code for your battery monitoring ADC you could share? I will use high value resistors, as you suggest + cap.
 
here are excerpts from that code - even tho i did not need bandwidth i left conversion, sampling, and averaging
as they had been for fast operation in a previous code because i am lazy - you will want to play with them and
perhaps get a tiny bit of additional accuracy.

Code:
    #include <ADC.h>

      unsigned short int i,j,n;
      unsigned int value1,value2;

    ADC *adc = new ADC(); // adc object;

    int readPin = A10;
    int readPin2 = A11;

    int main() {

    Serial.begin(38400);
    delay(500);
    
        pinMode(readPin,  INPUT);
        pinMode(readPin2, INPUT);

        pinMode(A10, INPUT);
        pinMode(A11, INPUT);

        adc->adc0->setAveraging(1);
        adc->adc0->setResolution(12);
        adc->adc0->setConversionSpeed(ADC_CONVERSION_SPEED::VERY_HIGH_SPEED);
        adc->adc0->setSamplingSpeed(ADC_SAMPLING_SPEED::VERY_HIGH_SPEED);


    loop:

    value1 = adc->analogRead(readPin);
    value2 = adc->analogRead(readPin2);
    Serial.println(value1);
    Serial.println(value2);
    Serial.println(" ");
    delay(2000);
     goto loop;

    }
 
> pinMode(A10, INPUT);

All this does on a teensy is add some distortion of the signal. Leave it out.
 
jonr - thanks for the feedback

i got in a t4 code that is a spectrum analyzer, fed in a very clean 10 khz 3vp-p sinewave, and saw the same 2nd harmonic
size with and without those lines - so in that exact case they were not driving distortion up but i am sure you have seen
cases where they do. bottom line they are not needed, don't help anything, could hurt; i will leave them out in the future.

32bits - take out both of those lines:
pinMode(A10, INPUT);
pinMode(A11, INPUT);
 
analog&RFmodels using your code example and removing the 2nd ADC ( I only need one ADC input using A9), the code works. I included adc->adc0->setReference(ADC_REFERENCE::REF_3V3); although this could be the default mode and to use the internal 3v3 reg. When using the REF_3V3 is it required to physically conect the AREF pin to the 3.3v line (pin 24)?
 
analog&RFmodels using your code example and removing the 2nd ADC ( I only need one ADC input using A9), the code works. I included adc->adc0->setReference(ADC_REFERENCE::REF_3V3); although this could be the default mode and to use the internal 3v3 reg. When using the REF_3V3 is it required to physically conect the AREF pin to the 3.3v line (pin 24)?

yes - i have aref tied to 3.3 and should have mentioned it and yes - that must be the default for reference because
i never have used the adc_reference........

glad you are on the air - don't forget to play with sampling and conversion and averaging settings so you can get
the speed vs accuracy vs signal to noise ratio that is best for you. you can also average readings in C after the
hardware averaging if you have time.
 
Status
Not open for further replies.
Back
Top