Spark Core Battery Percentage Checking

hi mdma !

I’m just a beginner with Spark Core.

Today, I just tried to put this code ( for Arduino ) in Spark IDE ( changed something in code to adapt to Spark IDE ) :

But got these errors :


Vcc.cpp: In member function 'float Vcc::Read_Volts()':
Vcc.cpp:45:7: error: 'ADMUX' was not declared in this scope
if (ADMUX != ADMUX_VCCWRT1V1)
^
Vcc.cpp:38:30: error: 'REFS0' was not declared in this scope
#define ADMUX_VCCWRT1V1 (_BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1))
^
Vcc.cpp:45:16: note: in expansion of macro 'ADMUX_VCCWRT1V1'
if (ADMUX != ADMUX_VCCWRT1V1)
^
Vcc.cpp:38:35: error: '_BV' was not declared in this scope
#define ADMUX_VCCWRT1V1 (_BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1))
^
Vcc.cpp:45:16: note: in expansion of macro 'ADMUX_VCCWRT1V1'
if (ADMUX != ADMUX_VCCWRT1V1)
^
Vcc.cpp:38:43: error: 'MUX3' was not declared in this scope
#define ADMUX_VCCWRT1V1 (_BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1))
^
Vcc.cpp:45:16: note: in expansion of macro 'ADMUX_VCCWRT1V1'
if (ADMUX != ADMUX_VCCWRT1V1)
^
Vcc.cpp:38:55: error: 'MUX2' was not declared in this scope
#define ADMUX_VCCWRT1V1 (_BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1))
^
Vcc.cpp:45:16: note: in expansion of macro 'ADMUX_VCCWRT1V1'
if (ADMUX != ADMUX_VCCWRT1V1)
^
Vcc.cpp:38:67: error: 'MUX1' was not declared in this scope
#define ADMUX_VCCWRT1V1 (_BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1))
^
Vcc.cpp:45:16: note: in expansion of macro 'ADMUX_VCCWRT1V1'
if (ADMUX != ADMUX_VCCWRT1V1)
^
Vcc.cpp:51:26: error: 'delayMicroseconds' was not declared in this scope
delayMicroseconds(350); 
^
Vcc.cpp:55:3: error: 'ADCSRA' was not declared in this scope
ADCSRA |= _BV(ADSC);
^
Vcc.cpp:55:17: error: 'ADSC' was not declared in this scope
ADCSRA |= _BV(ADSC);
^
Vcc.cpp:55:21: error: '_BV' was not declared in this scope
ADCSRA |= _BV(ADSC);
^
Vcc.cpp:56:32: error: 'bit_is_set' was not declared in this scope
while (bit_is_set(ADCSRA,ADSC)) {};
^
Vcc.cpp:61:28: error: 'ADC' was not declared in this scope
float vcc = 1.1*1023.0 / ADC;
^
Vcc.cpp: In member function 'float Vcc::Read_Perc(float, float, bool)':
Vcc.cpp:75:38: error: 'constrain' was not declared in this scope
perc = constrain(perc, 0.0, 100.0);
^
make: *** [Vcc.o] Error 1

After that, I visited many topics about battery checking issues and got these topics :

So now I have no idea how checking battery in spark core without using another board to measure.

1 Like