rasProject_01 / weSweetHome  R. 146 2026-09-26
process control       /     RasPi software         by   weinert-automation
Loading...
Searching...
No Matches
sweetHome2.h File Reference

Types, values and functions for a smart home project. More...

#include "weBatt.h"
#include "weStateM.h"
#include "sweetHome.h"
#include "weGPIOd.h"
#include "mqttHome.h"
#include "we1wire.h"
#include <errno.h>
#include "weModbus.h"

Macros

#define BAT_LD_AL_BALL
 Allow ballast loading.
#define BAT_LD_AL_CONT
 Allow controlled loading.
#define BAT_UNL_P400
 Battery unloading when Pimp > 400W, value 4.
#define BAT_UNL_SUMM
 Summer default for battery unloading, value 3.
#define BAT_UNL_WINT
 Winter default for battery unloading, value 3.
#define BEFORE_RISE
 Before sunrise timer offset.
#define CHS_CP_OFFSET
 CP signal PWM correction offset.
#define CONcarLd
 Contactor (relay) power to car is ON (low active).
#define CONcarRq
 Car (CP resistor 2k7) connected / ready (low active).
#define hotWatPmpCntlTimOffLog
 do log hotWater pump control timer Off
#define hotWatPmpCntlTimOnLog
 do log hotWater pump control timer On
#define hotWatPmpSchTimLog
 no log hotWater pump schedule timer
#define hotWpmpButLog
 no log hotWater pump button timer
#define HWPB
 push button switch for hot water pump lo-active
#define HYPr
 Battery to Hippogreiff (cable wire ws/gn).
#define INVu
 Inverter to battery step up.
#define isOnPPSrel()
 Check if the phase power switch control relay is on.
#define LED9
 life LED hi active
#define LEDx
 other LED hi active (currently unused, always on)
#define NUM1W_SENSORS
 Number of 1-wire sensors.
#define offPort(N)
 Switch port N off.
#define offRel(N)
 Switch relay N off.
#define onPort(N)
 Switch port N on.
#define onRel(N)
 Switch relay N on.
#define PCK_POWER_IND_MAX
 phase packet control limit 200%
#define PCK_POWER_LIM_DEF
 phase packet default limit 3,6kW
#define PCK_POWER_LIM_MAX
 phase packet max. limit
#define PCK_POWER_REL
 phase packet switch control relay
#define PDEL_BALEND
 Minimal solar power to leave ballast loading SFC.
#define PDEL_BALINC
 Delivery power low limit to add ballast.
#define PDEL_BALRED
 Delivery power to reduce ballast.
#define PDEL_SGCONS
 Minimal delivery power (W) to signal consumer.
#define PDEL_SGGIVE
 Maximal delivery power to signal give away.
#define PH_P_SSR1
 Phase packet switch SSR1 (heater element 1).
#define PH_P_SSR2
 Phase packet switch SSR2 (heater element 2).
#define PHPK_BALINC
 Heater phase pack percentage limit to add ballast.
#define PHPK_BALRED
 Heater phase pack percentage limit to add ballast.
#define POWH
 Power module voltage control (li/br-ws).
#define PWMcarLd
 PWM to control max. car load current (per phase).
#define REL1
 Pin for low active relay 1: PIN11.
#define REL1msk
 Mask bit for relay 1.
#define REL2
 Pin for low active relay 2: PIN12.
#define REL2msk
 Mask bit for relay 2; value 0x02.
#define REL3
 Pin for low active relay 3: PIN13.
#define REL3msk
 Mask bit for relay 3; value 0x04.
#define REL4
 Pin for low active relay 4: PIN15.
#define REL4msk
 Mask bit for relay 4; value 0x08.
#define REL5
 Pin for low active relay 5: PIN16.
#define REL5msk
 Mask bit for relay 5; value 0x10.
#define REL6
 Pin for low active relay 6: PIN18.
#define REL6msk
 Mask bit for relay 6; value 0x20.
#define REL7
 Pin for low active relay 7: PIN22.
#define REL7msk
 Mask bit for relay 7; value 0x40.
#define REL8
 Pin for low active relay 8: PIN03.
#define REL8msk
 Mask bit for relay 8; value 0x80.
#define SENS0PATH
 SENS0PATH Temperature of water tank (top level).
#define SENS1PATH
 Temperature of hot water pipe.
#define SENS2PATH
 Temperature of water tank (bottom level).
#define switchPPSrel(V)
 Actuate phase power switch control relay.
#define switchRel(N, V)
 Switch relay N on or off.
#define watTempBadMeasLog
 do log > 251 bad water temperature reads
#define webHMIcommandsLog
 no log HMI commands
#define wouldGiv250W_Log
 no log >= 250W surplus power

Functions

void changeBatLoadPWM (int pwmChg)
 Change battery loader module PWM.
void logBatteryState ()
 Log battery state on outLog as line with time stamp.
uint8_t pckSwPec (float power)
 Set and get package switch percentage by power.
void setBatLoadPWM (int pwm)
 Set battery loader module PWM.
uint8_t setPckSwPerc (uint8_t perc)
 Set package switch percentage.
float setPhPckLimit (float powerLimit)
 Set and get package switch power limit.
void startBatBallLoad (char const *startCommand)
 Start battery ballast load operation.
void startBatteryKeep (char const *startCommand)
 Start battery keep operation.
void startBatteryLoad (char const *startCommand)
 Start battery normal load operation.
void startBatteryUnl (char const *startCommand)
 Start battery unload operation.
void stopBatteryOps (char const *stopCommand)
 Stop any battery load or unload operation.
void switchBatToStepUp (uint8_t on)
 Switch battery to step up converter.
void switchHotWpump (uint8_t const on)
 Hot water comfort pump turn on/off.

Variables

state_t batBalLodSeq
 Battery controlled load as ballast.
state_t batCntLodSeq
 Battery loading and keeping.
state_t batKeepInh
 Inhibit battery keep alive loading.
int batLoadAllowed
 Battery loading allowed.
float batLoadPower
 Battery charging power when valid.
uint8_t batLoadPowValid
 Battery charging power is valid.
volatile int batModPWM
 The actual battery load module's PWM input.
int batUnloadAllowed
 Battery unload allowed.
state_t batUnloadSeq
 Battery controlled unload via inverter.
uint8_t batVoltValid
 The measured battery voltage is valid.
state_t befRiseTimer
 Before sunrise timer.
state_t consumeGiveHyst
 Give away hysteresis.
state_t consumeGiveSFC
 Give away state machine / SFC.
state_t dawnTimer
 Dawn timer.
state_t duskTimer
 Dusk timer.
uint8_t heaterAllowed
 phase packet load enabled (always)
int hippoSwitchMode
 Hippogreiff on/off times.
state_t load250Wcont
 Controlled load SFC.
volatile uint16_t logBatStrCnt
 counter to log battery state if < 3
volatile uint nologBatCap
 Control logging inhibit charging battery due to capacity limit.
volatile uint8_t phPckCnt
 current switch state duration counter
volatile uint8_t phPckOff
 current phase packet switch OFF duration
volatile uint8_t phPckOn
 current phase packet switch ON duration
volatile uint8_t phPckRelOffDelay
 PPS relay off delay.
volatile uint8_t phPckS2
 heater 2 pps switch state: 0 off; 1 on
volatile uint8_t phPckSw
 phase packet switch state: 0 off; 1 on
volatile uint8_t phPckSwIndex
 Actual index (0..200%) determining power.
volatile uint8_t phPpow2
 heater 2 power * 50% (0:0% .. 2:100%)
float pStdW
 actual power delivery to home
oneWireDevice_t sensors [3]
 The 1-wire sensors used.
state_t solarPowerHyst
 Solar power producer hysteresis.
state_t sunriseTimer
 Sunrise timer.
state_t sunsetTimer
 Sunset timer.
