HCPBridge Documentation GitHub

Sensors

Up to six optional sensors can be connected to the bridge. They are enabled in the web interface – one firmware for all combinations.

Supported sensors

SensorInterfaceMeasuresMQTT keys
BME280I²C (0x76 / 0x77)Temperature, humidity, pressuretemp, hum, pres
DS18X20OneWireTemperature (first sensor on the bus)temp
DHT22Single wireTemperature, humiditytemp, hum
HC-SR04Trigger / echoDistance, parking spacedist, free
HC-SR501DigitalMotion (PIR)motion
MQ4Analog (+ optional digital)Methane / natural gasgas, gas_alarm

Default GPIOs per board are listed in the configuration reference.

Enable a sensor

  1. Connect itwith the board powered off. On the prebuilt PCBs solder pin headers to the sensor pads first.
  2. Open Sensor Configurationtick the sensor and check its GPIO numbers.
  3. Save & RestartThe sensor is initialised at boot. If it works, it appears as a tile in the web interface and as an entity in Home Assistant.
  4. CheckSystem information lists every sensor as Active, Disabled (failed) or Off.

How sensors are read

Start-up detection

Each enabled sensor gets up to 3 attempts at boot. It only becomes active if it delivers a plausible reading:

SensorAccepted at start-up when …
BME280found at 0x76 or 0x77 and temperature −50…80 °C, humidity 0…<99.9 %, pressure 300…1100 hPa
DS18X20temperature −50…80 °C
DHT22after a 2 s warm-up both temperature and humidity are valid
HC-SR04an echo is received and the distance is > 0 and ≤ 2 × SR04 max. distance
HC-SR501a pin is configured
MQ4the analog value is between 1 and 4094 (not stuck at 0 or full scale)

A sensor that fails is marked Disabled; the bridge keeps booting normally and the reason is published in sensor_error of the debug topic.

Polling, thresholds and publishing

Fail-safe

Several temperature sensors

Only one temperature and one humidity value is published. Priority: BME280 → DS18X20 → DHT22. If a BME280 is enabled, DS18X20 and DHT22 values are not used (even when the BME280 failed).

Sensor details

BME280

Connect VCC (3.3 V), GND, SDA and SCL. The address (0x76 or 0x77) is detected automatically. Pressure is shown in mbar in the web interface and published as hPa (same value).

DS18X20

Only the first sensor on the OneWire bus is read. Self-built boards need the usual 4.7 kΩ pull-up between data and 3.3 V.

DHT22

Reads temperature and humidity. If only one of both values is valid, that one is still used; only when both are invalid does it count as a failed reading.

Parking space detection (HC-SR04)

Mount the sensor above the parking space, pointing down (or at the front wall, pointing at the car). It publishes the measured distance (dist, cm) and whether the space is free (free).

Calibration happens after every restartThe reference distance is not stored. If a car is parked while the bridge restarts, the car's roof becomes the reference and the space is reported as free until the car has left once. Also note that the parking state is only updated every Sensor query interval – lower it (e.g. 10–30 s) if you want a faster reaction.

Readings above twice the SR04 max. distance are treated as invalid. The HC-SR04 is a 5 V module – on self-built boards bring its echo signal down to 3.3 V with a voltage divider.

HC-SR501 motion

Polled every 500 ms; every change is published immediately as {"motion":"true"} / {"motion":"false"}. Hold time and sensitivity are set with the potentiometers on the module.

MQ4 gas