In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use Python self-made Wechat remote intelligent temperature and hygrometer", so the editor summarized the following contents, detailed contents and clear steps, which can be used for reference. I hope you can get something after reading this article. Let's take a look at this "how to use Python self-made Wechat remote intelligent temperature and hygrometer" article.
1. Apply for Wechat push service
There are many platforms that can realize Wechat push service, so I won't explain them one by one here. I chose "Server paste", which is called "ServerChan" in English. You can choose the platform you think is easier to use.
1. Login: log in to the website with your GitHub account, click to go to the "send message" page, and you will get a SCKEY.
two。 Binding: click the "Wechat push" page, scan the code to follow and complete the binding at the same time.
3. Send a message: send a GET request to https://sc.ftqq.com/SCKEY.send and you can receive the message in Wechat.
2. Let's start the DIY temperature and humidity meter
1. Choose the appropriate main control board
I prefer python programming, here I choose the TPYBoardv202 (esp8266) development board that supports micropython. The development board can be programmed directly with python, the function is still relatively powerful, and even can be used as a web server. Here we mainly use it for temperature and humidity sensor control and network request.
2. DHT11 temperature and humidity sensor
DHT11 is a commonly used temperature and humidity sensor, which can be easily bought online. To put it simply, it is the temperature and humidity of the current environment that can be obtained with this sensor.
The sensor is very easy to use, some with 3 pins and some with 4 pins. When we use it, we only use three, namely VCC (power pin, 5V), DATA (data pin) and GND (grounding).
3. The correct connection method
Concrete wiring correspondence and physical drawing of TPYBoardv202 and DHT11
TPYBoard v202DHT11 sensor + 5vvccG5DATAGNDGND
Third, indispensable programming
TPYBoardv202 has two main files to control, one is boot,py, the other is main.py. We only need to modify these two files to complete the program.
1. Write boot script
Import networkimport utime pdcn = network.WLAN (network.STA_IF) pdcn.active (True) pdcn.connect ('wifi account', 'wifi password') utime.sleep (5) if pdcn.isconnected (): print ("WiFi isconnected% s."% pdcn.ifconfig () [0]) else: pdcn.active (False) utime.sleep (5) print ("WiFi cannot connect.")
2. Write main.py script
# coding=utf-8import urequestsimport dhtimport machinefrom machine import Pinimport time class AlarmSystem: def _ init__ (self): self.d = dht.DHT11 (machine.Pin (5)) def dht11 (self): try: self.d.measure () return 'Temp:'+str (self.d.temperature ()) +' °C-- Hum:'+str (self.d.humidity ()) +'%' Except: return'0' def push (self Result): title = "TPYBoardv202 prompt you: pay attention to weather changes and keep a healthy mood" content = 'text='+title+'&'+'desp='+result url= "https://sc.ftqq.com/ your key. Send?% s"% content r = urequests.get (url) r.close () p2=Pin (2 Pin.OUT) a = AlarmSystem () def SendData (): p2.value (not p2.value ()) data_= a.dht11 () if (datastats): print (data_) a.push (data_) else: print ('GET Data Fail') if _ name__ =' _ _ main__': while True: SendData () time.sleep
IV. Sharing of results
Here, when the work is done, the sugar cube will be given to you, and you will see the temperature and humidity displayed.
The above is about "how to use Python Wechat remote intelligent temperature and humidity meter" this article content, I believe we all have a certain understanding, I hope the editor to share the content to help you, if you want to know more related knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.