1wire slave code for AVRs
C Python C++ Makefile Shell Assembly
Switch branches/tags
Nothing to show
Latest commit 9f64fb1 Nov 22, 2015 @smurfix smurfix Merge from github
Permalink
Failed to load latest commit information.
.gitignore add comment re py3 Apr 5, 2015
Cfg.py fix recursive include bug Sep 1, 2015
GPL-3 linor stuff, ATtiny13-buildable Apr 7, 2010
HOWTO.md Somewhat more documentation Sep 5, 2015
LICENSE Licensing and related stuff Feb 14, 2015
Makefile Merge from github Nov 22, 2015
README.md more docs Sep 6, 2015
adc.c Power saving features Nov 18, 2015
adc.h Clean up dead alert code Nov 7, 2015
boot.c comments and stuff Jul 19, 2015
bug.c Loader, part 1: build the code Jul 19, 2015
bug.h Loader, part 1: build the code Jul 19, 2015
cfg Merge from github Nov 22, 2015
cfg_write Find python3 path via env Jul 4, 2015
console.c Added a stupid workaround for pgm_read_ptr Sep 1, 2015
console.h Added a stupid workaround for pgm_read_ptr Sep 1, 2015
count.c Add configurable falling/rising edge selection for counter inputs Nov 7, 2015
count.h Add configurable falling/rising edge selection for counter inputs Nov 7, 2015
crc.c CRC split off Jul 19, 2015
crc.h CRC split off Jul 19, 2015
debug.h More interesting debugging Aug 14, 2015
dev_data.c set-but-not-used variable warning Sep 5, 2015
dev_data.h EPROM support: use "MoaT" prefix Jul 27, 2015
ds2408.c Fix building ds2423 and ds2408 May 26, 2015
ds2423.c ds2423: reset alarm flag on mem read Nov 3, 2015
elf_end Loader, part 1: build the code Jul 19, 2015
features.h Fix proper HAVE_DBG_PIN support on mega8 Nov 12, 2015
gen_eeprom EPROM support: use "MoaT" prefix Jul 27, 2015
irq_catcher.c Added ability to reassign 1wire pin Sep 5, 2015
jmp.S quickjump Apr 19, 2015
jmp.h quickjump Apr 19, 2015
local.cfg.example Add a sample local.cfg file Jul 19, 2015
main.c onewire init removed from main Sep 5, 2015
moat.c Power saving features Nov 18, 2015
moat.h some sort of ncomplete bootloader support May 31, 2015
moat_adc.c Writing ADC bounds shall clear the alarm flags Jun 26, 2015
moat_alert.c Added a stupid workaround for pgm_read_ptr Sep 1, 2015
moat_backend.c Added a stupid workaround for pgm_read_ptr Sep 1, 2015
moat_config.c C warning Sep 5, 2015
moat_console.c More interesting debugging Aug 14, 2015
moat_count.c various boundary checks and related bugginess May 16, 2015
moat_dummy.c write_check needs to be present Jul 27, 2015
moat_internal.h Loader, part 1: build the code Jul 19, 2015
moat_loader.c Added a stupid workaround for pgm_read_ptr Sep 1, 2015
moat_port.c stupid bug Jun 9, 2015
moat_pwm.c split write fn Jun 9, 2015
moat_status.c Loader, part 1: build the code Jul 19, 2015
moat_temp.c temperature! Sep 6, 2015
module.ld Loader, part 1: build the code Jul 19, 2015
onewire.c Let moat_poll run in some update_idle calls, as discussed in #7 Nov 12, 2015
onewire.h CRC split off Jul 19, 2015
onewire_internal.h Fix build on ATmega8 Nov 3, 2015
ordered_yaml.py Add config file (and rewriter) Mar 16, 2015
pgm.h Added a stupid workaround for pgm_read_ptr Sep 1, 2015
port.c Added a stupid workaround for pgm_read_ptr Sep 1, 2015
port.h Clean up dead alert code Nov 7, 2015
pwm.c Added a stupid workaround for pgm_read_ptr Sep 1, 2015
pwm.h Fix attiny25/45/85 compilation Jul 3, 2015
run_test fix test May 16, 2015
sample.cfg Somewhat more documentation Sep 5, 2015
status.c Added a stupid workaround for pgm_read_ptr Sep 1, 2015
status.h Try to make startup more stable Jul 27, 2015
temp.c temperature! Sep 6, 2015
temp.h temperature! Sep 6, 2015
temp_dummy.c temperature! Sep 6, 2015
test.c WDT and debug Jun 6, 2015
timer.c Fix build on ATmega8 Nov 3, 2015
timer.h ADC handling. May 13, 2015
uart.c Added a stupid workaround for pgm_read_ptr Sep 1, 2015
uart.h round baud rate to nearest integer, not down Jul 29, 2015
world.cfg Merge from github Nov 22, 2015

README.md

MoaT

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 https://github.com/M-o-a-T/owslave -- please come and contribute! (Bug reports welcome.)

Goals

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.

License

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

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
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
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 <http://www.gnu.org/licenses/>.

Implementation

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.

The 1wire bus must be connected to the INT0 pin. See features.h or your microcontroller's data sheet which hardware pin that is. For example, on an ATmega168 it's PD2 (pin 4 if your ATmega lives in a 28-pin PDIP package). Add a power supply (leeching parasite power from the bus is not a good idea) and a capacitor, and your 1wire slave is ready to go (of course, you do need to program it).

History

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 mail@tobynet.de 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.

OWFS

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 git@github.com:M-o-a-T/owfs.git .

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

HOWTO

For build instructions, see HOWTO.md

Rationale

This project uses its own build system, based on a configuration file and make.

The reason is simple enough: suppose you want to prepare or update 100 devices for installation in a new house.

You do not want to click your way through a GUI to do this.

The first time through, you want to issue one command and then plug each device into the programmer. Wait, unplug, repeat.

After it's all installed, you want to run "make update-all" and have the build system handle everything. Yes, this includes firmware uploads via 1wire.

MoaT doesn't yet support online firmware updates. But it will.

TODO

bugs

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

optimizations

  • interrupt-based port monitoring
  • hardware-based PWM

implementations

  • secondary 1wire bus?
  • I²C bus?
  • RF12/RF69?
  • more over-the-wire config changes
  • over-the-wire firmware update
  • some (esp. 1wire) statistics
  • PID
  • SMOKE
  • I2C interface
  • THERMO via I2C
  • HYGRO via I2C
  • serial bridge
  • named ports