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
Diff: main.cpp
- Revision:
- 19:0367cb46d003
- Parent:
- 18:d419ccebc666
- Child:
- 20:7933076df5af
--- a/main.cpp Mon Sep 28 11:16:46 2015 +0000 +++ b/main.cpp Mon Oct 05 14:05:33 2015 +0000 @@ -1,3 +1,10 @@ +// Gas usage monitor +// Counts pulses from a gas meter +// Monitors temperature sensors +// Monitors valve/pump activity +// Web interface and UDP broadcast +// Rob Dobson 2015 + #include "mbed.h" #include "EthernetInterface.h" #include "NTPClient.h" @@ -37,7 +44,8 @@ SDFileSystem sd(p5, p6, p7, p8, "sd"); // Log file names -const char* gasPulseFileName = "/sd/curPulse.txt"; +const char* gasPulseFileName1 = "/sd/curPulse.txt"; +const char* gasPulseFileName2 = "/sd/curPulse2.txt"; const char* eventLogFileName = "/sd/log.txt"; const char* dataLogFileBase = "/sd/"; @@ -46,7 +54,7 @@ // Gas use counter DigitalIn gasPulsePin(p21); -GasUseCounter gasUseCounter(gasPulseFileName, gasPulsePin, pc); +GasUseCounter gasUseCounter(gasPulseFileName1, gasPulseFileName2, gasPulsePin, pc); // Thermometers - DS18B20 OneWire Thermometer connections const PinName tempSensorPins[] = { p22 }; @@ -196,14 +204,15 @@ pc.printf("Trying to update time...\r\n"); if (ntp.setTime("0.pool.ntp.org") == NTP_OK) { - printf("Set time successfully\r\n"); - time_t ctTime; - ctTime = time(NULL); - printf("Time is set to (UTC): %s\r\n", ctime(&ctTime)); + osDelay(1000); // This delay is simply to try to improve printf output + printf("Set time successfully\r\n"); + time_t ctTime; + ctTime = time(NULL); + pc.printf("Time is set to (UTC): %s\r\n", ctime(&ctTime)); } else { - printf("Cannot set from NTP\r\n"); + pc.printf("Cannot set from NTP\r\n"); } // Refresh time every K hours @@ -231,7 +240,7 @@ int main() { pc.baud(115200); - pc.printf("Gas Monitor V2 - Rob Dobson 2014\r\n"); + pc.printf("\r\n\r\nGas Monitor V2 - Rob Dobson 2014\r\n"); // Initialise thermometers thermometers.Init(); @@ -239,7 +248,6 @@ // Get the current count from the SD Card gasUseCounter.Init(); - // Setup ethernet interface char macAddr[6]; mbed_mac_address(macAddr); @@ -283,9 +291,15 @@ { // Record the reason for restarting in the log file if (watchdogCausedRestart) + { logger.LogEvent("Watchdog Restart"); + pc.printf("Watchdog Restart\r\n"); + } else + { logger.LogEvent("Normal Restart"); + pc.printf("Normal Restart\r\n"); + } restartCauseRecorded = true; } }