-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
I have a DHT22 Temp sensor. I am new to Python and I was wondering if there is any sample code to show how to incorporate those readings for indoor Temp/humidity?
I can probably write the function call but what pseudo-code do you use to call that function in main.py would be helpfully. Working example (sample) would be awesome!
Follow-up:
I wrote a sample python script which returns temperature (and humidity):
import board
import adafruit_dht
def gettemp():
dhtDevice = adafruit_dht.DHT22(board.D4)
return dhtDevice.temperature * (9 / 5) + 32
This works fine to test the sensor working
for the main.py I call:
# Indoor Temperature
Clock.schedule_interval(partial(temp.gettemp, self.Obs), 10.0)
The function looks like this:
import board
import adafruit_dht
dhtDevice = adafruit_dht.DHT22(board.D4)
def gettemp(obs):
obs['inTemp'][0] = str(dhtDevice.temperature * (9 / 5) + 32)
obs['inTemp'][1] = '\u00b0' + "F"
return obs
I even tried to manually set via:
self.Obs['inTemp'][0] = "25.0"
self.Obs['inTemp'][1] = '\u00b0' + "F"
I never see the update? A Kivy problem?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels