tatery
Posts: 2
Joined: Wed May 04, 2016 1:04 pm

RPi as 1wire slave

Mon Oct 17, 2016 10:51 am

Hi,

I'd like to use RPi as 1-wire slave for my home project. Do you think it is feasible? If yes then how to configure device tree to reuse the same pin for 1wire slave as it is for 1wire master (gpio 4)?

Thanks for any comments on that.

scotty101
Posts: 3583
Joined: Fri Jun 08, 2012 6:03 pm

Re: RPi as 1wire slave

Mon Oct 17, 2016 12:33 pm

The built in kernel module for 1wire only supports being used as a master.

You'd probably have to write your own code to make it act as a slave.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

tatery
Posts: 2
Joined: Wed May 04, 2016 1:04 pm

Re: RPi as 1wire slave

Thu Oct 20, 2016 11:24 am

Thanks scotty101 for your answer. You are right, I'm going to write own code for slave but I don't know how to setup device tree to use my code on RPi GPIO4 (current 1-wire master).

ab.rodrigo
Posts: 5
Joined: Sat Dec 29, 2018 3:55 pm

Re: RPi as 1wire slave

Sat Dec 29, 2018 3:57 pm

Did u make the code for Rpi as a slave?

hippy
Posts: 5186
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: RPi as 1wire slave

Sun Dec 30, 2018 7:04 pm

ab.rodrigo wrote:
Sat Dec 29, 2018 3:57 pm
Did u make the code for Rpi as a slave?
I would imagine not, simply because there would likely have been some report back of success given the bragging rights which would deservedly go with having achieved that.

A 1-wire slave is theoretically possible even without built-in hardware to support it. It can be done with bit-banging on a dedicated microcontroller, but I am not sure if that could be achieved on a Pi while running a multi-tasking OS.

I can't be sure of the exact figures off-hand but recall the slave must respond within 15us of seeing a signal transition from the master and the slave has to be responsive enough to continually keep up with the master-driven communication's sequence. That's easy enough with a fast dedicated micro but potentially a pain if an OS is taking control away from the slave handler code or preventing the required responsiveness.

I can't give a definitive answer because doing highly responsive bit-banging with a Pi is not something I have really looked into. It could be possible, perhaps by running code in the GPU or even a dedicated ARM core. One would be into 'niche skill-set' territory there.

One could likely produce a bootcode.bin which can make a Pi a dedicated 1-wire slave controller by running entirely in GPU or using ARM bare-metal but that is probably not that useful.

The easiest approach to having a Pi work as a 1-wire slave, while running a general purpose OS, would probably be to add a suitable microcontroller which can act as the 1-wire slave and pass data between the two. How useful that would be would depend on what data you wanted to deliver.

ab.rodrigo
Posts: 5
Joined: Sat Dec 29, 2018 3:55 pm

Re: RPi as 1wire slave

Sat Jan 05, 2019 2:31 pm

hippy wrote:
Sun Dec 30, 2018 7:04 pm
ab.rodrigo wrote:
Sat Dec 29, 2018 3:57 pm
Did u make the code for Rpi as a slave?
I would imagine not, simply because there would likely have been some report back of success given the bragging rights which would deservedly go with having achieved that.

A 1-wire slave is theoretically possible even without built-in hardware to support it. It can be done with bit-banging on a dedicated microcontroller, but I am not sure if that could be achieved on a Pi while running a multi-tasking OS.

I can't be sure of the exact figures off-hand but recall the slave must respond within 15us of seeing a signal transition from the master and the slave has to be responsive enough to continually keep up with the master-driven communication's sequence. That's easy enough with a fast dedicated micro but potentially a pain if an OS is taking control away from the slave handler code or preventing the required responsiveness.

I can't give a definitive answer because doing highly responsive bit-banging with a Pi is not something I have really looked into. It could be possible, perhaps by running code in the GPU or even a dedicated ARM core. One would be into 'niche skill-set' territory there.

One could likely produce a bootcode.bin which can make a Pi a dedicated 1-wire slave controller by running entirely in GPU or using ARM bare-metal but that is probably not that useful.

The easiest approach to having a Pi work as a 1-wire slave, while running a general purpose OS, would probably be to add a suitable microcontroller which can act as the 1-wire slave and pass data between the two. How useful that would be would depend on what data you wanted to deliver.
Thank you very much!

Return to “Interfacing (DSI, CSI, I2C, etc.)”