Loading...
 

1-wire slave for AVR microcontrollers


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

Making it work on an Arduino (Atmega168 version)


Get the code from GitHub and put pulsedtr.py 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, the pin used for the communication is pin 2 of port D (MCU pin 4), which is mapped to the digital pins on the Arduino board. 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).

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: dnet .
Page last modified on Sunday 30 of October, 2011 18:46:53 CET by dnet.

Upcoming Events

1)  Fri 02 of Dec, 2016 19:00 CET
Cryptonite: ransomware
2)  Tue 06 of Dec, 2016 19:00 CET
Plénum
3)  Tue 13 of Dec, 2016 19:00 CET
Plénum