summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2019-03-02 15:29:00 +0000
committerdakkar <dakkar@thenautilus.net>2019-03-02 15:29:00 +0000
commit88c6eacae3d2e6f7aeaac56be1c5a0d82d017ab5 (patch)
tree5ca2cbf1969daf0b2514f4e6249d7b3aa16beeca
parentno more display (diff)
downloadthermostat-88c6eacae3d2e6f7aeaac56be1c5a0d82d017ab5.tar.gz
thermostat-88c6eacae3d2e6f7aeaac56be1c5a0d82d017ab5.tar.bz2
thermostat-88c6eacae3d2e6f7aeaac56be1c5a0d82d017ab5.zip
define pins & read battery level
-rw-r--r--sensor/thermostat.ino13
1 files changed, 9 insertions, 4 deletions
diff --git a/sensor/thermostat.ino b/sensor/thermostat.ino
index 20496bc..4f65c60 100644
--- a/sensor/thermostat.ino
+++ b/sensor/thermostat.ino
@@ -18,6 +18,10 @@ static BLEUUID thermo_time_uuid("11111111-2222-3333-4444-000000000002");
#define BLE_POWER ESP_PWR_LVL_P7
// #define BLE_POWER ESP_PWR_LVL_N14
+#define SENSOR_POWER_PIN A3
+#define SENSOR_DATA_PIN A2
+#define VBAT_PIN A13
+
DHTesp dht;
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
@@ -43,13 +47,13 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
}; // MyAdvertisedDeviceCallbacks
void enable_sensor(bool enable) {
- pinMode(12,OUTPUT);
- digitalWrite(12,enable ? HIGH : LOW);
+ pinMode(SENSOR_POWER_PIN,OUTPUT);
+ digitalWrite(SENSOR_POWER_PIN,enable ? HIGH : LOW);
delay(500);
}
bool read_sensor(float* humidity, float* temperature) {
- dht.setup(13,DHTesp::DHT11);
+ dht.setup(SENSOR_DATA_PIN,DHTesp::DHT11);
int tries=0;bool ret=false;
while (!ret && ++tries<10) {
@@ -125,9 +129,10 @@ void loop() {
int next_time;
if (cb->pServerAddress) {
-
float humidity, temperature;
bool ok = read_sensor(&humidity,&temperature);
+ int batteryLevel = analogRead(VBAT_PIN);
+ batteryLevel *= 2;
if (ok) {
String data = String(BLEDevice::getAddress().toString().c_str()) + " "
+ String(humidity) + " "