Skip to content

Commit 76b19a7

Browse files
authored
Added cpu and memory debug information (#408)
1 parent 83e9036 commit 76b19a7

File tree

5 files changed

+4
-31
lines changed

5 files changed

+4
-31
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ You can interact with each class provided by NodeManager through a set of API fu
239239
void hello();
240240
// [6] reboot the board
241241
void reboot();
242-
// return vcc in V
243-
float getVcc();
244242
// [36] set the default interval in minutes all the sensors will report their measures. If the same function is called on a specific sensor, this will not change the previously set value. On sleeping sensors, the elapsed time can be evaluated only upon wake up (default: 10 minutes)
245243
void setReportIntervalSeconds(unsigned long value);
246244
unsigned long getReportIntervalSeconds();

nodemanager/Node.cpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ void NodeManager::setup() {
234234
// turn the sensor off
235235
powerOff();
236236
#endif
237+
// print out information regarding CPU voltage, frequency and free memory
238+
debug(PSTR(LOG_SETUP "HW V=%d F=%d M=%d\n"),hwCPUVoltage(),hwCPUFrequency()/10,hwFreeMem());
237239
}
238240

239241
// run the main function for all the register sensors
@@ -395,31 +397,6 @@ void NodeManager::loop() {
395397

396398
#endif
397399

398-
// return vcc in V
399-
float NodeManager::getVcc() {
400-
#ifdef CHIP_AVR
401-
// Measure Vcc against 1.1V Vref
402-
#if defined(CHIP_MEGA)
403-
ADMUX = (_BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1));
404-
#elif defined (CHIP_TINYX4)
405-
ADMUX = (_BV(MUX5) | _BV(MUX0));
406-
#elif defined (CHIP_TINYX5)
407-
ADMUX = (_BV(MUX3) | _BV(MUX2));
408-
#else
409-
ADMUX = (_BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1));
410-
#endif
411-
// Vref settle
412-
wait(70);
413-
// Do conversion
414-
ADCSRA |= _BV(ADSC);
415-
while (bit_is_set(ADCSRA, ADSC)) {};
416-
// return Vcc in mV
417-
return (float)((1125300UL) / ADC) / 1000;
418-
#else
419-
return (float)0;
420-
#endif
421-
}
422-
423400
#if NODEMANAGER_INTERRUPTS == ON
424401
// return the pin from which the last interrupt came
425402
int8_t NodeManager::getLastInterruptPin() {

nodemanager/Node.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ class NodeManager {
4747
void hello();
4848
// [6] reboot the board
4949
void reboot();
50-
// return vcc in V
51-
float getVcc();
5250
// [36] set the default interval in minutes all the sensors will report their measures. If the same function is called on a specific sensor, this will not change the previously set value. On sleeping sensors, the elapsed time can be evaluated only upon wake up (default: 10 minutes)
5351
void setReportIntervalSeconds(unsigned long value);
5452
unsigned long getReportIntervalSeconds();

sensors/SensorBattery.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class SensorBattery: public Sensor {
9191
void onLoop(Child* child) {
9292
// measure the board vcc
9393
float volt = 0;
94-
if (_battery_internal_vcc || _battery_pin == -1) volt = nodeManager.getVcc();
94+
if (_battery_internal_vcc || _battery_pin == -1) volt = (float)hwCPUVoltage()/1000;
9595
else volt = analogRead(_battery_pin) * _battery_volts_per_bit;
9696
volt = volt * _battery_adj_factor;
9797
child->setValue(volt);

sensors/SensorML8511.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SensorML8511: public Sensor {
4141
void onLoop(Child* child) {
4242
// read the voltage
4343
int uvLevel = analogRead(_pin);
44-
int refLevel = nodeManager.getVcc()*1024/3.3;
44+
int refLevel = (float)hwCPUVoltage()/1000*1024/3.3;
4545
//Use the 3.3V power pin as a reference to get a very accurate output value from sensor
4646
float outputVoltage = 3.3 / refLevel * uvLevel;
4747
//Convert the voltage to a UV intensity level

0 commit comments

Comments
 (0)