Jun-22-2018, 10:34 PM
Hi,
I have been trying to create something like this for a while to use with a flask app, I am trying to learn python3 so I am lost with the above, I want to create a module that I can import
with a seperate file with a list of the sensors
Can any one tell me if the first code will work as a module to be imported ie:
import readsensor as sensorID ??? and if then I would be able to call the function with:
read_sensor(solar_panel) ???
so that I can then use the returned value to compare with another to operate the solar pump ie:
I am using a pi zero 4gb card stretch 9 lite via ssh
Any help greatly wanted
Paul
I have been trying to create something like this for a while to use with a flask app, I am trying to learn python3 so I am lost with the above, I want to create a module that I can import
def read_sensor(sensorID)
tempfile = open("/sys/bus/w1/devices/"+ sensorID +"/w1_slave")
thetext = tempfile.read()
tempfile.close()
tempdata = thetext.split("\n") [1].split(" ")[9]
temperature = float(tempdata[2:])
temp = temperature / 1000
print (temp"sensorname") with a seperate file with a list of the sensors
# Execute DS18B20 function for sensor ID's below.
solar_panel = float(read_ds18b20('28-0516a3ff90ff'))
top_cyl = float(read_ds18b20('28-0317003f1cff'))
flow_panel = float(read_ds18b20('28-0416c4a3a0ff')) (I have stolen the code from above) I want the name of the sensor to print out with its temperature. I know the code needs to be modified.Can any one tell me if the first code will work as a module to be imported ie:
import readsensor as sensorID ??? and if then I would be able to call the function with:
read_sensor(solar_panel) ???
so that I can then use the returned value to compare with another to operate the solar pump ie:
while solar_panel + 5 > flow_panel GPIO.output(relay,GPIO.HIGH)As you can see I have a lot to learn!!!
I am using a pi zero 4gb card stretch 9 lite via ssh
Any help greatly wanted
Paul
