I know it's old question but just in case someone will look for it in the future, here's how I made it to work:
First the wiring, datasheet on Maxim is misleading at least for me. So looking straight at the FLAT side of the EEPROM, going from left to right you have: GND, IO, NC.
- Connect GND pin to any of the RPi's GND GPIO directly.
- Connect IO pin to RPi's GPIO 4 (fourth from the left in the bottom row looking on RPi's such that power USB is towards you)
- Connect 4.7K (4700) Ohm resistor BETWEEN IO pin of EEPROM and wire that goes to RPi's GPIO 4, other side of this resistor stick directly to 3.3V output of RPi
Here's a very pretty drawing of how it should be connected:
Now the software part. I'm using fresh installation of Raspbian Stretch Lite from 2018-06-27 on Raspberry Pi 3B+, SSH enabled.
First run sudo raspi-config
, go to 5 Interfacing Options
and then P7 1-Wire
, answer Yes
then reboot.
Alternatively you can edit /boot/config.txt
file and put that line at the end: dtoverlay=w1-gpio
and reboot.
Now ls /sys/bus/w1/devices
you should see two folders/links here:
w1_bus_master1
and 2d-000022b489f8
(name may vary, but must start with 2d-, if it starts with 00- or you have only w1_bus_master then something's not connected properly).
Now sudo modprobe w1_ds2431
. After this cd
into your 2d-*
directory and after you do ls
you should see file named eeprom
there (it will only appear after modprobe w1_ds2431
so that's important step). This is your point of entry.
To write into the eeprom: echo 'Hello world' | sudo tee eeprom
(we need root privileges to write, so we use tee
command here).
To read from eeprom: cat eeprom | hexdump -Cv
(no root needed).
Example output:
pi@raspberrypi:/sys/bus/w1/devices/2d-000022b489f8 $ echo 'Hello world' | sudo tee eeprom Hello world
pi@raspberrypi:/sys/bus/w1/devices/2d-000022b489f8 $ cat eeprom | hexdump -Cv
00000000 48 65 6c 6c 6f 20 77 6f 72 6c 64 0a 00 00 00 00 |Hello world.....|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000080
To make w1_ds2431 module loaded on boot (so there will be no need for modprobe w1_ds2431 each time RPi is rebooted) edit /etc/modules
file and add this line: w1_ds2431
. With this in place eeprom
file will be ready to use automatically after reboots.
Hope it would help someone as I was looking all over internet for how to use DS2431 with RPi and all I found was that darn thermometer :D