state_t wouldGive250WHyst
 Would give away 250W hysteresis.
state_t wouldGiveAwayHyst
 Would give away hysteresis.

Detailed Description

Types, values and functions for a smart home project.

Copyright (c) 2018 - 2026 Albrecht Weinert
weinert-automation.de a-weinert.de
/ / /\
/ /___ / \ |
\ /____\ /____\ | _|__
\ /\ / \ / \| |
\/ \/ \__/ \__/|_

Revision history

Rev. 148 8.10.2026
Rev. 99 29.01.2018 : load module voltage handling added
Rev. 148 16.06.2018 : battery ballast handling improved, Hippogreiff relay
Rev. 170 24.07.2018 : temperature sensors documentation
Rev. 190 12.02.2019 : remove 4 status relay output as (minimal) preparation
for VDE-AR-N 4105 evaluation and inverter cut off
Rev. 218 07.09.2019 : MQTT excerpted to mqttHome.h
Rev. 241 12.08.2021 : battery values updated (200Ah ++)
Rev. 252 17.08.2023 : ECar loading feature added
Rev. 255 17.03.2024 : flexible Hippogreiff switching times
Rev. 259 04.08.2024 : battery changed to ECO-WORTHY 12.8V 100Ah LiFePO4
Rev. 79 21.03.2025 : meterPi and Hager contactor to M2=L3
Rev. 85 14.06.2025 : miniJoule inverter replaced - cleanup
Rev. 87 03.07.2025 : solarPowerHyst values and discharge limit
Rev. 90 06.08.2025 : battery SOC/% <-> Ubat; loader test prep.
Rev. 92 15.08.2025 : load unload values and SFCs (Rev. 92..94, 02.09.)
Rev. 111 10.01.2026 : battery load and keep changed (Rev. 111..112, 21.1.)
Rev. 123 29.06.2026 : PDEL_BALEND increased as often triggered (experimental)
Rev. 142 28.08.2026 : interchange relays BATu and INVu
Rev. 145 20.09.2026 : comment corr.
state_t solarPowerHyst
Solar power producer hysteresis.
Definition sweetHome2.c:1082
#define PDEL_BALEND
Minimal solar power to leave ballast loading SFC.
Definition sweetHome2.h:223
oneWireDevice_t sensors[3]
The 1-wire sensors used.
Definition sweetHome2.c:59
#define INVu
Inverter to battery step up.
Definition sweetHome2.h:321

This file is the addendum to sweetHome.h and sweetHome.c. It contains process IO related issues. These are not necessary for programs related to pure HMI, logging and the like. For those programs sweetHome.h and sweetHome.c will be sufficient.

In the smart home under control, there's one smart meter for the whole house's public electricity supply and one for solar generators and battery storage. The (two, cf. ANZmodSLAVES) meters are connected by Modbus. Additionally and also via Modbus, a Growatt inverter offers power and other values. Those are made available via an extra Pi acting as Modbus to MQTT bridge.

GPIO usage

See also file /forDSocu/Raspi3ioPinsMeterPi.ods

GPIO pins are used to control relays, LEDs and one button in the Pi's immediate neighbourhood. Three open drain (module) outputs control slightly remote (10m) periphery via shielded cable.

This program uses eight relays (one 10A change over contact each) in an eight relays module. The relays are energised by an active low "Din" (n:1..8) signal.

Eight 10A relays module connected via RS485 converter/shield pin connectors

module : Gnd Di1 Di2 Di3 Di4 Di5 Di6 Di7 Di8 3V3 Gnd 5V
colour : brn blk wht gry vio blu grn yel ora red brn red
RS conv.: Gnd P0 P1 P2 P3 P4 P5 P6 P7 3.3V Gnd 5V
Pi Pin : 6&c 11 12 13 15 16 18 22 3 1 &c 6&c 2&3
GPIO Pi3: 17 18 27 22 23 24 25 2
IO name : REL1 REL2 REL3 REL4 REL5 REL6 REL7 REL8

