[Show/Hide Left Column]

1-wire slave for AVR microcontrollers

The software was created by smurfix (Matthias Urlichs)(external link), the source can be found on his GitHub project page(external link).

Making it work on an Arduino (Atmega168 version)

Get the code from GitHub and put pulsedtr.py(external link) in the same directory.

git clone https://github.com/smurfix/owslave.git
cd owslave
wget https://github.com/stef/arduino-cli/raw/master/pulsedtr.py

In the Makefile, change the line that starts with PROG= to PROG=stk500v1 -P /dev/ttyUSB0 -b 19200 -F and replace /dev/ttyUSB0 with the appropriate device node if needed. After the line that starts with burn: add the following line indented with a tabulator: python pulsedtr.py /dev/ttyUSB0 (again, replace the device node if needed). Now build and burn the ds2408 code.

make ds2408
make ds2408_burn

According to the Atmega168 section of onewire.c(external link), the pin used for the communication is pin 2 of port D (MCU pin 4(external link)), which is mapped to the digital pins on the Arduino board(external link). This means, that the 1-wire bus should be connected to digital pin 2 (right after the serial port occupying 0 and 1). Now, by connecting pin 2 of two Arduino's digital ports, and uploading the following code to the other, it should work (you'll need the contributed OneWire library(external link)).

Arduino PoC source code using OneWire

#include <OneWire.h>
OneWire ow(2);
void setup() {
void loop() {
 byte addr[8];
 if (!ow.search(addr)) {
 Serial.print("Found: ");
 for(byte i = 0; i < 8; i++) {
  Serial.print(addr[i], HEX);

Serial console output


Waveform captured with scope


Contributors to this page: dnet5208 points  .
Page last modified on Sunday 30 of October, 2011 18:46:53 CET by dnet5208 points .

Upcoming events

1)  Tue 04 of Oct., 2016 19:00 CEST
2)  Tue 11 of Oct., 2016 19:00 CEST
3)  Tue 18 of Oct., 2016 19:00 CEST