ESP Plant Care - Class Documentation

General

MQTTHelper

class MQTTHelper

MQTT helper for fast sensor and system data uploading.

Public Functions

MQTTHelper(PubSubClient *pubSubClient, TimeProvider *timeProvider)

Parameters

void setup()

Setup the MQTT connection.

void update()

Update the MQTT connection.

void connect()

Connect/Reconnect to the MQTT broker.

void disconnect()

Disconnect from the MQTT broker.

template <typename Generic>
void logSensorMetric(String sensor, Generic payload, bool retained = false)

Send generic sensor message with automatic time providing.

Template Parameters
  • Generic:
Parameters

template <typename Generic>
void logSystemMetric(String system, Generic payload, bool retained = false)

Send generic system message with automatic time providing.

Template Parameters
  • Generic:
Parameters

template <typename Generic>
void logSensorMetric(String sensor, Generic payload, unsigned long time, bool retained = false)

Send generic sensor message.

Template Parameters
  • Generic:
Parameters

template <typename Generic>
void logSystemMetric(String system, Generic payload, unsigned long time, bool retained = false)

Send generic sensor message.

Template Parameters
  • Generic:
Parameters

TimeProvider

class TimeProvider

Epoch time keeper, for accurate measurement times.

Inherits from ITimeProvider

Public Functions

TimeProvider(UDP *udp)

Parameters
  • udp:

unsigned long getTime()

Return
epoch time

void update(bool force = false)

update time

Parameters
  • force: - if true, ignore update interval time

Sensors

AnalogReadCap

class AnalogReadCap

                  R sens           100 ohm
 3.3V/Sensor -----\/\/\/-----*-----\/\/\/----- DigitalPin
                             |
                             |
                          ======= 10µF
                             |
                             |
                            GND
*

Analog sensor reader:

  1. Discharge Capacitor
  2. Wait until charged and time it
  3. RC = time

Inherits from Sensor

Public Functions

AnalogReadCap(String name, ITimeProvider *timeProvider, uint8_t ioPin)

Parameters
  • name:
  • timeProvider:
  • ioPin: digital read pin

BH1750

class BH1750light

BH1750 Sensor.

Inherits from Sensor

Public Functions

BH1750light(String name, ITimeProvider *timeProvider, int sda, int scl, BH1750::Mode = BH1750::CONTINUOUS_HIGH_RES_MODE)

Parameters
  • name: - used as MQTT sensor topic name
  • timeProvider:
  • sda: - i2c
  • scl: - i2c

BMP180

class BMPholder

BMP180 Sensor.

Inherits from SensorSet

Public Functions

void registerPressureSensor(Sensor *pressureSensor)

Register sensor to hold the data.

Parameters
  • pressureSensor:

void registerTemperatureSensor(Sensor *temperatureSensor)

Register sensor to hold the data.

Parameters
  • temperatureSensor:

void registerAltitudeSensor(Sensor *altitudeSensor)

Register sensor to hold the data.

Parameters
  • altitudeSensor:

DHT22

class DHTholder

DHT22 Sensor.

Inherits from SensorSet