Other process IO see project file /forDocu/Raspi3ioPinsMeterPi.ods .

Notes on process IO functions

REL1 : defect XX (ex PPS-SSR pre-relay)
REL2 : off miniJoule's Ferraris meter on battery unload (out of use 6'23)
REL3 : not used (ex VDE-AR-N 4105)
REL4 : phase packet switch (PPS-SSR) pre-relay for heater contactor
REL5 : would give away more than 250 W (prolonged 2h)
REL6 : not used (ex VDE-AR-N 4105)
REL7 : not used (ex VDE-AR-N 4105)
REL8 : hot water circulation pump (comfort function)
Note : When searching relay usages search for macros onRel(N), offRel(N)
and switchRel(N, V).
LED9 : red LED; Modbus slave indicator; on: Modbus slave index > 0
LEDx : green LED; no function at the moment, always on
HWPB : start hot water pump (button to GND)
POWH : Battery load power module voltage control (via open drain)
PWM for adjustable 11..14V 10A power module
lo or off: for lowest voltage
BATu : Battery unload (hi active); battery to step up
when battery surveyor signal is OK; two relays in parallel
INVu : inverter input plugs +&-: ex CONb, not used, free for other uses
HYPr : Battery to Hippogreiff
PH_P_SSR1: Phase packet switch SSR1 (heater element 1) 0..100%
PH_P_SSR2: Phase packet switch SSR2 (heater element 2) 0, 50, 100%
PWMcarLd : PWM to control max. car load current (per phase)
CONcarLd : Contactor (relay) "power to car" is set ON (low active OC in)
CONcarRq : Car (i.e. CP resistor 2k7) is connected (low active OC in)
#define ON
true On An marche go.
Definition basicTyCo.h:76
#define onRel(N)
Switch relay N on.
Definition sweetHome2.h:501
#define PWMcarLd
PWM to control max. car load current (per phase).
Definition sweetHome2.h:342
#define PH_P_SSR2
Phase packet switch SSR2 (heater element 2).
Definition sweetHome2.h:340
#define LED9
life LED hi active
Definition sweetHome2.h:303
#define CONcarLd
Contactor (relay) power to car is ON (low active).
Definition sweetHome2.h:343
#define REL4
Pin for low active relay 4: PIN15.
Definition sweetHome2.h:278
#define PH_P_SSR1
Phase packet switch SSR1 (heater element 1).
Definition sweetHome2.h:339
#define HYPr
Battery to Hippogreiff (cable wire ws/gn).
Definition sweetHome2.h:337
#define offRel(N)
Switch relay N off.
Definition sweetHome2.h:513
#define switchRel(N, V)
Switch relay N on or off.
Definition sweetHome2.h:488
#define POWH
Power module voltage control (li/br-ws).
Definition sweetHome2.h:365
#define LEDx
other LED hi active (currently unused, always on)
Definition sweetHome2.h:305
#define REL7
Pin for low active relay 7: PIN22.
Definition sweetHome2.h:281
#define REL5
Pin for low active relay 5: PIN16.
Definition sweetHome2.h:279
#define REL6
Pin for low active relay 6: PIN18.
Definition sweetHome2.h:280
#define REL2
Pin for low active relay 2: PIN12.
Definition sweetHome2.h:276
#define CONcarRq
Car (CP resistor 2k7) connected / ready (low active).
Definition sweetHome2.h:344
#define REL1
Pin for low active relay 1: PIN11.
Definition sweetHome2.h:275
#define HWPB
push button switch for hot water pump lo-active
Definition sweetHome2.h:367
#define REL8
Pin for low active relay 8: PIN03.
Definition sweetHome2.h:282
#define REL3
Pin for low active relay 3: PIN13.
Definition sweetHome2.h:277

MQTT usage

The MQTT protocol is used for remote process IO within "sweet home's" private (W)LAN:
a) battery surveillance and voltage measurement by specialised ESP8266
b) For Sonoff S20 plug switches modified to be MQTT clients (Tasmota).

