File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
libraries/MySensors/examples/BatteryPoweredSensor Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 3030#include < SPI.h>
3131#include < MySensor.h>
3232
33+ #define DEBUG 1 // Debug enables Serial.print 1 = Yes 0 = No
34+
3335int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
3436
3537MySensor gw;
@@ -50,7 +52,9 @@ void loop()
5052{
5153 // get the battery Voltage
5254 int sensorValue = analogRead (BATTERY_SENSE_PIN);
55+ #if DEBUG > 0
5356 Serial.println (sensorValue);
57+ #endif
5458
5559 // 1M, 470K divider across battery and using internal ADC ref of 1.1V
5660 // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
@@ -59,13 +63,15 @@ void loop()
5963 float batteryV = sensorValue * 0.003363075 ;
6064 int batteryPcnt = sensorValue / 10 ;
6165
66+ #if DEBUG > 0
6267 Serial.print (" Battery Voltage: " );
6368 Serial.print (batteryV);
6469 Serial.println (" V" );
6570
6671 Serial.print (" Battery percent: " );
6772 Serial.print (batteryPcnt);
6873 Serial.println (" %" );
74+ #endif
6975
7076 if (oldBatteryPcnt != batteryPcnt) {
7177 // Power up radio after sleep
You can’t perform that action at this time.
0 commit comments