An ESP32-based 1-Wire interface supporting access with physical ethernet and MQTT protocol.
Overview
Hardware
- Access 1-wire devices via ethernet / MQTT protocol
- 4 independent 1-Wire channels with hardware bus masters
- Over-the-air (OTA) updates (web interface and espota protocol)
- Multiple independent 1-wire buses.
- Responsive web interface

-
DS2401 / DS2411 (Silicon Serial Number)
- Unique Unique 64-Bit Serial Code
-
DS18B20 (Temperature sensor)
- Configurable resolution temperature
-
DS2438 (Smart Battery Monitor)
- Temperature, VAD, VDD
Default login:
- Username:
admin - Password:
1w-If
%topic% is a configurable prefix. Default: 1wIf
General MQTT topic for commands: %topic%/cmd
General MQTT topic for responses: %topic%/stat
Payload Format:
{
"action": "<command>",
... action specific parameters / attributes ...
}
Restart the entire system.
{
"action": "restart",
}
Response:
{
"action": "restart",
"acknowledge": true
}
Scan 1-wire buses for all available devices:
{
"action": "scan",
}
Scan 1-wire buses for availability of a specific device:
{
"action": "scan",
"device_id": "01.D2C79A1A0000"
}
Scan 1-wire buses for availability of a specific device family:
{
"action": "scan",
"family_code": 40
}
The response lists all available devices and the supported attributes (for Read / Subscribe / Unsubscribe commands):
Example Response:
{
"action": "scan",
"devices": [
{
"channel": 1,
"device_id": "01.D2C79A1A0000",
"presence": true,
"attributes": ["presence"]
},
{
"channel": 1,
"device_id": "28.8F0945161301",
"presence": true,
"attributes": ["presence", "temperature"]
},
{
"channel": 2,
"device_id": "26.563743020000",
"presence": true,
"attributes": ["presence", "temperature", "VAD", "VDD"]
},
...
]
}
Read value(s) of a single 1-wire device:
{
"action": "read",
"device_id": "28.8F0945161301",
"attribute": "temperature"
}
Example Response:
{
"action": "read",
"device": {
"channel": 1,
"device_id": "28.8F0945161301",
"temperature": 24.75
}
}
Read value(s) of a specific device family:
{
"action": "read",
"family_code": 40,
"attribute": "temperature"
}
Example Response:
{
"action": "read",
"family_code": 40,
"devices": [
{
"channel": 1,
"device_id": "28.8F0945161301",
"temperature": 24.75
},
...
]
}
Also the presence of a device can be accessed via the read command using the attribute presence.
This is similar to the scan command.
{
"action": "read",
"device_id": "28.8F0945161301",
"attribute": "presence"
}
Example Response:
{
"action": "read",
"device": {
"channel": 1,
"device_id": "28.8F0945161301",
"presence": true
}
}
Subscribe to cyclic updates for 1-wire device attributes.
After successful subscription this triggers internally a Read command with the configured internal time.
Unit of 'interval': milliseconds
{
"action": "subscribe",
"device_id": "28.8F0945161301",
"attribute": "temperature",
"interval": 1000
}
Example response acknowledging the successful subscription:
{
"action": "subscribe",
"acknowledge": true,
"device": {
"device_id": "28.8F0945161301"
}
}
Unsubscribe from the attribute:
{
"action": "unsubscribe",
"device_id": "28.8F0945161301",
"attribute": "temperature"
}
It is also possible to subscribe to the attribute presence to get cyclic updates about the availability of dedicated
devices:
{
"action": "subscribe",
"device_id": "01.D2C79A1A0000",
"attribute": "presence",
"interval": 2000
}
Example of the Read command for attribute presence cyclically triggered by the subscription:
{
"action": "read",
"device": {
"device_id": "01.D2C79A1A0000",
"presence": false
}
}
# Build firmware
./build.sh
# Flash firmware + LittleFS filesystem
./flash-fs.sh
# Optional: Monitor via serial outputs
./monitor.sh
Run tests
cd test
pdm install --dev
# Create a test_env_config.yaml in the test directory
cp example_test_env_config.yaml test_env_config.yaml
# Adapt all MQTT / device settings test_env_config.yaml
vim test_env_config.yaml
# Execute tests
pdm run tests
# Alternative: with filter
pdm run tests -k "<test name filter>"
# Lint/Format of test implementations
pdm run lint
pdm run format
- PCB designed with KiCad
- Production files created with KiCad plugin KiCAD JLCPCB tools