PLG1 "would give 250 W" = parallel to REL5
PLG2 sunset to sunrise (since 03.03.2018; as Hippogreiff)
PLG3 just controlled by web interface (since August 2019 used
for outside air monitor's supply, to enable remote reset)
PLG4 "actually giving away" (neg. supply) warning

Macro Definition Documentation

◆ SENS0PATH

#define SENS0PATH

SENS0PATH Temperature of water tank (top level).

This is the address of the 1-wire sensor's value file provided by the 1-wire-temp kernel module.
Value of full path: "/sys/devices/w1_bus_master1/28-0113173ecfcc/w1_slave"

See also SENS1PATH SENS2PATH

◆ SENS1PATH

#define SENS1PATH

Temperature of hot water pipe.

This stainless steel sensor is placed by the top hot water outlet pipe within the thermal insulation.
One wire sensor ID since 12 23: 28-6fb4d443009b

See also SENS0PATH.

◆ SENS2PATH

#define SENS2PATH

Temperature of water tank (bottom level).

One wire sensor ID: 28-0113175b35bf

See also SENS0PATH.

◆ PDEL_BALEND

#define PDEL_BALEND

Minimal solar power to leave ballast loading SFC.

Delivery power to leave ballast loading SFC.

See also PDEL_BALEND (and condition).
Value: 110.2 W

See also ::PSOL_BALEND (and condition).
Value: 888.8W

◆ PDEL_BALRED

#define PDEL_BALRED

Delivery power to reduce ballast.

Value: 61.02 W

◆ PDEL_BALINC

#define PDEL_BALINC

Delivery power low limit to add ballast.

Value: 1.02 W

◆ PHPK_BALRED

#define PHPK_BALRED

Heater phase pack percentage limit to add ballast.

Must be >= 0 and <= PHPK_BALRED. See also PDEL_BALRED (and condition). Value: 3

◆ PDEL_SGCONS

#define PDEL_SGCONS

Minimal delivery power (W) to signal consumer.

See consumeGiveHyst.

Value: 45.4 W

◆ PDEL_SGGIVE

#define PDEL_SGGIVE

Maximal delivery power to signal give away.

See consumeGiveHyst.

Value: -1.3 W

◆ REL1msk

#define REL1msk

Mask bit for relay 1.

It is the Mask for this relay in ::valFilVal.by[0]; value 0x01.

See also REL2msk .. REL2msk REL1 .. REL8

◆ INVu

#define INVu

Inverter to battery step up.

Battery form controlled load module to unload step up.

This is one of four relays in an electronic box near inverters and batteries: hi active via open drain and OC drivers connected by cable to the meterPi (wire colour: gr/gr-ws).

This function is not used any longer. A new inverter put in after a defect had a second input for a (non existent) panel that was directly connected to the inverter output.

See also BATu HYPr

These are two of four relays in an electronic box near inverters and batteries: hi active via open drain and OC drivers connected by cable to the meterPi (wire colour: ws/ge-ws).

Both relays are controlled by the same output pin and bot changeover contacts (30A) are connected parallelly to reduce losses by the battery currents. (The battery connection is guarded ba a 50A fuse.)

See also INVu HYPr HIPPO_COMMANDS

◆ CHS_CP_OFFSET

#define CHS_CP_OFFSET

CP signal PWM correction offset.

The CP signal's duty cycle to E-car (+/-12V) might deviate from the microprocessors control signal (TTL); explanation see at DEF_CP_OFFSET.

-27 is the correct value for the (modified) Analog EVSE. Due to asymmetries caused by the optocoupler input the change to Hi state is propagated faster than the one to Lo.

◆ POWH

#define POWH

Power module voltage control (li/br-ws).

See loadModUlookup

◆ switchPPSrel

#define switchPPSrel ( V)

Actuate phase power switch control relay.

For safety reasons there is a contactor (Hager 4 * 40A) in front of the electronic zero crossing switches (solid state relays SSR) for the two heater elements.

The PPS relay (4) actuates this contactor. The Hager contactor consumes about 9W, when actuated. The meterPi and Hager contactor were move from M3=L3 to M2=L3 as not to spoil the ballast load sum.

Parameters
V0: off; else: on

◆ onPort

#define onPort ( N)

Switch port N on.

Parameters
Nport name (LEDx, BATu, INVu ..)

◆ offPort

#define offPort ( N)

Switch port N off.

Parameters
Nport name (LEDx, BATu, INVu, ..)

◆ switchRel

#define switchRel ( N,
V )

