Help us understand the problem. What is going on with this article?

ESP32+MicroPythonで温湿度センサAM2320を扱う

More than 1 year has passed since last update.

結論から言うと,dhtモジュールでDHT22の1-Wireモードとして扱えば読み取れます.

接続方法

AM2320 ESP32
1: VDD 3V3
2: SDA 任意のIOピン+プルアップ(3V3と~10kΩ抵抗で接続)
3: GND GND
4: SCL GND

esp32_am2320.jpg

読み取り

>>> import machine,dht
>>> d = dht.DHT22(machine.Pin(21))
>>> d.measure()
>>> d.temperature()
24.7
>>> d.humidity()
52.4

なお,プルアップ出来ていない等で通信に失敗すると下記のようにタイムアウトエラーになります.

>>> d.measure()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "dht.py", line 16, in measure
OSError: [Errno 110] ETIMEDOUT

参考

AM2320の操作例を探していたところ,上記チュートリアルにAM2320のピン説明が載っていて,もしやと思って試したらあっさり読めました.I2Cでゴリゴリ書かなくて済んだ.

no_clock
P2P地震情報とかも作ってます.
https://www.nyamikan.net/
m3dev
インターネット、最新IT技術を活用し日本・世界の医療を改善することを目指します
https://m3.recruitment.jp/engineer/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした