[Tutor] Python Arduino Web Page
Engineering
engg at cleantechsolution.in
Fri Aug 9 10:33:02 CEST 2013
I have written the following code in Python for my Arduino
#!c:\Python27\Python.exe
import cgi, cgitb;
import sys, serial
cgitb.enable()
ser = serial.Serial('COM27', 9600)
myvar = ser.readline()
print "Content-type:text/html\n\n"
print """
<html>
<head>
<title>
Real Time Temperature
</title>
<script type="text/javascript">
window.onload = startInterval;
function startInterval()
{
setInterval("startTime();",1000);
}
function startTime(myvar)
{
document.getElementById('mine').innerHTML ="Temperature"
+parseInt(myvar);
}
</script>
</head>
<body>
<h1>Real Time Temperature:</h1>
<div id="mine"></div>
</body></html>
"""
I have Apache Web Server
But on running this my localhost , I am getting the following output
"TemperatureNaN" . Why is NaN being showed. Why cant I get the number as
read by se.readline()?
Is there a way to separate the Python code and the Javascript on different
files. If so can you please give a example.?
I am not really interested to do with bottle or other web framework as I
will be controlling my arduino with python from the web and also do video
image processing with openCV. Open CV have a support for Python and not for
Javascript.
Thanks
Subhendu Sinha Chaudhuri
CLEANTECH SOLUTION
www.cleantechsolution.in
SAVE PAPER , SAVE EARTH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130809/e60daf43/attachment.html>
More information about the Tutor
mailing list