Skip to content

Commit ed939e7

Browse files
committed
Update BatteryPoweredSensor.ino
Made debugging informations (Serial Print) optionally through setting
1 parent d90e2d9 commit ed939e7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

libraries/MySensors/examples/BatteryPoweredSensor/BatteryPoweredSensor.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <SPI.h>
3131
#include <MySensor.h>
3232

33+
#define DEBUG 1 // Debug enables Serial.print 1 = Yes 0 = No
34+
3335
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
3436

3537
MySensor 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

0 commit comments

Comments
 (0)