当前位置:网站首页>Detailed tutorial on the use of smoke sensor (mq-2) (based on raspberry pie 3B +)
Detailed tutorial on the use of smoke sensor (mq-2) (based on raspberry pie 3B +)
2022-04-23 14:04:00 【one billion twenty-nine million one hundred and seventy-nine th】
Experience :
Most of the Internet is about mq-2 Code for , The realized function judges whether there is smoke value , The specific smoke value cannot be read . Because raspberry pie can't read analog signals directly A0 value , So we have to help PCF8591( Read the smoke value adc) Read , This PCF8591 Quite critical , You have to use .
Hardware preparation :
Raspberry pie 3b+、mq-2、PCF8591( Read the smoke value adc) DuPont line
PCF8591 Here's the picture :
Physical connection :
PCF8591 Connect with raspberry pie :
mq-2 With raspberry pie and PCF8591 Connect
mq-2 PCF8591 Raspberry pie
vcc------------------------3.3v
gnd-----------------------gnd
AOUT–A0
Key connections are shown in the figure :
Set raspberry pie :
open I2C Interface
Open the raspberry pie terminal , Enter the following command to enter the configuration interface
sudo raspi-config
choice Interfacing Options -> I2C ->yes start-up i2C Kernel driver
Code up :
import time
from smbus import SMBus
address = 0x48
MODE0 = 0x00 #Channel0 = AIN0
#Channel1 = AIN1
#Channel2 = AIN2
#Channel3 = AIN3
MODE1 = 0x10 #Channel0 = AIN3-AIN0
#Channel1 = AIN3-AIN1
#Channel2 = AIN3-AIN2
MODE2 = 0x20 #Channel0 = AIN0
#Channel1 = AIN1
#Channel2 = AIN3-AIN2
MODE3 = 0x30 #Channel0 = AIN1-AIN0
#Channel1 = AIN3-AIN2
CHNL0 = 0x40 #Using Channel0
CHNL1 = 0x41 #Using Channel1
CHNL2 = 0x42 #Using Channel2
CHNL3 = 0x43 #Using Channel3
DAouputEn = 0x40
PCF8591 = SMBus(1)
while True:
value0 = PCF8591.read_byte(address)
PCF8591.write_byte(address, CHNL0)
time.sleep(2)
Running results
The concrete effect and specific information can be viewed at WeChat official account. :
版权声明
本文为[one billion twenty-nine million one hundred and seventy-nine th]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231401297935.html
边栏推荐
猜你喜欢
visio安装报错 1:1935 2:{XXXXXXXX...
Ptorch classical convolutional neural network lenet
Autumn recruitment in 2021, salary ranking No
Nifi 快速安装及文件同步操作
基于微信小程序的wifi模块使用
Choreographer全解析
PATH环境变量
Prediction of tomorrow's trading limit of Low Frequency Quantization
微信小程序获取登录用户信息、openid和access_token
RobotFramework 之 项目框架
随机推荐
Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
初识go语言
crontab定时任务输出产生大量邮件耗尽文件系统inode问题处理
Quartus prime hardware experimental development (de2-115 board) experiment 1 CPU instruction calculator design
生产环境——
websocket
groutine
Go语言 RPC通讯
烟雾传感器(mq-2)使用详细教程(基于树莓派3b+实现)
DDT+Excel进行接口测试
记录一个奇怪的bug:缓存组件跳转之后出现组件复制
go 语言 数组,字符串,切片
基于ibeacons签到系统
腾讯根据ip解析地址
生成随机高质量符合高斯分布的随机数
Restful WebService和gSoap WebService的本质区别
趣谈网络协议
Program compilation and debugging learning record
PATH环境变量
微信小程序与低功耗蓝牙通信-往硬件端发送数据(三)