Update BatteryPoweredSensor.ino
Made debugging informations (Serial Print) optionally through setting
This commit is contained in:
@@ -30,6 +30,8 @@
|
|||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <MySensor.h>
|
#include <MySensor.h>
|
||||||
|
|
||||||
|
#define DEBUG 1 // Debug enables Serial.print 1 = Yes 0 = No
|
||||||
|
|
||||||
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
|
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
|
||||||
|
|
||||||
MySensor gw;
|
MySensor gw;
|
||||||
@@ -50,7 +52,9 @@ void loop()
|
|||||||
{
|
{
|
||||||
// get the battery Voltage
|
// get the battery Voltage
|
||||||
int sensorValue = analogRead(BATTERY_SENSE_PIN);
|
int sensorValue = analogRead(BATTERY_SENSE_PIN);
|
||||||
|
#if DEBUG > 0
|
||||||
Serial.println(sensorValue);
|
Serial.println(sensorValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
// 1M, 470K divider across battery and using internal ADC ref of 1.1V
|
// 1M, 470K divider across battery and using internal ADC ref of 1.1V
|
||||||
// Sense point is bypassed with 0.1 uF cap to reduce noise at that point
|
// Sense point is bypassed with 0.1 uF cap to reduce noise at that point
|
||||||
@@ -59,6 +63,7 @@ void loop()
|
|||||||
float batteryV = sensorValue * 0.003363075;
|
float batteryV = sensorValue * 0.003363075;
|
||||||
int batteryPcnt = sensorValue / 10;
|
int batteryPcnt = sensorValue / 10;
|
||||||
|
|
||||||
|
#if DEBUG > 0
|
||||||
Serial.print("Battery Voltage: ");
|
Serial.print("Battery Voltage: ");
|
||||||
Serial.print(batteryV);
|
Serial.print(batteryV);
|
||||||
Serial.println(" V");
|
Serial.println(" V");
|
||||||
@@ -66,6 +71,7 @@ void loop()
|
|||||||
Serial.print("Battery percent: ");
|
Serial.print("Battery percent: ");
|
||||||
Serial.print(batteryPcnt);
|
Serial.print(batteryPcnt);
|
||||||
Serial.println(" %");
|
Serial.println(" %");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (oldBatteryPcnt != batteryPcnt) {
|
if (oldBatteryPcnt != batteryPcnt) {
|
||||||
// Power up radio after sleep
|
// Power up radio after sleep
|
||||||
|
|||||||
Reference in New Issue
Block a user