Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Timo Furrer
@timofurrer
Great!
cf-programmers
@cf-programmers
"It also works on a Beagle Bone". Did anybody actually tested this package on BeagleBone? If yes please add the Beaglebone setup process.
Timo Furrer
@timofurrer
I haven't tried it myself. But know from other people who got it to work. Also, I've found this issue dating quite a while back: timofurrer/w1thermsensor#16
maybe it helps
I'll check if I can find more material
Haasjes
@Haasjes
Hello,
How can i separe 2 sensor values to int?
this is the code i use for 2 sensors

import time
from w1thermsensor import W1ThermSensor
sensor = W1ThermSensor()

while True:
for sensor in W1ThermSensor.get_available_sensors ():
print("Sensor %s has temperature %.2f" % (sensor.id, sensor.get_temperature()))
time.sleep(0.01)

Timo Furrer
@timofurrer
Hi @Haasjes ... I didn't quite understand. What do you want to do?
Haasjes
@Haasjes
I have 2 temp sensors, and i used the code above to read these sensors. But i want the temp value in a Integer so i can do same calulations.
im not sure how i can get only the value for these 2 temp sensors
Timo Furrer
@timofurrer
you can assign sensor.get_temperature() to a variable:
temperature = sensor.get_temperature()
Haasjes
@Haasjes
But how can u do this for 1 second sensor?
Its not temperature2 = sensor2.get_temperature() right ?
Timo Furrer
@timofurrer
no, not unless the second W1ThermSensor object is assigned to the variable sensor2
I suggest that you assign the two sensors based on the id to variable
sensor1 = W1ThermSensor(id="first-sensor-id")
sensor2 = W1ThermSensor(id="second-sensor-id")
Haasjes
@Haasjes
But when we replace a sensor with a new one, we need to manual assign the sensor id?
Timo Furrer
@timofurrer
Yes
Another way would be to unpack the list of sensors into variables (as long as the number of sensor stays the same)
sensor1, sensor2 = W1ThermSensor.get_available_sensors()
Haasjes
@Haasjes
I've almost done it, only the value in the label doesn't change. It stays around the first value when I run the program. What am I doing wrong here?

import tkinter as tk
from PIL import ImageTk
from PIL.ImageTk import PhotoImage
from tkinter import Button
from tkinter import simpledialog
from tkinter import Entry, END, Frame, Toplevel, StringVar
from tkinter import Label
from w1thermsensor import W1ThermSensor
import time

root = tk.Tk()
canvas = tk.Canvas(root, width=600, height=420, background="Black")
canvas.pack()
canvas.create_image(400, 240)

sensor1, sensor2 = W1ThermSensor.get_available_sensors()

Label3 = Label(text=sensor1.get_temperature())
Label3_window = canvas.create_window(100, 100, anchor="nw", window=Label3)

Label4 = Label(text=sensor2.get_temperature())
Label4_window = canvas.create_window(200, 200, anchor="nw", window=Label4)

root.mainloop()

Timo Furrer
@timofurrer
Well, there is no code here which would update that Label ... so it remains the initial value.
Haasjes
@Haasjes
how can u update the label? .sleep doesnt work
e1w00db1ue5
@e1w00db1ue5
Hey, I'm trying to build the latest version as I have experienced one of the issues it fixes. I'm a bit of a newbie tho so may be doing something wrong but I get the following error;

'
============== 1 failed, 144 passed, 16 warnings in 22.17 seconds ==============
E: pybuild pybuild:341: test: plugin distutils failed with: exit code=1: cd /home/pi/w1/w1thermsensor/.pybuild/cpython3_3.7_w1thermsensor/build; python3.7 -m pytest {dir}/tests/ -s
dh_auto_test: pybuild --test -i python{version} -p 3.7 returned exit code 13
make: * [debian/rules:10: build] Error 25
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui failed'

Can anyone help?