Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino Nano Every NOT Supported #68

Open
GabriCattazz01 opened this issue Apr 1, 2022 · 1 comment
Open

Arduino Nano Every NOT Supported #68

GabriCattazz01 opened this issue Apr 1, 2022 · 1 comment

Comments

@GabriCattazz01
Copy link

GabriCattazz01 commented Apr 1, 2022

Hi guys, we have bought the newest arduino nano every for our IOT projects and to monitoring houses consumptions.

However, we have seen that your library does not yet support these models...
The arduino compiler gives us this ADC register error :

/*
C:\Users\Mauro\Documents\Arduino\libraries\EmonLib-master\EmonLib.cpp: In member function 'long int EnergyMonitor::readVcc()':
C:\Users\Mauro\Documents\Arduino\libraries\EmonLib-master\EmonLib.cpp:253:3: error: 'ADCSRA' was not declared in this scope
ADCSRA |= _BV(ADSC); // Convert
^~~~~~
C:\Users\Mauro\Documents\Arduino\libraries\EmonLib-master\EmonLib.cpp:253:3: note: suggested alternative: 'ADC_t'
ADCSRA |= _BV(ADSC); // Convert
^~~~~~
ADC_t

ADCSRA |= _BV(ADSC); // Convert
^
C:\Users\Mauro\Documents\Arduino\libraries\EmonLib-master\EmonLib.cpp:253:17: note: suggested alternative: 'DDRC'
C:\Users\Mauro\Documents\Arduino\libraries\EmonLib-master\EmonLib.cpp:255:12: error: 'ADCL' was not declared in this scope
result = ADCL;
^~~~
C:\Users\Mauro\Documents\Arduino\libraries\EmonLib-master\EmonLib.cpp:255:12: note: suggested alternative: 'ADC0'
result = ADCL;
^~~~
ADC0
C:\Users\Mauro\Documents\Arduino\libraries\EmonLib-master\EmonLib.cpp:256:13: error: 'ADCH' was not declared in this scope
result |= ADCH<<8;
^~~~
C:\Users\Mauro\Documents\Arduino\libraries\EmonLib-master\EmonLib.cpp:256:13: note: suggested alternative: 'ADC0'
result |= ADCH<<8;
^~~~
ADC0
*/

Would you able to integrate this model in your library?
Thanks!

@AndreLuisFeltrin
Copy link

For atmega4809 make this change inside emonlib.cpp file:

#if defined(AVR)
delay(2);
ADC0.COMMAND = ADC_STCONV_bm;
while (ADC0.INTFLAGS & ADC_RESRDY_bm == 0)
;
result = ADC0.RES;
ADC0.INTFLAGS = ADC_RESRDY_bm;
result = READVCC_CALIBRATION_CONST / result; // 1100mV*1024 ADC steps http://openenergymonitor.org/emon/node/1186
return result;
#elif defined(arm)
return (3300); // Arduino Due
#else
return (3300); // Guess that other un-supported architectures will be running a 3.3V!
#endif
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants