Page Reload using Webduino Outside of POST?

Is there a way use the Webduino or Ethernet libraries to conditionally reload the page without pressing a button or hitting refresh on the web page? I want the page to reload with an alarm message when a PIR detects motion, however with my limited knowledge of programming I have no idea how I should do this. I'm not really a programmer but I've been thrust into this role (I built all the code I have now off of Ben Combee's "Webduino Buzzer" example). I would love it if I could somehow pass a variable into POST triggering a reload, or if I could get httpSeeOther working outside of POST. Anyway I'm going to go bang my head against the wall for a while longer; please if you know how put me out of my misery. Thanks in advance for any help.

You would probably need to use some type of javascript refresh or meta page refresh, and have a different page supplied from the arduino when something is triggered.

I've tried adding a meta refresh into the html with a variable refresh time, however this does not seem to work because the html is only updated on a refresh. It was easy enough to pass a variable into the GET function of my default command, so I used that to create conditional html output (which is the alarm message). The problem here is that I can't see the alarm message as soon are the alarm is triggered. I could use a smaller value for my refresh time, but that just seems lazy and not optimal.

I don't have any of my code right now, but I imagine I'll be posting some of it if my explanations are not enough. If it comes to that be prepared to look at if statements galore.

You probably need to look at the client/server relationship of http based connections. Your arduino server cannot initiate anything on your brouser (updating a page and such). Your brouser has to initiate any connection to a server. Basic network security. If you want the outside to be able to do things on your computer, then you need to set up a server on your computer to await incomming alarm messages. You could use an arduino as a client that monitors alarm equipnent, and when appropriate sends a message to a pc or another arduino operating in the server mode. When the server receives the alarm message, it can interface with various gizmos to alert you. One clever thing is that it is possible on a pc and and perhaps an arduino to immediately send an email text message to your cell phone.

I don't know how you're doing things, but I think the best solution would be to have a web server (not on the arduino) and the arduino push data to it. Since you've got decent resources on your web server you can use AJAX to push data to a web page in much the same way as you can see fresh tweets without reloading when you're logged in to twitter.

A quick and dirty way would be to use an iframe. An iframe is a web page within another web page (an inline frame). You can make the page that loads inside the iframe very simple and just show a flag (you could just change the colour of the background from white to red if your PIR has detected movement), and because it's small a frequent reload doesn't really matter. The quickest you could get it to reload is every second.

Thank you zoomkat and cowjam. I feared that this was the case, so I'll look into what you have told me and set up the web page to refresh every 5 seconds or so for now. I doubt that the optimal way to set this up is to have another arduino, in which case I'll look into setting up a web server on the computer or using the security camera's web server.

Thanks again for the help.

Alright I got some more news. I'm adding another shield to my arduino board. Now not only will I have a ethernet board, but I'll also have a cellular module board. So I have a new question, "If my cellular module has TCP/IP functionality can I use it as a web client to get the web server to update the page?"

edit: I should note that I'm talking about the web server on my arduino board, so I'm wondering if I can set up the wiznet board to handle the web server, then have the cellular module act as a web client.

I don't think it'd work how you planned.

When you visit a website, your browser asks the web server for the page. The server delivers the page, and you sit there looking at it. That's all that happens until you decide to do somethign - like refresh or click a button.

Getting your GSM module to hit the server will get the server to update, but it won't change anything for you sat at your PC looking at the page.

You have to make elements on the page go back to the server. A meta-refresh makes the whole page load again. You can use javascript to make individual elements load again. AJAX is "asynchronous javascript with XML" (or similar) - it's just a fancy version of javascript that interracts with a database too, making it really useful and powerful.

There's no hardware fiddling you can do (that I can think of) that will solve your problem. You need to make the web page more complicated, and I suspect the only way you'll do it well is it have it off the arduino.

Thanks for the reply cowjam. I guess that makes more sense. I would probably benefit from using a server on my computer, but I'm going to try to get this to work on the Arduino first. So I'm going to see what I can do with AJAX and javascript, but so far the meta-refresh has been a bust.

Still using the cellular module for emergency calls, text messaging, and to allow for control of the alarm system with a cell phone.

Below is the html for one of my test pages. The part that might be of interest to you is the "Get data from SSC-32: " box. You should be able to copy the below html, paste in notepad, and save as test.htm on your desktop. Open it up and click on any of the last three options above the box (they connect to an external web site) and you should get “boom”. This is a simple on demand way to import data without refreshing the whole web page. I haven’t tried meta refreshing the “boom” link, but it may be possible. If it is meta refreshable, then various info or alerts from an arduino could be obtained from an arduino with minimal page generation from the arduino itself.

<HTML>
<HEAD>
<TITLE>Zoomkat's cgi test</TITLE>
</HEAD>
Zoomkat's SSC-32 cgi test 2/28/10


Position Servo:


Servo 0:


<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1200">1200</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1240">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1280">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1320">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1360">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1400">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1440">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1480">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1520">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1560">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1600">1600</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1640">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1680">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1720">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1760">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1800">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1840">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1880">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1920">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1960">*</a>
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p2000">2000</a>


 


Control continous rotation servo speed/direction:


Servo 4: 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1400">R</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1410">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1420">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1430">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1440">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1450">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1460">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1470">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1480">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1490">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1500">STOP</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1510">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1520">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1530">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1540">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1550">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1560">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1570">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1580">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1590">*</a> 
<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?-4p1600">F</a> 

 


Get data from SSC-32:



|<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?ver" target="DataBox" title="'SSC-32 version'">VER</a>|

<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?va" target="DataBox" title="'Voltage on A analog input'">VA</a>|

<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?vb" target="DataBox" title="'Voltage on B analog input'">VB</a>|

<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?vc" target="DataBox" title="'Voltage on C analog input'">VC</a>|

<a href="http://127.0.0.1/cgi-bin/cgi3c8.exe?vd" target="DataBox" title="'Voltage on D analog input'">VD</a>|

<a href="http://www.yourhtmlsource.com/examples/inlineframes3.html" target="DataBox" title="'Someone set us up the bomb'">Q</a>|

<a href="http://www.yourhtmlsource.com/examples/inlineframes3.html" target="DataBox" title="'Someone set us up the bomb'">VB</a>|

<a href="http://www.yourhtmlsource.com/examples/inlineframes3.html" target="DataBox" title="'Someone set us up the bomb'">VC</a>|


 
<iframe src="http://127.0.0.1/cgi-bin/cgi3c8.exe?ver" width="30%" height="40" name="DataBox">
</iframe>


Push to move, release to stop servo0


<input type="button" value="Pan Left" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p700S150');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?STOP0');"/> 

<input type="button" value="Pan Right" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p2300S150');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?STOP0');"/> S150



<input type="button" value="Pan Left" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p700S50');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?STOP0');"/> 

<input type="button" value="Pan Right" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p2300S50');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?STOP0');"/> S50



<input type="button" value="<<<" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p700S100');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?STOP0');"/> 
<input type="button" value="<<" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p700S50');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?STOP0');"/> 
<input type="button" value="<" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p700S10');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?STOP0');"/> 

<input type="button" value="S" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/stop.bat?STOP0');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/stop.bat?STOP0');"/> 

<input type="button" value=">" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p2300S10');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?STOP0');"/> 
<input type="button" value=">>" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p2300S50');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?STOP0');"/> 
<input type="button" value=">>>" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p2300S100');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?STOP0');"/> 



Absolute position go/return


<input type="button" value="Pan Left" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p700');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1500');"/> 

<input type="button" value="Pan Right" 
onmousedown="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p2100');" 
onmouseup="location.href 
('http://127.0.0.1/cgi-bin/cgi3c8.exe?-0p1500');"/> 



</HTML>