Switch relay N on or off.

Parameters
Nrelay number 1..8
V0: off; else: on

◆ onRel

#define onRel ( N)

Switch relay N on.

Parameters
Nrelay number 1..8

◆ offRel

#define offRel ( N)

Switch relay N off.

A module with 8 relays controlled directly by Pi output pins.

Parameters
Nrelay number 1..8

◆ BAT_LD_AL_BALL

#define BAT_LD_AL_BALL

Allow ballast loading.

See also ::batAllowed.

◆ BAT_LD_AL_CONT

#define BAT_LD_AL_CONT

Allow controlled loading.

See also ::batAllowed.

◆ BEFORE_RISE

#define BEFORE_RISE

Before sunrise timer offset.

See also: befRiseTimer value: 248 minutes (since 12.08.2021; 188 before)

Function Documentation

◆ pckSwPec()

uint8_t pckSwPec ( float power)

Set and get package switch percentage by power.

Besides determining an returning the percentage(power), this function sets the process control values via setPckSwPerc() returns its value.

Parameters
powerin W
Returns
the phase packet percentage 0..100

◆ setPhPckLimit()

float setPhPckLimit ( float powerLimit)

Set and get package switch power limit.

This function sets the PPS power limit in the range 0.0 ... PCK_POWER_LIM_MAX.

Parameters
powerLimitPPS power limit in W
Returns
the (new) power limit

◆ setPckSwPerc()

uint8_t setPckSwPerc ( uint8_t perc)

Set package switch percentage.

This function sets phPckSwIndex by the parameter value in the range 0..200; respectively PCK_POWER_IND_MAX. Additionally it adjusts the current phPckCnt should its value be higher than by the new setting.

On transitions from respectively to 0 the control relay (PCK_POWER_REL) is actuated before respectively after actuating the electronic switch.

This function also sets .phPckpower in valFilVal according to the values in table (array) phPckSwPow.

Parameters
perc0..200; values above PCK_POWER_IND_MAX will have no effect and return the current setting un-altered
Returns
the actual (new) phase packet percentage 0..200

◆ switchHotWpump()

void switchHotWpump ( uint8_t const on)

Hot water comfort pump turn on/off.

It turns the hot water comfort circulation pump on respectively off.

Parameters
on!= 0 : on; else, ==0 : off

◆ logBatteryState()

void logBatteryState ( )

Log battery state on outLog as line with time stamp.

Logs the battery voltage in the format

/0123456789x123456789v123456789t123456789q123456789c123456789s123456789S1234567
/ 2019-05-01 11:58:16.600 # battery 1?.05 V, pwmL 000: 13.08V; 1234.6W .
/linefeed

◆ stopBatteryOps()

void stopBatteryOps ( char const * stopCommand)

Stop any battery load or unload operation.

Parameters
stopCommandit is recorded in state_t.controlV of state machine(s) involved; shall have (max.) 6 characters

◆ startBatteryUnl()

void startBatteryUnl ( char const * startCommand)

Start battery unload operation.

Stops all loading and starts unload (if battery charging state allows).

Parameters
startCommandit is recorded in state_t.controlV of state a machine involved; shall have (max.) 6 characters

◆ startBatteryLoad()

void startBatteryLoad ( char const * startCommand)

Start battery normal load operation.

Stops unloading and starts normal battery charging.

Parameters
startCommandit is recorded in state_t.controlV of state a machine involved; shall have (max.) 6 characters

