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
VoltAlerter.cpp@10:72eb217def1f, 2015-02-22 (annotated)
- Committer:
- Bobty
- Date:
- Sun Feb 22 20:23:43 2015 +0000
- Revision:
- 10:72eb217def1f
Now sending complete broadcast message with gas count, temperatures and voltage sensing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bobty | 10:72eb217def1f | 1 | // Detect stat of Volt-Alerter |
Bobty | 10:72eb217def1f | 2 | // Device produces a square wave when voltage detected |
Bobty | 10:72eb217def1f | 3 | // Cycle time of square wave around 100ms |
Bobty | 10:72eb217def1f | 4 | // Rob Dobson, 2015 |
Bobty | 10:72eb217def1f | 5 | |
Bobty | 10:72eb217def1f | 6 | #include "VoltAlerter.h" |
Bobty | 10:72eb217def1f | 7 | |
Bobty | 10:72eb217def1f | 8 | VoltAlerter::VoltAlerter(PinName pinName) : |
Bobty | 10:72eb217def1f | 9 | _inPin(pinName, PullUp) |
Bobty | 10:72eb217def1f | 10 | { |
Bobty | 10:72eb217def1f | 11 | _curPinState = 0; |
Bobty | 10:72eb217def1f | 12 | _consecutiveLows = 0; |
Bobty | 10:72eb217def1f | 13 | } |
Bobty | 10:72eb217def1f | 14 | |
Bobty | 10:72eb217def1f | 15 | void VoltAlerter::Service() |
Bobty | 10:72eb217def1f | 16 | { |
Bobty | 10:72eb217def1f | 17 | // Check pin |
Bobty | 10:72eb217def1f | 18 | if (!_inPin) |
Bobty | 10:72eb217def1f | 19 | { |
Bobty | 10:72eb217def1f | 20 | _curPinState = 1; |
Bobty | 10:72eb217def1f | 21 | _consecutiveLows = 0; |
Bobty | 10:72eb217def1f | 22 | return; |
Bobty | 10:72eb217def1f | 23 | } |
Bobty | 10:72eb217def1f | 24 | |
Bobty | 10:72eb217def1f | 25 | // Only set state low if we get X consecutive lows |
Bobty | 10:72eb217def1f | 26 | _consecutiveLows++; |
Bobty | 10:72eb217def1f | 27 | if (_consecutiveLows >= CONSECUTIVE_LOWS_REQD_FOR_LOW) |
Bobty | 10:72eb217def1f | 28 | { |
Bobty | 10:72eb217def1f | 29 | _curPinState = 0; |
Bobty | 10:72eb217def1f | 30 | // The following is just to ensure the int doesn't overflow |
Bobty | 10:72eb217def1f | 31 | _consecutiveLows = CONSECUTIVE_LOWS_REQD_FOR_LOW; |
Bobty | 10:72eb217def1f | 32 | } |
Bobty | 10:72eb217def1f | 33 | } |
Bobty | 10:72eb217def1f | 34 |