1

According to the documentation for w1-therm:

Writing a value between 9 and 12 to the sysfs w1_slave file will change the precision of the sensor for the next readings. This value is in (volatile) SRAM, so it is reset when the sensor gets power-cycled.

To store the current precision configuration into EEPROM, the value 0 has to be written to the sysfs w1_slave file. Since the EEPROM has a limited amount of writes (>50k), this command should be used wisely.

I can read the w1_slave file(s) easily enough:

pi@xenon:~$ cat /sys/bus/w1/devices/28*/w1_slave
a0 01 80 80 1f ff 80 80 f5 : crc=f5 YES
a0 01 80 80 1f ff 80 80 f5 t=26000

But I haven't yet figured out how to write them:

pi@xenon:~$ sudo echo 12 >/sys/bus/w1/devices/28-0315549b98ff/w1_slave 
-bash: /sys/bus/w1/devices/28-0315549b98ff/w1_slave: Permission denied

Any insight into how to make this work.

2

The permissions problem is because the redirection (>) is done before sudo takes effect.

Try the following invocation.

sudo sh -c "echo 12 >/sys/bus/w1/devices/28-0315549b98ff/w1_slave"

This should run the shell with sudo and then issue the command.

  • Thanks! And I subsequently learned that writing a zero tells the driver to write it into the device's EEPROM, thereby making it permanent. – Eric Nelson Aug 25 '17 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.