◆ startBatBallLoad()

void startBatBallLoad ( char const * startCommand)

Start battery ballast load operation.

Stops unloading and starts battery charging as ballast.

Parameters
startCommandit is recorded in state_t.controlV of state a machine involved; shall have (max.) 6 characters

◆ startBatteryKeep()

void startBatteryKeep ( char const * startCommand)

Start battery keep operation.

Stops unloading and starts battery charging for a minimal charging state.

Parameters
startCommandit is recorded in state_t.controlV of state a machine involved; shall have (max.) 6 characters

◆ switchBatToStepUp()

void switchBatToStepUp ( uint8_t on)

Switch battery to step up converter.

When the parameter is !=0 respectively ON, this function connects the battery to the step up converter (12V DC to 56V DC) feeding one input of a solar inverter (40..60V DC to 230V ~).

When the parameter is 0 or OFF, the step up converter will be disconnected resp. turned off.

Parameters
ontrue: switch battery to step up converter; 0, false: turn step up converter off.

◆ setBatLoadPWM()

void setBatLoadPWM ( int pwm)

Set battery loader module PWM.

This function sets the battery load module power PWM signal and hence its output voltage. 0 is the lowest and 255 the highest possible setting. While this function allows setting to 0, the highest value is limited to BAT_LDMX_PWM.

Parameters
pwmthe pwm ratio 0: 0%; 255: 100%

◆ changeBatLoadPWM()

void changeBatLoadPWM ( int pwmChg)

Change battery loader module PWM.

This function adds the parameter pwmChg's value to the current one limits the result to BAT_NOLD_PWM ... BAT_LDMX_PWM and sets it (see setBatLoadPWM).

Parameters
pwmChgthe change of the pwm value

Variable Documentation

◆ hippoSwitchMode

int hippoSwitchMode
extern

Hippogreiff on/off times.

time: dusk | dawn | set | rise
switch: on | off | on | off
bit: 3 | 2 | 1 | 0
value: 8 | 4 | 2 | 1

Bit 1,0, ( 3): switch at sunset resp. sunrise (winter)
Bit 3,2 (12): switch at dusk resp. dawn (summer)
See also HIPPO_COMMANDS.

◆ sensors

oneWireDevice_t sensors[3]
extern

The 1-wire sensors used.

See also NUM1W_SENSORS.

◆ phPckSwIndex

volatile uint8_t phPckSwIndex
extern

Actual index (0..200%) determining power.

This is the control variable for the electric heater elements in the hot water tank. Until June 2023 there was one such element of PCK100PERC_POWER W and this variable had a range of 0..100%. Since July 2023 there are two heater elements of equal power. The range of this control variable was extended to 0..200%. The power distribution between the two heater elements is done by software; see setPckSwPerc(uint8_t const perc) and PCK_POWER_IND_MAX

◆ batVoltValid

uint8_t batVoltValid
extern

The measured battery voltage is valid.

When not 0 the last MQTT battery voltage measurement respectively message is not older than 2.4s and hence considered the actual valid value.
6..240 = uBat and SOC by Bluetooth; 1..5 = uBat by ADU

◆ nologBatCap

volatile uint nologBatCap
extern

Control logging inhibit charging battery due to capacity limit.

1: log next time when it occurs and (always) decrement 0: or high value log no more this day. n: inhibit the next 2*n seconds while continually trying

◆ batKeepInh

state_t batKeepInh
extern

Inhibit battery keep alive loading.

This timer will be started after battery loading and unloading for a specific time BATkeepInhContLoad, BATkeepInhUnload or BATkeepInhByCmd. This timer is initially OFF and will be stopped in advance by battery keep command via HMI/GUI.
It will be started after battery unload, after battery ballast load and by battery off command via GUI.
When running out it will start battery keep alive with BAT_KEEP_PWM by startBatteryKeep.

Note: The feature seems/is unnecessarily complicated due to its lead acid battery past

◆ batUnloadAllowed

