Skip to content

Sample Code For Indoor Temp #39

Description

@jjkirby

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions