I have two questions, i want to call a URL passing in three parameters SensorName Temperature Humidity the sensor is working so the temp and humi parameters are correct so how to i correctly call the usrl passing the parameters thanks Madaxe
i solved the first part of adding the values to the url, the code runs but the url does not post, but in the output if i open the url then it works
Here is the terminal output from the code above i printed out the response also
the strange thing is if i paste the url into a browser on the pi then i get data in the table
#!/usr/bin/env python import urllib3 import subprocess import os import pigpio import DHT22 import urllib2 import urllib host = subprocess.check_output('hostname', shell=True) http = urllib3.PoolManager() from time import sleep os.chdir('/home/pi/PIGPIO') pi = pigpio.pi() s = DHT22.sensor(pi, 4) try: while 1: s.trigger() temp = s.temperature() humi = s.humidity() print 'Temp: {0:0.1f}*C Humidity: {1:0.1f}%'.format(temp, humi) r = request.post('http://192.168.0.1/WebTempHumidity/WebServiceTempHumidity.asmx/WriteTempHumidity?SensorName=Marcs&Temperature=56&Humidity=78') sleep(3) except KeyboardInterrupt: pass i solved the first part of adding the values to the url, the code runs but the url does not post, but in the output if i open the url then it works
#!/usr/bin/env python
import urllib3
import subprocess
import os
import pigpio
import DHT22
import requests
host = subprocess.check_output('hostname', shell=True)
http = urllib3.PoolManager()
from time import sleep
os.chdir('/home/pi/PIGPIO')
pi = pigpio.pi()
s = DHT22.sensor(pi, 4)
try:
while 1:
s.trigger()
temp = s.temperature()
humi = s.humidity()
print 'Temp: {0:0.1f}*C Humidity: {1:0.1f}%'.format(temp, humi)
RBS_URL ='http://192.168.178.28/WebTempHumidity/WebServiceTempHumidity.asmx/WriteTempHumidity?SensorName=Marcs&Temperature=' + str(temp) + '&Humidity=' + str(humi) + ''
print(RBS_URL)
r = requests.post(RBS_URL)
sleep(3)
except KeyboardInterrupt:
passHere is the terminal output from the code above i printed out the response also
the strange thing is if i paste the url into a browser on the pi then i get data in the table
Temp: 24.1*C Humidity: 59.6% http://192.168.178.28/WebTempHumidity/WebServiceTempHumidity.asmx/WriteTempHumidity?SensorName=Marcs&Temperature=24.1&Humidity=59.6 Request format is invalid: .
