Monitor for central heating system (e.g. 2zones+hw) Supports up to 15 temp probes (DS18B20/DS18S20) 3 valve monitors Gas pulse meter recording Use stand-alone or with nodeEnergyServer See http://robdobson.com/2015/09/central-heating-monitor

Dependencies:   EthernetInterfacePlusHostname NTPClient Onewire RdWebServer SDFileSystem-RTOS mbed-rtos mbed-src

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers VoltAlerter.cpp Source File

VoltAlerter.cpp

00001 // Detect stat of Volt-Alerter
00002 // Device produces a square wave when voltage detected
00003 // Cycle time of square wave around 100ms
00004 // Rob Dobson, 2015
00005 
00006 #include "VoltAlerter.h"
00007 
00008 VoltAlerter::VoltAlerter(PinName pinName) :
00009     _inPin(pinName, PullUp)
00010 {
00011     _curPinState = 0;
00012     _consecutiveLows = 0;
00013 }
00014 
00015 void VoltAlerter::Service()
00016 {
00017     // Check pin
00018     if (!_inPin)
00019     {
00020         _curPinState = 1;
00021         _consecutiveLows = 0;
00022         return;
00023     }
00024     
00025     // Only set state low if we get X consecutive lows
00026     _consecutiveLows++;
00027     if (_consecutiveLows >= CONSECUTIVE_LOWS_REQD_FOR_LOW)
00028     {
00029         _curPinState = 0;
00030         // The following is just to ensure the int doesn't overflow
00031         _consecutiveLows = CONSECUTIVE_LOWS_REQD_FOR_LOW;
00032     }
00033 }
00034