This change controls a GPIO on the expansion connector depending on the
surrounding temperature. If external temperature is too low for
charging, the GPIO is set high, else it is set low.
In combination with the new LNSC-2420-Addon board this allows to switch
on a high-power heater connected directly to the solar panels whenever
the temperature is too low to charge the battery. Once the temperature
becomes high enough again, the heater is switched off and the battery is
charged instead.
If communication times out or a NAK is received, this is now recognized
and sensor values are flagged as invalid. The communication then
restarts on the next regular cycle. This is still to be tested.
This version uses only blocking i2c calls, and long transfers will
probably cause frame loss. Also, if no BMP280 is present, the firmware
will not start up and hang in an endless loop instead.
Unfortunately, the offset voltage of the opamp for charge current
measurement breaks measurement at low currents with a small shunt, so at
dusk, when currents become low, it may happen that 0 current is measured
while the battery is still being charged. This would falsely trigger the
transition to sleep state. To improve this situation, we simply keep the
charger active for a longer time.
Before this change, initial charging ended exactly HOLD_TIME after the
CHARGE_INITIAL state was entered. This was usually not sufficient to
reach the INITIAL_FULL voltage. Now a new state is entered once the
INITIAL_FULL voltage is reached.
The measurement module now provides averaged measurements. These are
used in some places where accuracy is more important than latency (for
example for the temperature limit, where noise triggered the limit too
early).
This is most important for the LEDs and the RS485 interface. If any LED
is on when deep sleep is entered, it will stay on the whole sleep time,
drawing about 10 mA on the 3,3V rail.
The RS485 transceiver must be switched to RX mode, as it consumes about
30 mA from the 5V rail in TX mode.
- Run ADC Calibration on startup (without calibration, there is a huge
offset error, making the current sensing unusable)
- Added calibration factors which allow to compensate for inaccuracies
in the circuitry (example: 1% tolerance transistors)
- Send measured values via RS485