In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what is the method of Micropython development board DIY intelligent temperature control small fan". In the operation of the actual case, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Learn the wiring method of DS18B20 and detect the current temperature
First, take a look at the meaning of DS18B20 pins, as shown in the figure above:
The corresponding relationship between the pins of TPYBoard and those of DS18B20 is as follows:
TPYBoard DS18B20
-
# 3V3 or any Pin = > VDD
# any Pin = > DO
# GND = > GND
If you still don't understand, just put the pin number on it.
TPYBoard DS18B20
-
3.3v = > VDD
GND = > GND
Y10 = > DO
After connecting to ok, in the source directory of MicroPython, go to the drivers\ onewire\ directory, and then copy the files ds18x20.py and onewire.py in the directory to the root directory of the PYBFLASH disk. Copy the file to safely exit the disk, and then re-access, otherwise can not find the file, you can run the main.py file, print temperature, you can use Putty to see the current temperature.
Main.py source code:
# main.pyimport pybfrom pyb import Pinfrom ds18x20 import DS18X20 Pin ("Y11", Pin.OUT_PP). Low () # GNDPin ("Y9", Pin.OUT_PP). High () # VCCpyb.delay (100) DQ=DS18X20 (Pin ('Y10')) # DQwhile True: tem = DQ.read_temp () print (tem) pyb.delay (1000)
After we follow the above steps, then turn on the power and write the main.py file, we can control the rotation of the fan through the temperature. The specific code is as follows:
# main.pyimport pybfrom pyb import Pinfrom ds18x20 import DS18X20 Pin ("Y9", Pin.OUT_PP). High () # VCCPin ("Y11", Pin.OUT_PP). Low () # GNDx1 = Pin ('X1' Pin.OUT_PP) pyb.delay (100) DQ=DS18X20 (Pin ('Y10')) # DQwhile 1: tem = DQ.read_temp () if tem > 18: x1.value (1) else: x1.value (0) "what is the method of Micropython development board DIY intelligent temperature control small fan" is introduced here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.