How do I force the system to detect a GPIO device has been connected or disconnected?

For instance, I'm playing with the DS18B20 temperature sensor, and I noticed that immediately after connecting it, it does not show in /sys/bus/w1/devices, it only appears after a few seconds.

When I disconnect it, it seems to take much longer (more than 10 seconds) until it finally disappears from the w1 devices list.

I'd like to know exactly how long it takes, or to force a refresh of the list of connected devices.

PS: I'm using Raspbian, in case it is relevant for the answer.

  • I see the same behaviour after disconnecting the sensor, it takes around 100 seconds to recognise disconnection of a sensor, new sensor is recognised almost immediately. Any solution since then? – Lukas Oct 3 '16 at 22:21

Wish I had a 1 wire device to test this on, but I am going to take a stab in the dark here. Does this reduce the interval time:

modprobe wire timeout=1

or add to your /etc/modules.conf:

wire timeout=1

I could not find any relevant settings in the w1_gpio module (and rightly so) and I am assuming "w1_master_timeout - the delay in seconds between searches" in the wire (w1.c) module is the right setting. You can view the current setting by running:

cat /sys/bus/w1/drivers/w1_master_driver/w1_bus_master1/w1_master_timeout
  • I tried doing it, but it didn't seem to help much. I tried timing more precisely the detection times: disconnection was detected after about 90 seconds, while reconnection only took about 5 seconds to be detected. The time seems to be unaffected by the value set with modprobe. Reading the current setting of the master timeout yields 10. – anol Apr 20 '14 at 16:06

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.