ESP32连接DHT11获取温湿度数据,显示在OLED屏幕上,通过中间层将数据上传到mysql数据库并且通过网页显示出来
部署方式:
1、刷入micropython固件
2、安装库文件:(使用Thonny进行开发)
点击 工具——>管理包,搜索安装如下库
3、将代码保存为main.py到ESP32,这样ESP32上电以后会自动运行
1、安装库文件
pip install request
pip install flask
pip install pymysql
pip install flask_cors
pip install jsonify
pip install logging
2、分别启动两个中间层(一个用来处理ESP32的请求,上传数据到数据库,另一个接受网页的请求,从数据库中读取数据,并且返回json给网页)
请一定一定确保两个中间层的端口不要冲突
1、安装基础web服务
sudo apt-get update
sudo apt-get install apache2
2、上传网页到服务器的/var/www/html文件夹下,并且命名为index.html
create table temp_moisture
(
id int auto_increment
primary key,
time varchar(64) not null,
temp double not null,
moisture double not null
);