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

Thermometers.h

Committer:
Bobty
Date:
2015-10-16
Revision:
23:fd5a5a9f30bc
Parent:
20:7933076df5af

File content as of revision 23:fd5a5a9f30bc:

// Handles Thermometers
// Rob Dobson, 2015

#ifndef Thermometers__H
#define Thermometers__H

#include "RdDS18B20.h"
#include "Logger.h"

struct TemperatureValue
{
    time_t timeStamp;
    char address[DS18B20::ONEWIRE_ADDR_STRLEN];
    double tempInCentigrade;
};

class Thermometers
{
public:
    Thermometers(int numTempSensorPins, const PinName tempSensorPins[], int serviceIntervalInMs, Logger &logger);
    void Init();
    void Service();
    int GetTemperatureValues(int maxTempValues, TemperatureValue* tempValues, int maxAgeInSecs);
    static const int numSecondsBetweenThermReadings = 10;
    static const int timeForThermReadingInSecs = 2;
    static const int reGetThermometerAddressesAfterNumReadings = 100;
    static const int MAX_ONEWIRE_BUSES = 1;
    static const int MAX_THERMOMETERS = 8;
    
private:
    // Thermometer info
    int _numTempSensorPins;
    const PinName* _tempSensorPins;
    int _numThermometerBuses;
    DS18B20* _thermometerBuses[MAX_ONEWIRE_BUSES];
    int _serviceIntervalInMs;

    // Counters for state machine
    int _countForThermReadings;
    int _countForGetThermometerAddresses;
    
    // DEBUG
    int _failReadCount;
    int _failAddrCount;
    Logger &_logger;
};

#endif