AVR web server and client, DS18S20 temperature sensor
This is a web client uploading data to your tuxgraphics web-view account.
This is a portal were you can design your own pages to show data and
graph it.
Tuxgraphics offers a web service called "ds_view" to manage
and view data reported by the embedded client board. To have access
to this area you have to purchase a board with pre-loaded embedded client
software.
For testing purposes you can as well use the free data upload service
at http://ds.tuxgraphics.org/cgi-bin/upld .
In the cgi-bin directory you find a perl cgi-script to store data
on your own server and process it further. For this you do not need
the "ds_view" service from Tuxgraphics.
The software uses a DHCP client and thus there is no need to configure anything.
You can compile this software and load it into your ethernet board.
After that it will automatically optain an IP address from your network (
normally from a DHCP server inside your DSL-router).
One minute later it will upload the first temperature data to
http://ds.tuxgraphics.org/cgi-bin/upld and you can go with your own web browser to
http://ds.tuxgraphics.org/cgi-bin/upld.
and see what happened.
The board runs not only a web client which reports periodically data but
as well a web-server. The only difficulty is that you can not easily know
what IP address the board obtained from your DSL router and thus easily know
where the web server is. Some routers
have the option to see "connected devices" and you can guess from there which
one the ethernet board has. You can as well go to http://ds.tuxgraphics.org/cgi-bin/upld
and look for the brdIp parameter.
brdIp is the IP address the board obtained from your
DSL router. Use that address to connect with your own web browser directly to the board (e.g http://192.168.2.3 ).
The local web server running on the board provides important information about
the status of the system and offers the possibility to configure the board.
You can as well read the sensor values as they are at this moment.
To enter configuration mode connect pin PB0 to GND for a short moment.
After that point your web browser to the device at the IP address it obtained
from your DSL router (see above, e.g http://192.168.2.3 )
You for security reasons you have 3 minutes to reconfigure the board. This ensures
that only somebody with physical access to the board can actually change something.
It is possible to not use the data upload feature at all and just use this
as a stand-alone web server providing measurement data on a web page.
To switch off the upload feature you put an empty string into the server-url part during configuration.
To reset the board back to compile time settings you connect PB0 to GND continuously for
20-30 seconds, then release PB0 again, wait 1-2 seconds and power-cycle the board.
Hardware
For a description on how to connect the sensors see the
hardware directory
Compile time config (!! READ THIS BEFORE YOU COMPILE THE CODE !!)
Edit the C-file of the application which you plan to compile from
the appropriate sub-directory and change the line:
static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x29};
You must assign a new MAC address to each board such that there are
no two boards in your local network with the same MAC address.
MAC address do not have to be unique world wide. They are only of local
significance in your own network.
Check the file "Makefile" and make sure the MCU is set correctly:
MCU=atmega328p
DUDECPUTYPE=m328p
or
MCU=atmega644
DUDECPUTYPE=m644
The code needs an atmega328p or atmega644 chip.
Compiling the code
You need an avr-gcc development environment in order to compile this.
See http://tuxgraphics.org/electronics/200901/avr-gcc-linux.shtml
Each of the examples can be compiled from the corresponding sub-directory
Just use the command:
make
Note: windows users may use and modify the supplied winmake.bat to setup the
environment correctly. See details below on how to compile this under windows.
More information about Makefiles can be found at:
http://tuxgraphics.org/electronics/200912/makefiles.shtml
The command
make load
This will execute the avrdude command to load the software into the microcontroller.
E.g something like:
avrdude -p m88 -c stk500v2 -e -U flash:w:main.hex
For the "make load" stuff to work you will have to set the LOADCMD variable
in the Makefile.
It is as well possible to compile everything from the top level make file
but loading is obviously not possible from there.
To see a list of all possible build targets run the command:
make help
Selecting the right clock source (fuse settings) !you do this only once per board!
Tuxgraphics hardware sold as of march 2007 is prepared to use the clock
signal from the enc28j60. To use this clocke signal you need to change the
low fuse byte once from 0x62 to 0x60:
avrdude -p m328p -c stk500v2 -u -v -U lfuse:w:0x60:m
or
avrdude -p m644 -c stk500v2 -u -v -U lfuse:w:0x60:m
The above command can as well be executed by using the make
file. In a Linux shell you just make sure the Makefile is correct and
then type:
make fuse
Note: windows users may use and modify the supplied winsetfuse.bat script.
After programming the fuse settings of atmega328p should look
similar to this:
lfuse reads as 0x60
hfuse reads as 0xD9
efuse reads as 0x07
The idea is: Just change the lfuse from factory default
to 0x60. Note that the efuse of the atmega328p has some
unused bits and is dependent on the chip revision.
Fuses of the atmega644/atmega644a after programming:
Device signature = 0x1e9609
lfuse reads as 60
hfuse reads as 99
efuse reads as FF
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 below list of fuses shows for reference purpose the settings
of a new and never programmed chip.
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
The result should be this (default factory settings for atmega644/atmega644a):
avrdude: Device signature = 0x1e9609
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as 99
avrdude: safemode: efuse reads as FF
Compiling on non-Unix systems
Please use the provided Makefile !!!
This Makefile will work under Windows.
Take a look at the supplied winmake.bat, winclean.bat and winload.bat files.
These scripts as well as the settings at the beginning of the Makefile
need to be adjusted.
More information about Makefiles can be found at:
http://tuxgraphics.org/electronics/200912/makefiles.shtml
After adjusting both the batch script and the Makevars.mk you can
use this system as follows:
- Compilation: just double click on the winmake.bat in the filemanager. This
will compile the whole tree.
- Loading of the resulting main.hex file: double click on the winload.bat from the filemanager window.
- Setting fuse bytes (needs to be done only once per board): double click in winsetfuse.bat
- Clean-up of object files (needs to be run after changing any settings in Makefiles): double click on winclean.bat
License
Copyright of the software and all diagrams: Guido Socher, tuxgraphics
The libraries
dhcp_client, dnslkup, ip_arp_udp_tcp, enc28j60 and websrv_help_functions
are licensed under LGPL V2
See http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html
All other parts are GPL V2
See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
Revision history
2012-04-13: version 1.0 -- based on stack version 5.1
vim:sw=8:ts=8:si:et