Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the method of Micropython development board DIY intelligent temperature control small fan?

Shulou Source: shulou.com Published: 2022-06-01 04:05:33 10月01日 Update

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!

Tags: File temperature pin method fan directory intelligence development content more knowledge disk learning wiring practical safe learned next figure above code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology NVidia Redmi Microsoft