Hello, thank you very much for the answer
I’ve tried to fix this and the results are better than before, but not perfect
The problem is like this, on the lxterminal on the raspberry pi it already shows all measurement points (totaling 8), but when checked on ubidots it reads only 3 measurement points
Coding:
import os
import time
import requests
os.system(‘modprobe w1-gpio’)
os.system(‘modprobe w1-therm’)
temp_sensor1 = ‘/sys/bus/w1/devices/28-000000147e7d/w1_slave’
temp_sensor2 = ‘/sys/bus/w1/devices/28-000000150f73/w1_slave’
temp_sensor3 = ‘/sys/bus/w1/devices/28-3c01f0962836/w1_slave’
temp_sensor4 = ‘/sys/bus/w1/devices/28-00000014ebab/w1_slave’
temp_sensor5 = ‘/sys/bus/w1/devices/28-00000016eceb/w1_slave’
temp_sensor6 = ‘/sys/bus/w1/devices/28-3c01f09664ab/w1_slave’
temp_sensor7 = ‘/sys/bus/w1/devices/28-00000014f22c/w1_slave’
temp_sensor8 = ‘/sys/bus/w1/devices/28-3c01f0960e4c/w1_slave’
def temp_raw1(temp_sensor1):
f = open(temp_sensor1, ‘r’)
lines = f.readlines()
f.close()
return lines
def temp_raw2(temp_sensor2):
f = open(temp_sensor2, ‘r’)
lines = f.readlines()
f.close()
return lines
def temp_raw3(temp_sensor3):
f = open(temp_sensor3, ‘r’)
lines = f.readlines()
f.close()
return lines
def temp_raw4(temp_sensor4):
f = open(temp_sensor4, ‘r’)
lines = f.readlines()
f.close()
return lines
def temp_raw5(temp_sensor5):
f = open(temp_sensor5, ‘r’)
lines = f.readlines()
f.close()
return lines
def temp_raw6(temp_sensor6):
f = open(temp_sensor6, ‘r’)
lines = f.readlines()
f.close()
return lines
def temp_raw7(temp_sensor7):
f = open(temp_sensor7, ‘r’)
lines = f.readlines()
f.close()
return lines
def temp_raw8(temp_sensor8):
f = open(temp_sensor8, ‘r’)
lines = f.readlines()
f.close()
return lines
def read_temp1(temp_sensor1):
lines = temp_raw1(temp_sensor1)
while lines[0].strip()[-3:] != ‘YES’:
time.sleep(0.2)
lines = temp_raw1(temp_sensor1)
temp_output = lines[1].find(‘t=’)
if temp_output != -1:
temp_string = lines[1].strip()[temp_output+2:]
temp_c = float(temp_string) / 1000.0
payload = {‘Kabin’: temp_c}
return payload
def read_temp2(temp_sensor2):
lines = temp_raw2(temp_sensor2)
while lines[0].strip()[-3:] != ‘YES’:
time.sleep(0.2)
lines = temp_raw2(temp_sensor2)
temp_output = lines[1].find(‘t=’)
if temp_output != -1:
temp_string = lines[1].strip()[temp_output+2:]
temp_c = float(temp_string) / 1000.0
payload = {‘Out Evap’: temp_c}
return payload
def read_temp3(temp_sensor3):
lines = temp_raw3(temp_sensor3)
while lines[0].strip()[-3:] != ‘YES’:
time.sleep(0.2)
lines = temp_raw3(temp_sensor3)
temp_output = lines[1].find(‘t=’)
if temp_output != -1:
temp_string = lines[1].strip()[temp_output+2:]
temp_c = float(temp_string) / 1000.0
payload = {‘Suction’: temp_c}
return payload
def read_temp4(temp_sensor4):
lines = temp_raw4(temp_sensor4)
while lines[0].strip()[-3:] != ‘YES’:
time.sleep(0.2)
lines = temp_raw4(temp_sensor4)
temp_output = lines[1].find(‘t=’)
if temp_output != -1:
temp_string = lines[1].strip()[temp_output+2:]
temp_c = float(temp_string) / 1000.0
payload = {‘Discharge’: temp_c}
return payload
def read_temp5(temp_sensor5):
lines = temp_raw5(temp_sensor5)
while lines[0].strip()[-3:] != ‘YES’:
time.sleep(0.2)
lines = temp_raw5(temp_sensor5)
temp_output = lines[1].find(‘t=’)
if temp_output != -1:
temp_string = lines[1].strip()[temp_output+2:]
temp_c = float(temp_string) / 1000.0
payload = {‘In Kondensor’: temp_c}
return payload
def read_temp6(temp_sensor6):
lines = temp_raw6(temp_sensor6)
while lines[0].strip()[-3:] != ‘YES’:
time.sleep(0.2)
lines = temp_raw6(temp_sensor6)
temp_output = lines[1].find(‘t=’)
if temp_output != -1:
temp_string = lines[1].strip()[temp_output+2:]
temp_c = float(temp_string) / 1000.0
payload = {‘Out Kondensor’: temp_c}
return payload
def read_temp7(temp_sensor7):
lines = temp_raw7(temp_sensor7)
while lines[0].strip()[-3:] != ‘YES’:
time.sleep(0.2)
lines = temp_raw7(temp_sensor7)
temp_output = lines[1].find(‘t=’)
if temp_output != -1:
temp_string = lines[1].strip()[temp_output+2:]
temp_c = float(temp_string) / 1000.0
payload = {‘In Ekspansi’: temp_c}
return payload
def read_temp8(temp_sensor8):
lines = temp_raw8(temp_sensor8)
while lines[0].strip()[-3:] != ‘YES’:
time.sleep(0.2)
lines = temp_raw8(temp_sensor8)
temp_output = lines[1].find(‘t=’)
if temp_output != -1:
temp_string = lines[1].strip()[temp_output+2:]
temp_c = float(temp_string) / 1000.0
payload = {‘In Evap’: temp_c}
return payload
while True:
r = requests.post(‘http://things.ubidots.com/api/v1.6/devices/Kabin/?token=TOKEN’, data=read_temp1(temp_sensor1))
r = requests.post(‘http://things.ubidots.com/api/v1.6/devices/OutEvap/?token=TOKEN’, data=read_temp2(temp_sensor2))
r = requests.post(‘http://things.ubidots.com/api/v1.6/devices/Suction/?token=TOKEN’, data=read_temp3(temp_sensor3))
r = requests.post(‘http://things.ubidots.com/api/v1.6/devices/Discharge/?token=TOKEN’, data=read_temp4(temp_sensor4))
r = requests.post(‘http://things.ubidots.com/api/v1.6/devices/InKondensor/?token=TOKEN’, data=read_temp5(temp_sensor5))
r = requests.post(‘http://things.ubidots.com/api/v1.6/devices/OutKondensor/?token=TOKEN’, data=read_temp6(temp_sensor6))
r = requests.post(‘http://things.ubidots.com/api/v1.6/devices/InEkspansi/?token=TOKEN’, data=read_temp7(temp_sensor7))
r = requests.post(‘http://things.ubidots.com/api/v1.6/devices/InEvap/?token=TOKEN’, data=read_temp8(temp_sensor8))
print(‘Posting temperatures in Ubidots’)
print(read_temp1(temp_sensor1))
print(read_temp2(temp_sensor2))
print(read_temp3(temp_sensor3))
print(read_temp4(temp_sensor4))
print(read_temp5(temp_sensor5))
print(read_temp6(temp_sensor6))
print(read_temp7(temp_sensor7))
print(read_temp8(temp_sensor8))
time.sleep(3)
So, is there still something wrong with my coding results?
Thank you