Skip to content

renshao/foxess-feeder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

foxess-feeder

Polls a FoxESS H3 PRO inverter via Modbus TCP every 10 seconds and writes readings to InfluxDB 2.

Registers polled

Field Description Unit
battery_soc Battery state of charge %
battery_voltage Battery voltage V
battery_temp Battery temperature °C
battery_power Battery charge/discharge power (negative = charging) kW
inverter_temp Inverter temperature °C
load_power House load power kW
grid_ct Grid import/export via CT clamp (negative = export) kW
gen_load CT2 external generation (e.g. separate solar inverter) kW
pv1_power PV string 1 power kW
pv2_power PV string 2 power kW

Requirements

  • FoxESS H3 PRO inverter with Modbus TCP enabled (port 502)
  • InfluxDB 2 instance
  • Rust toolchain (for building)

Configuration

All configuration is via environment variables.

Variable Required Default Description
FOXESS_MODBUS_IP Yes Inverter LAN IP address
INFLUXDB_URL No http://localhost:8086 InfluxDB base URL
INFLUXDB_TOKEN No foxess-local-token InfluxDB auth token
INFLUXDB_ORG No home InfluxDB organisation
INFLUXDB_BUCKET No inverter InfluxDB bucket
DEBUG No unset Print register values to stdout each poll

Building

cargo build --release

Cross-compile for Raspberry Pi (from Mac M1)

brew install messense/macos-cross-toolchains/aarch64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
cargo build --release --target aarch64-unknown-linux-gnu

Binary will be at target/aarch64-unknown-linux-gnu/release/foxess_feeder.

Running

FOXESS_MODBUS_IP=192.168.0.x ./foxess_feeder

With debug output:

DEBUG=1 FOXESS_MODBUS_IP=192.168.0.x ./foxess_feeder

On startup the program prints one line once the first successful poll and InfluxDB write completes:

Connected to inverter and InfluxDB. Polling every 10s.

Behaviour

  • Reconnects automatically if the Modbus TCP connection drops (30s delay between attempts)
  • InfluxDB write failures are logged but do not trigger a reconnect
  • Each Modbus read has a 15s timeout to handle half-open TCP connections
  • Writes to the inverter measurement in InfluxDB line protocol

Running as a service on Raspberry Pi

Create /etc/systemd/system/foxess-feeder.service:

[Unit]
Description=FoxESS inverter data feeder
After=network-online.target
Wants=network-online.target

[Service]
Environment=FOXESS_MODBUS_IP=192.168.0.x
Environment=INFLUXDB_URL=http://your-server:8086
Environment=INFLUXDB_TOKEN=your-token
ExecStart=/usr/local/bin/foxess_feeder
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Then:

sudo systemctl enable --now foxess-feeder

About

Read battery data from FoxESS inverter and feed to analytics data store

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages