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 30
30
#include < SPI.h>
31
31
#include < MySensor.h>
32
32
33
+ #define DEBUG 1 // Debug enables Serial.print 1 = Yes 0 = No
34
+
33
35
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
34
36
35
37
MySensor gw;
@@ -50,7 +52,9 @@ void loop()
50
52
{
51
53
// get the battery Voltage
52
54
int sensorValue = analogRead (BATTERY_SENSE_PIN);
55
+ #if DEBUG > 0
53
56
Serial.println (sensorValue);
57
+ #endif
54
58
55
59
// 1M, 470K divider across battery and using internal ADC ref of 1.1V
56
60
// Sense point is bypassed with 0.1 uF cap to reduce noise at that point
@@ -59,13 +63,15 @@ void loop()
59
63
float batteryV = sensorValue * 0.003363075 ;
60
64
int batteryPcnt = sensorValue / 10 ;
61
65
66
+ #if DEBUG > 0
62
67
Serial.print (" Battery Voltage: " );
63
68
Serial.print (batteryV);
64
69
Serial.println (" V" );
65
70
66
71
Serial.print (" Battery percent: " );
67
72
Serial.print (batteryPcnt);
68
73
Serial.println (" %" );
74
+ #endif
69
75
70
76
if (oldBatteryPcnt != batteryPcnt) {
71
77
// Power up radio after sleep
You can’t perform that action at this time.
0 commit comments