ESP32读取甲醛传感器数据
本文提供了基于ESP32开发板快速完成甲醛传感器数据读取的方式,可以用于开发甲醛检测仪。
准备
- 传感器:达特WZ-S甲醛传感器
- 开发板:安信可ESP32 NodeMCU-32S
- 开发环境:Arduino
- 依赖库: WZ (https://github.com/leonlucc/WZ)
引脚连接
ESP32 | WZ-S |
---|---|
5V | 5V |
GND | GND |
GPIO17 | RXD |
GPIO16 | TXD |
代码
主动模式读数
#include "WZ.h"
/// ESP32-S NodeMCU Board
/*
* There are three serial ports on the ESP32 known as UART0, UART1 and UART2.
*
* UART0 (GPIO1 - TX0, GPIO3 - RX0) is used to communicate with the ESP32 for programming and during reset/boot.
* UART1 (GPIO10 - TX1, GPIO9 - RX1) is unused and can be used for your projects. Some boards use this port for SPI Flash access th