int batUnloadAllowed
extern

Battery unload allowed.

Bit 0 (1): allow after sunset
Bit 1 (2): allow before sunrise
Bit 3 (4): allow when Pimp > 400W, i.e. allow also at daylight.
Bit 4 (8): default (usually 2 in winter and 3 in summer)
Start value: 8 = default
Note: Must be a standard integer (no uint_8 e.g.) for use in getopt_long.

See also BAT_UNL_SUMM BAT_UNL_WINT BAT_UNL_P400

◆ batLoadAllowed

int batLoadAllowed
extern

Battery loading allowed.

Bit 0 (1): allow ballast loading
Bit 1 (2): allow automatic / controlled loading
start value: 3 = all allowed
Note: Must be a standard integer (no uint_8 e.g.) for use in getopt_long.

See also
batUnloadAllowed
BAT_LOAD_FORBID

◆ batModPWM

volatile int batModPWM
extern

The actual battery load module's PWM input.

The range of the Pi's pwm output control register 0 for 0 % or permanent off to 255 for 100% respectively permanent on. The eight bit register, hence, is to be fed with an unsigned 8 bit value which was for many years the type of this variable.
A new loader module since August 2025 uses the full range 0..255. This variable was made a standard int to simplify underflow and overflow detection.
Note: Keeping this variable's value in the range 0 .. +255 is essential!

◆ sunriseTimer

state_t sunriseTimer
extern

Sunrise timer.

This timer will run out every day at (approximated) sunrise. For the "every day" behaviour, its state change function will — after all due actions — restart this timer for the next 24h to hit (very approximately) the next sunrise. This acceptable guess will be adjusted at day change or at program start.

◆ sunsetTimer

state_t sunsetTimer
extern

Sunset timer.

This timer will run out every day at (approximated) sunset. See also sunriseTimer

◆ dawnTimer

state_t dawnTimer
extern

Dawn timer.

This timer will run out every day at (approximated) dawn, meaning the beginning of civil twilight. See also sunriseTimer and duskTimer

◆ duskTimer

state_t duskTimer
extern

Dusk timer.

This timer will run out every day at (approximated) dusk, meaning the end of civil twilight. About this time street lamps and position lights may be lit. See also sunriseTimer

◆ befRiseTimer

state_t befRiseTimer
extern

Before sunrise timer.

This timer will run out every day at about 180 min before (approximated) sunrise. The offset must be sufficient time to unload the battery before sunrise.
See also: sunriseTimer BEFORE_RISE

◆ solarPowerHyst

state_t solarPowerHyst
extern

Solar power producer hysteresis.

The limits of the power of the biggest (or all) PV panels to recognise the availability / generation of solar power.
Current limits 7.9W (off), 40.0 W (on); since 03.07.2025
Former values 4.8, 12.02

◆ consumeGiveHyst

state_t consumeGiveHyst
extern

Give away hysteresis.

thresholds: PDEL_SGGIVE, PDEL_SGCONS

◆ consumeGiveSFC

state_t consumeGiveSFC
extern

Give away state machine / SFC.

Status ON means consumer: OK.
Status OFF means very low power consumption: Inhibit power delivery.

◆ wouldGiveAwayHyst

state_t wouldGiveAwayHyst
extern

Would give away hysteresis.

thresholds (04.03.18): -/+ 7W

◆ wouldGive250WHyst

state_t wouldGive250WHyst
extern

Would give away 250W hysteresis.

thresholds (04.03.18): -250 / -178W

◆ batLoadPowValid

uint8_t batLoadPowValid
extern

Battery charging power is valid.

Currently (2018..22026) the electric water tank heater and battery charging share a power meter. It will yield charging power (0..270 W) as ..batLoadPower if and only if water heating (0..4 kW) is off. The criterion is the contactor to the water heaters is off or all electronic relays (SSRs) to the resistor strads are off.

◆ batLoadPower

float batLoadPower
extern

Battery charging power when valid.

See batLoadPowValid.