The DS2413 Hat prototype must be used with a M-Bus Master DS – not a regular M-Bus Master. Follow the instructions here, under M-Bus Master Hat DS to set it up, in particular enabling the one-wire bus.
Next, install the DS2413 Hat, and the M-Bus Master Hat DS. The DS2413 Hat ships with 14mm and 12mm standoffs. Install the DS2413 Hat on the Pi, using the 14mm standoffs. Then install the M-Bus Master Hat on the DS2413 Hat using the 12mm standoffs.
Boot the Pi, and test the M-Bus Master Hat DS using the instructions, checking that you can read the temperature sensor on board the M-Bus Master Hat DS.
The easiest way to drive the DS2413 is using the 2100h script here. To install it:
sudo modprobe w1-ds2413
chmod +x ./2100h
Then scan the bus, using the 2100h script – this should give output similar to this:
Found 1-Wire devices:
The 28-xxxxxxxxxxxx device is the M-Bus Master Hat DS18B20 temperature sensor.
The 3a-xxxxxxxxxxxx devices are the DS2413 devices installed on the DS2413 Hat.
To read the state of the 2 pins attached to the DS2413 device:
./2100h r 3a-00000046e190
To write both pins to state 1:
sudo ./2100h w 3a-00000046e190 1 1
Ports and Wiring
There are 2 x 3-pin ports associated with each DS2413. The pins for each port are:
- IO (input/output driven by/read by DS2413)
- Voltage (if selected using the header pins above the DS2413 – this can be 3.3V or 5V)
Each IO pin can either be used as an input or output, see the datasheet for more information. The DS2413 can be driven using the 2100h script, linked to above.
The DS2413 Hat is a prototype. It therefore has some known issues which are expected to be resolved in the production version.
- There are only 2xDS2413 ICs, with 4 ports total (4 x IO pins) supported. This is because the other 2 ports foul the underside of the M-Bus Master Hat, so cannot be populated.
- There is no one-wire pull-up resistor on the DS2413 Hat. Therefore it must be installed with the M-Bus Master DS Hat (which does have a one-wire pull-up resistor installed). Alternatively, an external pull-up resistor can be connected to physical pin 7 (Broadcom GPIO4) of the Raspberry Pi.