当前位置:网站首页>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
边栏推荐
- 基于ibeacons签到系统
- CentOS mysql多实例部署
- go 语言 数组,字符串,切片
- Elmo (bilstm-crf + Elmo) (conll-2003 named entity recognition NER)
- Prediction of tomorrow's trading limit of Low Frequency Quantization
- 关于pthread多线程一些好文章
- Oracle告警日志alert.log和跟踪trace文件中文乱码显示
- Program compilation and debugging learning record
- RobotFramework 之 项目框架
- 程序编译调试学习记录
猜你喜欢

CDH cluster integration Phoenix based on CM management

freeCodeCamp----time_ Calculator exercise
Check in system based on ibeacons

Call wechat customer service applet

scikit-learn构建模型的万能模板

Choreographer全解析

Oracle告警日志alert.log和跟踪trace文件中文乱码显示

室内外地图切换(室内基于ibeacons三点定位)

Neuron and neural network

Crontab timing task output generates a large number of mail and runs out of file system inode problem processing
随机推荐
Kettle -- control parsing
smart-doc + torna生成接口文档
Record a strange bug: component copy after cache component jump
Oracle告警日志alert.log和跟踪trace文件中文乱码显示
力扣刷题 101. 对称二叉树
Introduction to spark basic operation
1256:献给阿尔吉侬的花束
CDH cluster integration Phoenix based on CM management
Android篇:2019初中级Android开发社招面试解答(中
Call wechat customer service applet
金蝶云星空API调用实践
SQL: How to parse Microsoft Transact-SQL Statements in C# and to match the column aliases of a view
Windos中安装labellmg教程
AtCoder Beginner Contest 248C Dice Sum (生成函数)
log4j 输出日志信息到文件中
Choreographer全解析
linux安装mysql后修改密码
RobotFramework 之 用例标签机制
nodejs通过require读取本地json文件出现Unexpected token / in JSON at position
STM32学习记录0007——新建工程(基于寄存器版)