An Ethernet based distributed alarm system
This is a distributed alarm system which is able to report
alarms to a central server using a network (local lan or
even over the internet).
The alarm is triggered by connecting pin PD0 to GND.
For more detailed documentation see http://tuxgraphics.org/electronics/
The subdirectory servers contains different working
examples of alarm servers. This is the central instance that receives
the alarms from all the distributed little ethernet boards.
All parts needed to build this AVR ethernet solution can be ordered from
http://shop.tuxgraphics.org/.
Copyright: Guido Socher, tuxgraphics.org
License for everything: GPL V2
See http://www.gnu.org/licenses/gpl.html
Other licenses are available on request.
!! READ THIS FIRST !!
! Edit the file main.c and change the following lines as needed:
Mac address of the device:
static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x30};
IP address of the device:
static uint8_t myip[4] = {10,0,0,30};
Password/shared secret:
static char password[10]="sharedsec"; // must not be longer than 9 char
Name of the system/area where this sensor is:
static char myname[MYNAME_LEN+1]="section-42";
The IP where the central alarm server is located:
static uint8_t udpsrvip[4] = {10,0,0,5};
Default gateway. The internal ip address of your DSL router:
static uint8_t gwip[4] = {10,0,0,2};
Check the file "Makefile" and make sure the MCU is set correctly:
MCU=atmega168
DUDECPUTYPE=m168
or
MCU=atmega328p
DUDECPUTYPE=m328
The code is written for atmega168 or atmega328p.
You need an avr-gcc development environment in order to compile this.
See http://tuxgraphics.org/electronics/200901/avr-gcc-linux.shtml
To compile the final software use the command:
make
Note: windows users may use and modify the supplied winmake.bat to setup the
environment correctly.
The command
make load
will execute the avrdude command to load the main.hex software
E.g something like:
avrdude -p m168 -c stk500v2 -e -U flash:w:main.hex
Note your programmer might interfer with the enc28j60! For the avrusb500
with 30cm cable you can normally leave the cable on. For all other programmers
it is however saver to remove the programmer cable and power down/up the device.
This is because the SPI interface is used for loading of the software and
communication to the enc28j60.
To see a list of all possible build targets run the command:
make help
Selecting the right clock source
--------------------------------
Tuxgraphics hardware sold as of march 2007 is prepared to use the clock
signal from the enc28j60. To use this you need to change the
low fuse byte once from 0x62 to 0x60:
avrdude -p m168 -c stk500v2 -u -v -U lfuse:w:0x60:m
or
avrdude -p m328 -c stk500v2 -u -v -U lfuse:w:0x60:m
or just type in your Linux shell:
make fuse
After programming the fuse settings of atmega168 should be:
low fuse: 0x60
high fuse: 0xdf
ext. fuse: 0x01
For the atmega328p the hfuse and efuse bytes look slightly different.
The idea is however the same. Just change the lfuse from factory default
to 0x60.
details of the lfuse bits:
CKDIV8 = 0
CKOUT = 1
SUT1 = 1
SUT0 = 0
CKSEL3 = 0
CKSEL2 = 0
CKSEL1 = 0
CKSEL0 = 0
If you are unsure what the current fuse setting are on the atmega
then you can read the fuse settings with a command like:
avrdude -p m168 -c stk500v2 -v -q
The result should be this (default factory settings for atmega168):
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 1
The result should be this (default factory settings for atmega328p):
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as 7
Note efuse has some un-used bits and they may show up with different
values dependent on the chip revision.
Compiling on non-Unix systems
-----------------------------
Please use the provided Makefile !!!
It will also work under Windows.
Take a look at the supplied winmake.bat file and the winload.bat.
This bat script might be needed to set the environment correctly.
Revision history
----------------
2010-02-21: version 0.1 -- first public version
vim:sw=8:ts=8:si:et