Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample Code For Indoor Temp #39

Open
jjkirby opened this issue Oct 21, 2021 · 1 comment
Open

Sample Code For Indoor Temp #39

jjkirby opened this issue Oct 21, 2021 · 1 comment

Comments

@jjkirby
Copy link

jjkirby commented Oct 21, 2021

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?

@andy-cooper
Copy link

Have a look at my fork - I integrated the Ecobee thermostat with this so that I can see the indoor temperature and current thermostat settings.

In particular, look at ecobee.py:L120 for the location where most of the work to retrieve and display the temperature happens. It runs as a separate thread that never exits; the thread is started in main.py:L426

All works fine for me ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants