This demo was created in just a few minutes using a few simple tools (learn more -- including a demonstration video -- Here):
The GP3EZ lets you develop applications for the GP3 with a "point and click" interface. You can see the screen shots on the link above. However, GP3EZ can also export scripts to HTML. The script that is running this demo looks like this:
This is the Cygwin/Web Temperature demo. LM34 hooked up to AN2.
Step # | Tag | Condition | Action | Next | Notes |
1 | Start | (wait) Analog 2>0 V |
External New File: c:\gp3temp.txt | This will always trigger. | |
2 | pause | (wait) After 10000 ms | Wait 10 sec. | ||
3 | (wait) Analog 2>0 V |
External Add File: c:\gp3temp.txt | pause | This will always trigger. |
Step 1 reads the voltage from the LM34 and writes it to a new file. Then the script pauses for 10 seconds and makes more readings, adding them to the file.
The file looks like this:
1/9/2008 7:24:33 AM,0.7373047,Start,{none} 1/9/2008 7:24:43 AM,0.7373047,3,{none} 1/9/2008 7:24:53 AM,0.7373047,3,{none} 1/9/2008 7:25:03 AM,0.7421875,3,{none} 1/9/2008 7:25:13 AM,0.7373047,3,{none}
The first two fields are what we are interested in: the date/time and the LM34 voltage (10mV = 1 degree). The other two fields are the step name or number, and the current GP3EZ state (which isn't used in this script). Note that readings taken by different steps could be distinguished (if you wanted to display multiple values). Keep in mind that the readings are 10 bit accurate, so the number of significant digits computed ought to be adjusted during calcuation (although this simple demo doesn't do that).
Now we just need a cygwin script (gp3temp.sh):
#!/bin/bash # Be sure to execute chmod +x gp3temp.sh once to make # the script executable while true do # read the last line from the file and "awk" it tail -n1 /c/gp3temp.txt | awk -f gp3temp.awk >/c/gp3temp.html # copy file to Web server scp gp3temp.html awce:public_html/gp3ez sleep 30 # wait 30 seconds done
That's easy enough. Awk processess the last line of the file and then scp sends it to the Web server. You could use FTP, rsync, or however you normally send things to your Web server. If you run a local Web server, it could be a simple file copy.
So what's in the Awk script? Easy:
BEGIN { FS=","; print "<HTML><HEAD><META HTTP-EQUIV='REFRESH' CONTENT='60'>\n"; print "<TITLE>GP3 Temperature Demo</TITLE>"; print "</HEAD><BODY BGCOLOR=CORNSILK>"; } /^[0-9]/ { xtemp=$2*100; # 10mV/degree print "<H1>At " $1 " the temperature at AWC was " xtemp "F"; } END { print "</BODY></HTML>"; }
Most of this is just spitting out generic HTML. The only real work is computing the actual temperature (xtemp=$2*100). Awk splits the lines into fields (in this case, on the commas) so $1 is the date/time and $2 is the voltage.