Skip to content

Commit

Permalink
Added setting sensorInterval
Browse files Browse the repository at this point in the history
  • Loading branch information
euphi committed Mar 11, 2018
1 parent 2dcbc48 commit 2f66c2a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "HomieNodeCollection",
"version": "0.9.0",
"version": "0.9.1",
"keywords": "Homie, sensor, temperature, display",
"description": "Collection of Node implementations for the Homie-ESP8266 library.",
"repository": {
Expand Down
7 changes: 6 additions & 1 deletion src/SensorNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


HomieSetting<double> SensorNode::tempOffset ("TempAdj", "offset to add to temperature");
HomieSetting<long> SensorNode::interval("sensorInterval", "interval how often to read sensors");


SensorNode::SensorNode() :
Expand All @@ -28,6 +29,10 @@ SensorNode::SensorNode() :
tempOffset.setDefaultValue(0).setValidator([] (double candidate) {
return ((!isnan(candidate) || candidate == 0.0) && candidate > -15.0 && candidate < 15.0);
});
interval.setDefaultValue(30000).setValidator([] (long candidate) {
return (candidate > 1000 && candidate < 600000);
});


advertise("degrees");
advertise("rel%");
Expand All @@ -48,7 +53,7 @@ void SensorNode::setup() {
}

void SensorNode::loop() {
if (millis() - lastLoop8000ms >= 30000UL || lastLoop8000ms == 0) {
if (millis() - lastLoop8000ms >= interval.get() || lastLoop8000ms == 0) {
lastLoop8000ms = millis();
#ifdef SENSORS_BMP180_ATTACHED
temp = Sensors::getThermometer()->getTemperature();
Expand Down
1 change: 1 addition & 0 deletions src/SensorNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SensorNode: public HomieNode {
private:
unsigned long lastLoop8000ms;
static HomieSetting<double> tempOffset;
static HomieSetting<long> interval;

#ifndef SENSORS_BMP180_ATTACHED
HTU21D htu;
Expand Down

0 comments on commit 2f66c2a

Please sign in to comment.