Spinneret and SHT11
JAGO
Posts: 49
Hi Friends,
I'm try to learn by my self about the spin programs and i have a spinneret web server with a SHT11 sensor, and a trying to show the temperatura and humidity in a web page but i have somo problems, because i don't have enought practice.
I work with the HTTPserver of Mike G. and work great...i follow the manual in http://spinneret.servebeer.com:5000/index.htm and i can read the RTC and show in the webpage also can control the led, but i don't know how insert the the object for read the SHT11 i have a sensirion demo from the Obex.
Anyone know something about?
Many thanks!
I'm try to learn by my self about the spin programs and i have a spinneret web server with a SHT11 sensor, and a trying to show the temperatura and humidity in a web page but i have somo problems, because i don't have enought practice.
I work with the HTTPserver of Mike G. and work great...i follow the manual in http://spinneret.servebeer.com:5000/index.htm and i can read the RTC and show in the webpage also can control the led, but i don't know how insert the the object for read the SHT11 i have a sensirion demo from the Obex.
Anyone know something about?
Many thanks!
Comments
Do you have a SHT11 demo working? If not, do that first.
many thanks for your answer, it's a honor for me stay in contact with you and apreciate so much your work.
Well the sht11 demo works fine, i can see temperature and humidity in the PST.
I understand how modify the methods, but a i have doubts with show the variables in the web page, i compare
with the HTTPdate method because in here is the acces to the RTC and exist many transformations before send the data to the web page. May be send the temperature is more easy, i hope that.
I try with your sugesti
I'm continue with my experiment and i try to send the sensor data to the web page but i can't, i don't know why...today insert the SHT object to the HTTPserver and compile ok... and i can send the data to the PST but when try with StringSend method the data not appears in the web page.
PRI GetTemp
sht.start(SHT_DATA, SHT_CLOCK) ' start sensirion object
pause(200)
sht.config(33,sht#off,sht#yes,sht#hires) 'configure SHT-11
c := sht.getTemperatureC
return c
This is the method for take the temperature and works with the PST but when use the variable "c" in the StringSend(id, @c) not work...
i don't know how do it...can you help me please?
Thanks
There is no context around your code snippet. I have no idea what happened before or after PRI GetTemp. I would expect PRI GetTemp to save a temperature string in memory and return a pointer not invoke the StringSend method. StringSend should happen where the page is being rendered.
Attach your code archive.
In fact now i trying to convert the c variable (integer) to string before send with the StringSend method. i attached all objects. i'm working with HTTPserver and i add the sensirion object for take the temperature and i create a GetTemp method for read the sensor and in the XmlTime method i'm trying to convert the "c" variable to string for send with the SendString method.
Please if you can check will be great...
Thanks
This needs to be moved to the Initialize method of HTTPServer
Your service call should look something like the snippet below. I don't have the SHT-11 so I simulated the result.
Many thanks for all, your code works fine! i insert your code in the xmltime method for try and when type the direction of my spinneret 192.168.1.8:5000/Xmltime apears the code showing the temperature:
<root application="spinneret">
<temp>
<![CDATA[ 19 ]]>
</temp>
</root>
the "19" is the temp of my sensor, great! but when open the web page time.htm (followeb the manual http://spinneret.servebeer.com:5000/services/xmltime.htm) and click the "Get Time" link but not appears the temperature...
i don't modify the web page only modify the propeller code, will be necesary modify the web page too, or is other the problem??
Many thanks for your help
<html>
<head>
<title>Get Temp</title>
<script language="javascript" type="application/javascript">
//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert("Your Browser does not support AJAX!\nIt's about time to upgrade don't you think?");
}
}
//XmlHttpRequest object
var req = getXmlHttpRequestObject();
var htmlTarget;
function getRequest(resource, elementId) {
// handle the case where a querystring is not detected
var char = "&";
if(resource.indexOf("?", 0) == -1) {
char = "?";
}
if (req.readyState == 4 || req.readyState == 0) {
req.open("GET", resource + char + 'ms=' + new Date().GetTemp(), true);
req.onreadystatechange = handleResponse;
htmlTarget = elementId;
req.send(null);
return false;
}
}
function handleResponse() {
if (req.readyState == 4) {
parseState(req.responseXML);
}
}
function parseState(xDoc) {
var target = document.getElementById(htmlTarget);
target.innerHTML = xDoc.getElementsByTagName("temp")[0].childNodes[0].nodeValue;
}
</script>
</head>
<body style="background-color:beige;">
<div style="width:600px;margin:auto;background-color:white;padding:10px;">
<h1 style="text-align:center;color:blue;">SHT</h1>
<div style="text-align:center;"><a href="index.htm">PRUEBA</a> | <a href="led.htm">LED</a> | <a href="time.htm">RTC </a> | <a href="temp.htm">SHT</a></div>
<p>
<a href="temp.htm" onClick="return getRequest('xmltemp', 'placeholder');">LEER TEMP</a>
</p>
<p><span id="placeholder"></span></p>
</div>
<script language='javascript' type='text/javascript'>
getRequest('xmltemp', 'placeholder');
</script>
</body>
</html>
this is the code for the temp.htm (web page for read temperature) is the same time.htm but i change all time words for temp but a have a doubt with the red line, in theory i should see the temperature but don't work.
may be, i'm wrong??
Thanks so much for your help mike..
I DO IT! i have a new web page for read the temperature and works when i click the link "GET TEMP"..... thanks so much for your help. now my idea is implement a dinamic refresh for the web page for see the temp or the RTC data without clicking the link, do you know what is the best method for do it this?? or the system only works with the link??
thanks mike.
Read from this thread forward.
http://forums.parallax.com/showthread.php?133268-Contest-Entry-Multi-Socket-Server&p=1038176&viewfull=1#post1038176
This is exactly for solve my problem, your code works great is very estable and fast....one more cuestion about the code, how many people can see the web page at the same time??
Greetings
this weekend i work very much with the spinneret...and work excellent, i add new pages and sensors and i can manipulate all variables, great. but i have a doubt about the acces over internet because in this moment only works via local red. so i read the document "make your spinneret internet accesible" and i understand about the port forward. but when i do in my router (d-link DIR-300) don't work and i can't access to my pink over internet only access over my local red.... so i need to know something new for access via internet to my spinneret?? or i need add or modify something in the code??
i ask you because you do it and you are the expert... please if you have any idea please help me...
Many thanks for all.
Your local "red"? That's "net" in English. I suspect your monolingual (English) readers might be confused by the term "red". [Or maybe I should give Parallax forum members more credit?]
I'm following your thread eagerly, because I have the same questions. Interesting stuff.
You have reason, in english is "Net". i from argentina and in my country the "net" is called "red".... thanks for follow.
For internet don't use 80 they are often blocked by providers . Try 2011 .....
Can you set your modem to DMZ (Demilitarized Zone) just for try.... you have to put your spinneret ip as destination.
In DMZ your modem is transparent to the spinneret, no blocking, no firewall on your side ....
If it's working you have to look in port forwarding.....
Of course remove the DMZ mode after testing to protect your local network.
In status of the modem you can look at wan ip. wan is the ip of your system for outsiders.
By normal (cheap) accounts, wan is always changing !
What is your WAN IP? The IP assigned by your internet provider.
What port is your Spinneret server on?
What port are you forwarding?
What URL are you using to hit the Spinneret?
Did you remember the port in the URL?
Thanks for reply... My WAN IP is dinamic so when i need try i found with http://www.whatismyip.com/ for example now my IP is 190.20.18.7.
- my local IP asigned to my spinneret is 192.168.0.103
- The port on my spinneret is 5000 (default in the spin code)
- In my router configuration i forward to IP 192.168.0.103 and port 5000
when i access to my spinneret via local net i type 192.168.0.103:5000 and works... i see the web pages and every goes well. but when i try to access via internet i type my WAN IP asigned by my internet provider, for example 190.20.18.7:5000 and don't work i can't see the web pages.
I try to apply DMZ to my local IP but i have the same result, i can't see my spinneret....any idea?? i follow your manual step by step and i learn so much about the spinneret and i have your spinneret direction as reference http://spinneret.servebeer.com:5000/ for this reason i use the port 5000.
please if you have any idea for solve my problem, i will be very grateful....thanks for all.
I can ping 190.20.18.7 and tracert successfully it's something in your router configuration.
When you look at your router setting you see 190.20.18.7 as the Internet IP address?
Yes the requests coming in on my gobal IP are forwarded to my local IP.... i'm capturing the portforward page configuration and the firewall configuration when finish i'll upload for you can see. in my router setings appears the same IP address that i see in the page whatismyip.com.
In few minutes i'll upload the screen captures of my router configuration, thanks for all.
i have the captures of my router configuration, in the portforwarding page i need to type a "name" in my case i type "spinneret" and in the public port type 5000 in the IP address type the IP of my spinneret 192.168.0.103 and in the private port automatically indicate the same number of the public port. in the trafic i select "any", in this option i can select "TCP", "UDP", or "any".
The firewall configuration appears automatically when i add the portforward rule and i can't modify anything only view.
I try to adding the IP of my spinneret to the DMZ but i have the same problem only see in my local red but when i try to access via internet typing my golbal ip i can't see my spinneret. What do you think about??
Thanks for all mike.
well, i'm continuing with the work in my spinneret, i solve the problem with the internet access, i try with other router and make port forwarding and this time works, i can see my spinneret out side of my net.
Now i'm experimenting with he micro SDcard i'm using a kingston 4GB and works great with the Datalogging section in the code of Mike G (HTTPserver) my doubt is, exist some methods for read the data in the TXT file created?? my idea is read the data from TXT archive and send to my web page for see the data, is posible do it??
Thanks for your answers, greetings.
i'm trying to read the microsd card, do you have any example method for read the data in the txt archive with the spinneret?
In this moment i can write data using the method for dataloggin in the HTTPserver, but i can't read the data, can you help me please?
Thanks for all.
wow, is very easy. I thinked is more complicated, but not.
The method for write data in the microsd is very cool and easy to use, about this... this method only can write in the same Log.txt
is posible generate a new log.txt every day? Or only can write in the same log.txt every day?
I'm trying to generate a new .txt in base to the filltime method, so doing this i'll have a new log.txt every day and the data will not blend.
Do you think that is posible?
Greetings