Python Forum
How to create a value system with a temp/humidity sensor?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create a value system with a temp/humidity sensor?
#1
I have a dht22 temp/humidity sensor and I am looking for help on how to create a value system within the sensor reading. Currently I have a fan turning on if the reading is greater than a certain temp or humidity with if-elif-else statements. But I am looking to create a value system where I could set point values for example; t = temp, h = humidity, p = points, v = value. if t = 80 then p = .1, if t = 81 then p = .2 (and so on), if h = 40 then v = .1, if h = 50 v = .2 (and so ). Then I am looking to code a similar system with if-elif-else statements to say "if (p + v) > 1: (Turn fans on), else: (do nothing).

I am just looking for some advice on what function would be the best solution because if-elif-else doesn't seem to be the right fit and I'm not too familiar with variables and such.

I have a rpi 3. Thank You!
Reply
#2
If there is a simple math relationship, then use it. For instance maybe p=(t-79)/10.. Otherwise, make an dictionary where keys are the input values (maybe rounded down) and the values are the output.

Normally, you can avoid writing along series of if/elif/else by using data-driven code (like using a dictionary as mentioned above).
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#3
Thank You Soo Much!!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Deleting Windows temp folder Raysz 7 445 Apr-02-2024, 12:36 PM
Last Post: Raysz
  pyspark creating temp files in /tmp folder aliyesami 1 5,019 Oct-16-2021, 05:15 PM
Last Post: aliyesami
  Help with storing temp data for each day then recording min/max in app. trthskr4 3 2,430 Sep-10-2021, 10:51 PM
Last Post: trthskr4
  How to save Matplot chart to temp file? Morkus 2 4,541 Jun-12-2021, 10:52 AM
Last Post: Morkus
  get data (temperature and humidity) from DHT22 into CSV and sending them over the net apollo 0 3,865 Apr-16-2021, 07:49 PM
Last Post: apollo
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 16,652 Jan-11-2021, 06:30 PM
Last Post: ykumar34
  Create sensor data for a IoT project georgelza 9 5,888 Dec-20-2019, 06:19 PM
Last Post: georgelza
Question Difference between Python's os.system and Perl's system command Agile741 13 6,847 Dec-02-2019, 04:41 PM
Last Post: Agile741
  Get system info from PI (cpu load and temp) korenron 2 2,104 Aug-04-2019, 08:45 AM
Last Post: korenron
  temp analysis Simba 13 5,909 Apr-25-2019, 09:13 PM
Last Post: Simba

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020