More reliable voltage alarm feature for ESP

Issue #61 resolved
Alan Noble created an issue

BACKGROUND

The ESP Arduino NetSender client implements a low-voltage alarm feature, which is configured by the following four variables:

  • AlarmPin: The GPIO pin to drive during an alarm (GPIO 0 by default).
  • AlarmLevel: The logical level during alarm condition (0 or LOW by default).
  • AlarmVoltage: Raise alarm when the analog (A0) value drops below this value (number between 1 and 1023, or 0 to disable).
  • AlarmRecoveryVoltage: Clear alarm when the analog (A0) value exceeds this value (number between 1 and 1023, or 0 to default to the AlarmVoltage).

If the user accidentally sets AlarmVoltage or AlarmRecoveyVoltage too high, the ESP will stay in alarm mode until a higher voltage can be applied (or forever if that is not possible). As a precaution, upon restarting, the voltage alarm feature is disabled until the device has been updated at least once. This gives the user a chance to re-configure the device with more appropriate (lower) values.

Note that despite their names, AlarmVoltage and AlarmRecoveryVoltage are analog (A0) values, not voltages. This is because conversion between raw values and voltages takes place in the cloud, not by NetSender.

The voltage presented to the analog (A0) port is stepped down by means of a 31:1 voltage divider (typically utilizing 150 kOhm and 5 kOhm resistors). Therefore, 1 analog (AO) unit corresponds to approximately 1/33V (=1023/31).

A lead-acid battery that is fully charged at 12.8V, is 50% charged at 12.2V, and completely discharged at 11.6V.

A reasonable AlarmVoltage might be 50%, i.e., 12.2V for a 12V system, or 24.4 for a 24V system.

These correspond to theoretical analog values of 403 and 805 respectively (“theoretical” because the exact voltage dividing ratio depends on the precise resistor values.).

ISSUE

There is a need for a voltage alarm that is foolproof and works without the need for a user-initiated update upon restarting.

It is proposed that ESP always enter alarm mode upon restarting. Further, a new variable, PeakVoltage, is proposed that specifies the analog value corresponding to the voltage of a fully-charged battery. The PeakVoltage will be used to limit the maximum possible values for the AlarmVoltage and AlarmRecoveyVoltage. Note that the PeakVoltage is not the maximum possible voltage, as higher voltages will be experienced during charging. This is desirable as it means that a voltage alarm can be canceled by simply charging the ESP sufficiently long.

To further fool-proof this feature, it is proposed that if PeakVoltage is unspecified, it will default to 845, corresponding to 25.6V.

This value is obviously too high for 12V systems but is reasonable for 24V systems.

Comments (1)

  1. Log in to comment