10

What I want to do is make a ATTiny IC become a slave on the 1-wire bus, with its own S/N and command list for its specific functions.

What I want to know is if I can use the one wire library from the arduino site to send data as a slave.

For example, you can have a slave in one room with multiple types of sensors which would report to the master on requested information, or the master can tell it to control something like blinds.

Question Would I have to monitor the bus line and respond to a request from the master and also take into consideration the way a normal sensor would send data? What frequency should I run the slave at to get the best functionality?

I won't use parasitic power, as a note.

6
  • forum.arduino.cc/…
    – Gerben
    Mar 13, 2015 at 15:28
  • @Gerben - I had found that before on a search. Skimmed through it. But I was concerned because there were some errors, though solved, I don't know the reliability. Also search foe designs using custom slaves didn't seem like a common thing, hence question above.
    – RSM
    Mar 13, 2015 at 17:04
  • It seems to say the library supports it. Here is a library specifically for it I think. Speed seems to be around 15kbps. I think CPU speed doesn't really matter, but that depends on the library. If it's not battery powered, just run it at 8mhz or 16mhz, and it should be fine.
    – Gerben
    Mar 13, 2015 at 20:45
  • @Gerben I will test out the library to see how it runs. One thing I still don't get is why it is so uncommon for some things not to use the one wire slave?
    – RSM
    Mar 13, 2015 at 21:39
  • @RSM You should check this library github.com/MarkusLange/OneWireSlave May 31, 2015 at 9:07

1 Answer 1

3

As far as I know, the 1-wire library you linked in your question allows only to act as a master, not a slave.

I've just released a library to turn an Arduino board into a 1-wire slave, here: https://github.com/neuoy/OneWireArduinoSlave (edit: moved here https://gitea.youb.fr/youen/OneWireArduinoSlave). I use it in my custom home automation system, and it works flawlessly in my setup (the 1-wire master, a DS9490R, is connected to a laptop via USB, and also provides power to the Arduino, which is an Arduino Uno). The library handles low level details: match rom, byte send and receive (which is actually quite hard to get right, mostly impossible without a logic analyzer). The rest is up to you.

It's entirely implemented with interrupts, all communications are performed in background, you can execute other code as usual, in parallel, and are notified by callbacks when bytes are received etc. Sending bytes to the master is also asynchronous.

I also know at least one other library exists, https://github.com/MarkusLange/OneWireSlave, as commented above by Ryu_hayabusa. It didn't work for me (don't know if it's because of my hardware setup or for another reason), but it definitely work for others, so also worth a try. It seems this library is not implemented with interrupts, so your program is blocked while waiting for master activity (which is perfectly acceptable in a lot of scenarios).

3
  • The repository seems to have moved to gitea.youb.fr/youen/OneWireArduinoSlave Nov 13, 2018 at 21:26
  • 1
    @JonasBerlin Indeed, I've moved the repository (just edited the answer to reflect that). I leave the old link as a backup just in case, and as a reference to find other people forks on GitHub.
    – youen
    Nov 14, 2018 at 13:54
  • Should the issues be copied perhaps? Nov 15, 2018 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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