Hi Aurelien
var args = [0, 1]webiopi().callMacro("Temp", args, macro_Temp_Callback);}function macro_Temp_Callback(macro, args, data){temp0 = data.split(" ")[0];temp1 = data.split(" ")[1];webiopi().setLabel("macro2", "temp0 " + temp0 +" c");webiopi().setLabel("macro3", "temp1 " + temp1 +" c");}setInterval ("callMacro_Temp()", 6000);{
}); <- This is incorrect replace with }
HTTP GET /devices/tmp/sensor/temperature/fthanks for your patients :)
Hi Jay,
Jim, Great project, all do-able I would say, including adding alarms etc for high / low temperatures, you just need a K type thermocouple and a MAX31855 Thermocouple Amplifier for the flue, range -200°C to 1350°C , that breakout board connects directly to the raspi spi bus, so if your planning that make sure you don't use gpio 7, 8, 9 ,10,& 11 for anything they are all required to access the spi bus.
Hi Jim,
Some of my learning curve issues related to the real simple stuff like finally realizing I needed to change the directory name webiopi0.6.0 to webiopi.
Commenting out those two lines in the script was another big help.
I seem to have scrambled my sd card a few times and had all but given up on webiopi until I moved the entire OS to a USB stick. Thus far no fatal crashes have occurred. I remain concerned about where the 1wire modules are writing their temperature data. It would be nice if that was all being done in ram. Anyone know?
I was able to use webiopi in the background with an RRD setup and was able to publish nice graphs for a few days before one of my many fatal sd card crashes.
Now if I could just see an example where a 1wire signal was displayed on a graphic dial all within webiopi. I saw the one graphic example in a thread here but still can't quite connect the dots to make one work or even start. Google is usually my helper but there seems a steep cliff once one gets past the first successful square button.
Any links or thoughts about how to reach the next level of expertise with webiopi especially with regards to fancy graphical displays of data within a browser?
Jim
"The next installment could be how I get dials to work if anyone is interested." ToshiBass
While I am still looking at the google gauges simply because of their better control over the zone coloring, your solution is perfect for proof of concept while I focus attention elsewhere!
Thank you for all your efforts here!
Hi all,DH11 / DH22 / AM2302 humidity and temperature sensor, assuming you have the above script.py and index.html all working with the table of values and gauges, to get values from these sensors you will need a small program written in c from adafruit, webiopi does not have an inbuilt support for these sensors, I had to download some files from adafruit and compile the program, anyway attached is the compiled program I do not know if this will work as maybe it needs to be compiled locally, so someone needs to go through the process of installing the index.html & python script and checking if this works or if I need to detail what to download and go through the compiling the process.
Toshi
Hallo TulgaDies wird geschehen, wenn Sie einige Missverhältnis zwischen dem, was Sie Ihren Sensor in der Konfigurationsdatei genannt haben und was Sie es in Ihren Python-Skript rufen zunächst prüfen, ob beide Eintrags identisch sind und sicherstellen, dass der Sensor-ID korrekt ist, habenIn Ihrem Python-Skript haben Sie die Linie aufgenommen haben:Import von webiopi deviceInstanceWenn Sie weitere Hilfe benötigen, dann müssen Sie eine Kopie Ihrer Konfigurationsdatei und Python-Skript zu schreiben, denn es ist nicht einfach nur Messerstecherei in der Dunkelheit.Toshi
mkdir adafruit
cd adafruit
wget https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/archive/master.zip
unzip master.zip
cd Adafruit/Adafruit-Raspberry-Pi-Python-Code-master/Adafruit_DHT_Driver/
sudo ./Adafruit_DHT 22 22
def get_Humidity(): global D11_Humidity, D11_Temperature Last_Humidity = D11_Humidity Last_Temperature = D11_Temperature try: for x in range (3): try: output = subprocess.check_output(["/home/pi/webiopi/htdocss/DHT", "11", "8"]); # sensor type "11" or "22" , gpio pin "8" or "X" X being your connected gpio pin #print (output) except Exception, e: print (e) print("Unable to access D11 c output") pass
valueStr = str(output, encoding='utf8' )
matches = re.search("Temp =\s+([0-9.]+)", valueStr)
if (matches): temp = float(matches.group(1)) matches = re.search("Hum =\s+([0-9.]+)", valueStr)
humidity = float(matches.group(1)) D11_Temperature = "%.2f" % temp D11_Humidity = "%.0f" % humidity break else: D11_Temperature = Last_Temperature D11_Humidity = Last_Humidity print (D11_Temperature, D11_Humidity) return D11_Temperature, D11_Humidity except Exception, e: print (e) print("Unable to access D11") pass
Hoipe it helps
Toshi
temp0 = DS18B20(slave="28-0000045328a0") #<--- your sensor numbers as defined in config file temp1 = DS18B20(slave="28-000004de52e9") temp2 = DS18B20(slave="28-000004816b68") temp3 = DS18B20(slave="28-000004f8f104") temp4 = DS18B20(slave="28-00000515fd8f") temp5 = DS18B20(slave="28-000005164c50") temp6 = DS18B20(slave="28-000004f87ee5") temp7 = 0
to this
temp1 = 0temp2 = 0 temp3 = 0 temp4 = 0 temp5 = 0 temp6 = 0 temp7 = 0once tested and working you can delete all instance of temp to just have the dh11 partToshi
i attach my script but the temperature don't update , only if i restart the webiopi.
root@raspberrypi:/home/pi/perry/python# sudo webiopi -c /etc/webiopi/config
2015-01-27 09:33:09 - WebIOPi - INFO - Starting WebIOPi/0.7.0/Python3.2
2015-01-27 09:33:09 - WebIOPi - INFO - GPIO - Native mapped to REST API /GPIO
2015-01-27 09:33:09 - WebIOPi - INFO - Loading configuration from /etc/webiopi/config
2015-01-27 09:33:09 - WebIOPi - INFO - Temperature - DS18B20(slave=28-00042d3d3aff) mapped to REST API /devices/temp0
2015-01-27 09:33:09 - WebIOPi - INFO - Loading myscript from /home/pi/perry/python/script.py
2015-01-27 09:33:09 - WebIOPi - WARNING - Access unprotected
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.2/threading.py", line 740, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.7.0-py3.2-linux-armv6l.egg/webiopi/utils/thread.py", line 23, in run
self.func()
File "/home/pi/perry/python/script.py", line 28, in loop
temp0 = "%.2f" % (temp0.getCelsius())
UnboundLocalError: local variable 'temp0' referenced before assignment
2015-01-27 09:33:09 - WebIOPi - INFO - HTTP Server binded on http://192.168.1.22:8000/
2015-01-27 09:33:09 - WebIOPi - INFO - CoAP Server binded on coap://224.0.1.123:5683/ (MULTICAST)
2015-01-27 09:33:09 - WebIOPi - INFO - CoAP Server binded on coap://192.168.1.22:5683/
Error is because in your loop temp0 is being treated as a local variable you need to be effecting the global variable temp0 so you need to add the line in red and you should be good to go.
#Looped by WebIOPi
def loop():
global temp0
temp0 = "%.2f" % (temp0.getCelsius())
webiopi.sleep(5) Toshi
AttributeError: 'str' object has no attribute 'getCelsius'
What's the problem ? i don't understand....
thanks
Pierantonio
Temp0 = webiopi.deviceInstance("Temp0")
Second way is to import the DS18B20 sensor directly into your python script, this way you will not see the sensor in the Devices-Monitor
from webiopi.devices.sensor.onewiretemp import DS18B20Temp0 = DS18B20(slave="28-00000xxxxxx")
OK you notice I use capital T in Temp0 you need to use a different variable name in the following line or you will get the error your seeing:
temp0 = "%.2f" % (temp0.getCelsius()) will give an error because you use the same same variable on both sides of the argument
temp0 = "%.2f" % (Temp0.getCelsius()) # no error
my_temp0 = "%.2f" % (temp0.getCelsius()) # no error
DS18B20 = "%.2f" % (temp0.getCelsius()) # no error
So if you decide which method your going to use to import the sensor and remove the surplus lines from your script, and ensure you use a different var name each side of xxxx = "%.2f" % (xxxx.getCelsius()) include global temp0 or what ever var you use in your loop before the line xxxx = "%.2f" % (xxxx.getCelsius()) then it will work.
Toshi
temp
=
((data
*
330
)
/
float
(
1023
))
-
50
temp
=
round
(temp,places)
Regards,
Jam
Hi AurelienIt doesn't take much to stop a web page loading, if your using chrome as your web browser try going to the Customize & Control icon - Tools - JavaScript console .. this will help you track-down problems,Anyway very simple mistake as follows:-} <-This is incorrect replace with });function callMacro_Temp(){var args = [0, 1]webiopi().callMacro("Temp", args, macro_Temp_Callback);}function macro_Temp_Callback(macro, args, data){temp0 = data.split(" ")[0];temp1 = data.split(" ")[1];webiopi().setLabel("macro2", "temp0 " + temp0 +" c");webiopi().setLabel("macro3", "temp1 " + temp1 +" c");}setInterval ("callMacro_Temp()", 6000);{}); <- This is incorrect replace with }That's it, I ran it and your page is working with these 2 changes above.RegardsToshi
////////
webiopi().ready(function() { var content; content = $("#content") }); setInterval ("callMacro_get_temp()", 2000);{ } function callMacro_get_force() { var arg = [0] //call the python macro get_force webiopi().callMacro("get_force", arg, macro_get_force_callback); } function macro_get_force_callback(macro, arg, data) { content.innerHTML = data.split(" ")[0] +" °C"; }
////////
My index2.html look like this:
//////
<html> | |
<head> | |
<title>RPI 1 Temperature</title> | |
<script type="text/javascript" src="/webiopi.js"></script> | |
<script type="text/javascript" src="script.js"></script> | |
<link rel="stylesheet" type="text/css" href="css/style.css"> | |
</head> | |
<body style="background-color: Yellow"> | |
<div id="content" style="text-align: center; color: Black; font-family: verdana"></div> | |
<p style="text-align: center; font-family: verdana; font-size:50%"><b>RPI_1 Temperature</b></p> | |
</body> | |
</html> |
////////
Then on my main index.html it is calling my index2.html using an iframe with this:
<iframe width="160" height="45" src="http://*********.ddns.net:8000/index2.html" style="position: absolute; left: -170px; top: 75px"></iframe>
Attached is the screenshot!
But if you have any better direct idea is much better.
I am creating two RPI with each has a camera that was hosted with RPI cam control and webiopi for my temp and PIR sensor that triggers the alarm.
The RPI cam control in port 9700 that is called in my webiopi using iframe as well so that I can have full control of all function in one...
Regards,
Jam
Toshi
--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
////////
webiopi().ready(function() { var content; content = $("#content") }); setInterval ("callMacro_get_temp()", 2000);{ } function callMacro_get_temp() { var arg = [0] //call the python macro get_force webiopi().callMacro("get_temp", arg, macro_get_temp_callback); } function macro_get_temp_callback(macro, arg, data) { content.innerHTML = data.split(" ")[0] +" °C"; }
Toshi
Hello to allI resume the post because they are several days that I try to bring up the temperatures in the two buttons but I can not figure out where I'm wrong.From complete novice I was able to build the page attached but to see temperatures just can not, if I connect at http://192.168.1.233:8085/app/devices-monitor I show both sensor work normally.
I would also make sure to send a message gmail detect motion when the PIR sensor (at the time one but I think connect two of them) detects motion only if the alarm was activated by the alarm button.
Can someone come to my rescue, and check the attachment and implement the part relating to the pir's missing?
@webiopi.macro def Temp(arg0, arg1):
Temp0 = "%.2f" % (temp0.getCelsius()) Temp1 = "%.2f" % (temp1.getCelsius())return ("%s %s" % (Temp0, Temp1))
@webiopi.macro def Temp(arg0, arg1):
Temp0 = "%.2f" % (temp0.getCelsius()) Temp1 = "%.2f" % (temp1.getCelsius())
print (Temp0, Temp1)
return ("%s %s" % (Temp0, Temp1))
Start webiopi with sudo webiopi -d -c /etc/webiopi/config check ssh console window you should see webiopi starting ... a line that says loading your script as you detailed in the config file and you shoud see Temp0 and Temp1 values beeing printed on the console.
That's assuming you did read the Tutorial and have modified the config file to point to your files ? see http://webiopi.trouch.com/CONFIGURATION.html
specifically these lines need to be pointing to where you have your index.html and script.py files.
doc-root = /home/pi/webiopi/examples/scripts/macros welcome-file = index.html
[SCRIPTS] # name = sourcefile myscript = /home/pi/webiopi/examples/scripts/macros/script.py
In your html file mod the RED parts as follows then I think it should work :