Skip to content


Subversion checkout URL

You can clone with
Download ZIP
1wire slave code for AVRs
C Python C++ Makefile Shell Assembly
Branch: master
Failed to load latest commit information.
.gitignore add comment re py3 Add an _include directive to .cfg file processing
GPL-3 linor stuff, ATtiny13-buildable Add an _include directive to .cfg file processing
LICENSE Licensing and related stuff
Makefile Use "mkdir -p" point to github master
adc.c Fix attiny25/45/85 compilation
adc.h Extend ADC alerting to report separate H and L limit overruns
cfg Merge remote-tracking branch 'moat/master'
cfg_write Find python3 path via env
console.c init+poll via dispatch
console.h init+poll via dispatch
count.c added code for alerting / alert reporting
count.h added code for alerting / alert reporting
debug.h Fix constant handling
dev_data.c EEPROM_POS used in both read_crc_byte and read_byte (cfg_byte)
dev_data.h fix EPROM mode (hopefully)
ds2408.c Fix building ds2423 and ds2408
ds2423.c Fix attiny25/45/85 compilation
features.h Fix attiny25/45/85 compilation
gen_eeprom Find python3 path via env
irq_catcher.c Timer
jmp.S quickjump
jmp.h quickjump
main.c Fix attiny25/45/85 compilation
moat.c Remove _near pointer-read suffix
moat.h some sort of ncomplete bootloader support
moat_adc.c Writing ADC bounds shall clear the alarm flags
moat_alert.c Remove _near pointer-read suffix
moat_config.c Remove _near pointer-read suffix
moat_console.c split write fn
moat_count.c various boundary checks and related bugginess
moat_internal.h split write fn
moat_port.c stupid bug
moat_pwm.c split write fn
moat_status.c Add status handling
onewire.c Fix ifdef typo
onewire.h drop next_idle param if not debugging
onewire_internal.h Fix ifdef typo Add config file (and rewriter)
port.c various boundary checks and related bugginess
port.h comment
pwm.c added code for alerting / alert reporting
pwm.h Fix attiny25/45/85 compilation
run_test fix test
sample.cfg Add an _include directive to .cfg file processing
status.c Add status handling
status.h Add status handling
test.c WDT and debug
timer.c Clean up timer interface
timer.h ADC handling.
uart.c remove DEBUGGPORT / DEBUGPINPORT when not applicable
uart.h debug: a byte is always 2chars
world.cfg Remove _near pointer-read suffix


or "Master of all Things" is a project to control various interesting little things using 1wire, via a common interface.

The master copy of this code is located at -- please come and contribute! (Bug reports welcome.)


1wire is a nice protocol for wire-based home automation. It's reasonably fast, stock hardware like basic I/O or temperature sensors are dirt cheap, and you can attach tiny AVR controllers (think Arduino) without any additional hardware.

It also has drawbacks. There's only one master, so you need to poll. The available I/O solutions are limited. Most slaves can't be parameterized in any meaningful way, can't work autonomously if the bus is wedged, and don't use CONDITIONAL SEARCH (required for any non-trivial network).

MoaT slaves are different. A common configuration file lists the features for each device you program. The parameters are added to the flash code (or, in the hopefully-not-too-far future, to the device's EEPROM) and can be interrogated via 1wire. OWFS then exports exactly those featurs which your device actually uses.


This is 1wire slave code for AVR microcontrollers. Copyright (C) 2010-2015 Matthias Urlichs

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <>.


The core code implements the basic 1wire discovery methods, including single-device mode and conditional discovery. Basic Code for e.g. the DS2423 fits in 2k on an ATtiny. Barely, but it fits. ;-)

Overdrive speed is not implemented, and probably never will be, because the timing constraints are too tight.

You can enable a debug pin which is a great help if you have timing problems; just add a 2-channel oscilloscope.

The 64-bit ID is optionally read from EEPROM. A tool to generate the 8-bit CRC is included.


Originally, this project consisted of an effort to convert convoluted code from the net, history unknown but apparently licensed GPL2, to something equally convoluted but more generic. And large. The work then languished for a couple of years.

At the beginning of 2015, Matthias Urlichs used code from Tobias Mueller to shrink down and rewrite the whole thing.

The Makefile was trimmed, build and device configuration was moved to a separate config file, and the project goal became a whole lot more ambitious.

1wire slaves

It appears that Dallas Semiconductor doesn't like people who implement 1wire slaves in software.

On the other hand, they do discontinue ICs like the DS2423 counter for which no known substitute exists.

Therefore, code to emulate specific 1wire slave ICs will only be added to this project's repository if the ICs are no longer available or "not recommended for new design".

Of course, code that does things which doesn't have a silicon equivalent is always welcome.


A nice and shiny 1wire client does not help if there's no server. Therefore, if you add your own code, please also submit appropriate changes to the owfs project so that other people can actually talk to your stuff.

The OWFS code for MoaT devices is located at .

NB: OWFS supports conditional search even if the "alarm" directory is missing. You can still access it.





  • make sure that an idle 1wire never results in a hung device


  • interrupt-based port monitoring
  • hardware-based PWM


  • secondary 1wire bus
  • store config in EEPROM
  • over-the-wire config changes
  • over-the-wire firmware update
  • some (esp. 1wire) statistics
  • ... including the fact that the device has been reset, and why
  • PID
  • I2C interface
  • THERMO via I2C
  • HYGRO via I2C
  • RF12 instead of 1wire
  • serial bridge
  • named ports
Something went wrong with that request. Please try again.