9

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.

  • forum.arduino.cc/… – Gerben Mar 13 '15 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 '15 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 '15 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 '15 at 21:39
  • @RSM You should check this library github.com/MarkusLange/OneWireSlave – Ryu_hayabusa May 31 '15 at 9:07
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).

  • The repository seems to have moved to gitea.youb.fr/youen/OneWireArduinoSlave – Jonas Berlin Nov 13 '18 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 '18 at 13:54
  • Should the issues be copied perhaps? – Jonas Berlin Nov 15 '18 at 6:56

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.