poprawa oszczedzania energii; poprawka odczytu napiecia referencyjnego (...

...3v3) oraz baterii; nadal wiele do poprawienia
Moja propozycja odczytu ponizej:




int getBandgap(void)  //battery level measure connected , PORT 4 measure through resistor divider 1M/1M in sensnodetx
     {
       const long InternalReferenceVoltage = 1115U;  // 1056U or 1115U for 328 Adjust this value to your specific internal BG voltage x1000
       // REFS1 REFS0          --> 0 1, AVcc internal ref.
       // MUX3 MUX2 MUX1 MUX0  --> 1110 1.1V (VBG)
       ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
       // Start a conversion 
       ADCSRA |= _BV( ADSC );
       // Wait for it to complete
       while( ( (ADCSRA & (1<<ADSC)) != 0 ) );
       // Scale the value
       // convert ADC readings to fit in one byte, i.e. 20 mV steps one bait transmission :
       // 1.0V = 0, 1.8V = 40, 3.3V = 115, 5.0V = 200, 6.0V = 250
       //((InternalReferenceVoltage/20U) * 1023U) / ( ADC + 1) - 50; //20mV precision
       unsigned int adcCnt = ADC;

 int results_VCC = (((InternalReferenceVoltage * 1023U) / adcCnt) + 5U);   //1mV precision
 
       return results_VCC;
      }

odczyt napiecia z 1Mohm mostka sensnodetx3.4


  int battVolts;   // made global for wider availability throughout a sketch if needed, example a low voltage alarm, etc
  battVolts = 0;
  for (int i=0; i <= 2; i++) battVolts += getBandgap(); battVolts = battVolts /3; //3 readings seem required for stable value
  measure.battvol = (map((batvol.anaRead())*2), 0, 1023, 0, (battVolts)));  //resistor divider measure multiply by 2


pokazuje dokladnie to co na mierniku , nie ucina 2 baitu jak sa wartosci ponizej x,5

nie ma problemu czy cos jest podlaczone czy nie  z czujnikow, pokazuje prawde takie wartosci jakie sa aktualnie podpiete do zasilania baterii