It's getting cold, so I tried to make it possible to turn on / off the AC heater automatically with Raspberry Pi!

Purpose: I tried turning the heater on and off with the Raspberry Pi!

Recently, it has become cold and it has become a difficult season for poor circulation. Therefore, I implemented IoT that turns on the heater when it reaches a certain temperature and turns it off when it gets warm to some extent.

What you have prepared

setup

-I quoted from GitHub.

  sudo apt-get install git

--Sample python program installation

  git clone https://github.com/szazo/DHT11_Python.git

circuit diagram

――I liken it to someone who has nothing to do with the temperature sensor. sorry. --From the right (*** GND, PIN to read the sensor value, 5V ***) --The Heater is AC, so you can just connect it to the SSR and stab it into the power strip. ―― *** * If you make a mistake in the circuit, the temperature sensor will become extremely hot. Please be careful. *** *** 温度センサー回路.jpg

Program (Python)

-I used Python3.
You can just quote dht11_example.py in DHT11_Python.
This time, I made this program.

dht11_example.py


# coding: utf-8
import RPi.GPIO as GPIO
import dht11
import time
import datetime

# initialize GPIO
GPIO.setwarnings(False)
#Declared to specify by GBCM number
GPIO.setmode(GPIO.BCM)
#Set pin 17 of BCM to output
GPIO.setup(17,GPIO.OUT)

# read data using pin 14
instance = dht11.DHT11(pin=14)
HotTemp = 20
ColdTemp = 5
sleepSecond = 0

try:
    while True:
        result = instance.read()
        if result.is_valid():
            tmp = result.temperature
            print(tmp)
            if tmp <= ColdTemp:
                # Heater running
                GPIO.output(17,1)
                print("Heater ON")
                sleepSecond = 10
            elif tmp >= HotTemp:
                # Heater stop
                GPIO.output(17,0)
                print("Heater OFF")
                sleepSecond = 10
            else :
                time.sleep(sleepSecond)

except KeyboardInterrupt:
        GPIO.cleanup()

*** I think it's a very easy-to-understand program. *** ***

Implementation

Let's implement it for the time being!

sudo python3 dht11_example.py 

*** Did it work? *** ***

If it's not working

--Try adding *** as GPIO *** to the first part of dht11.py of DHT11.

dht11.py


import time
#Add as GPIO to import RPi
import RPi as GPIO

class DHT11Result:
    'DHT11 sensor result returned by DHT11.read() method'

    ERR_NO_ERROR = 0
    ERR_MISSING_DATA = 1
    ERR_CRC = 2

Recommended Posts

It's getting cold, so I tried to make it possible to turn on / off the AC heater automatically with Raspberry Pi!
I wanted to run the motor with Raspberry Pi, so I tried using Waveshare's Motor Driver Board
I tried to automate the watering of the planter with Raspberry Pi
I tried to make it possible to automatically send an email just by double-clicking the [Python] icon
I tried to make a calculator with Tkinter so I will write it
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)
I tried to make it possible to automatically send an email just by double-clicking the [GAS / Python] icon
Make a thermometer with Raspberry Pi and make it visible on the browser Part 3
When I tried to do socket communication with Raspberry Pi, the protocol was different
I tried to make it easy to change the setting of authenticated Proxy on Jupyter
I tried to make it on / off by setting "Create a plug-in that highlights double-byte space with Sublime Text 2".
I tried to move ROS (Melodic) with the first Raspberry Pi (Stretch) at the beginning of 2021
I tried using the DS18B20 temperature sensor with Raspberry Pi
I tried to make a motion detection surveillance camera with OpenCV using a WEB camera with Raspberry Pi
I tried to expand the database so that it can be used with PES analysis software
[Shell script] It's annoying to send the same content every week, so I tried to automate it! !! !!
A memorandum when I tried to get it automatically with selenium
I tried to get started with Bitcoin Systre on the weekend
I tried to make a system to automatically acquire the program guide → register it in the calendar in one day
I tried to push the Sphinx document to BitBucket and it will be automatically reflected on the web server
Connect to VPN with your smartphone and turn off / on the server
Use python on Raspberry Pi 3 to light the LED with switch control!
Matching karaoke keys ~ I tried to put it on Laravel ~ <on the way>
I tried to automatically extract the movements of PES players with software
I tried with the top 100 PyPI packages> I tried to graph the packages installed on Python
[Zaif] I tried to make it easy to trade virtual currencies with Python
I tried to estimate the pi stochastically
In IPython, when I tried to see the value, it was a generator, so I came up with it when I was frustrated.
I wanted to know the number of lines in multiple files, so I tried to get it with a command
I have a question. Unable to make protocol buffers on raspberry pi 3 modelB.
(complex) It depends on how to name the coefficient of the morlet wavelet, the appropriate setting value, and the material, so I tried to organize it as much as possible.
When I tried to change the root password with ansible, I couldn't access it.
When I tried to make a VPC with AWS CDK but couldn't make it
I tried to build an environment of Ubuntu 20.04 LTS + ROS2 with Raspberry Pi 4
I tried to rescue the data of the laptop by booting it on Ubuntu
I tried to create a button for Slack with Raspberry Pi + Tact Switch
I didn't understand the Resize of TensorFlow so I tried to summarize it visually.
Use python on Raspberry Pi 3 and turn on the LED when it gets dark!
I tried to automatically send the literature of the new coronavirus to LINE with Python
I tried to make the weather forecast on the official line by referring to the weather forecast bot of "Dialogue system made with python".
I tried to make OneHotEncoder, which is often used for data analysis, so that it can reach the itch.
I tried to save the data with discord
I tried L-Chika with Raspberry Pi 4 (Python edition)
Power on / off your PC with raspberry pi
I tried playing with the calculator on tkinter
Connect to MySQL with Python on Raspberry Pi
I tried to scrape YouTube, but I can use the API, so don't do it.
I tried to make the phone ring when it was posted at the IoT post
Make it easy to install the ROS2 development environment with pip install on Python venv
[Rails] v1.0 came out on google-cloud-vision of gem, so I tried to support it
A Python beginner made a chat bot, so I tried to summarize how to make it.
It's Cat Day, so I tried to make something that translates into cat-like words.
I wanted to operate google spread sheet with AWS lambda, so I tried it [Part 2]
I tried to read and save automatically with VOICEROID2 2
I tried to implement Minesweeper on terminal with python
Try to visualize the room with Raspberry Pi, part 1
I tried to touch the CSV file with Python
I tried to solve the soma cube with python
I tried to automatically read and save with VOICEROID2
I tried to automatically generate a password with Python3
I tried to solve the problem with Python Vol.1