Loading...
 
[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() {
 Serial.begin(9600); 
}
 
void loop() {
 byte addr[8];
 ow.reset();
 if (!ow.search(addr)) {
  ow.reset_search();
  delay(2);
  return;
 }
 Serial.print("Found: ");
 for(byte i = 0; i < 8; i++) {
  Serial.print(addr[i], HEX);
  Serial.print(":");
 }
 Serial.println("");
 delay(1000);
}

Serial console output

Image

Waveform captured with scope

Image


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

Upcoming events

1)  Mon 28 of Apr., 2014 19:00 CEST
eTextile workshop
2)  Tue 29 of Apr., 2014 19:00 CEST
Plénum
3)  Thu 01 of May, 2014 16:00 CEST
Buhera szakkör