首页 动态 版块 商城 我的
 退出
游客  
等级:
金币:
经验值:

GY-906非接触式红外测温传感器Python/C++编程 树莓派与ESP32使用例程

  2973 
 5
趣    
文章主图

一:GY906红外测温传感器介绍

1.传感器参数

 GY906红外测温传感器是一种基于红外辐射原理的非接触式温度测量设备,常用于测量物体表面温度,由于 GY906红外测温传感器无需直接接触物体,避免污染或损坏,还有它的高精度和快速响应的特点,广泛应用于多个领域。最直接的应用产品就是医疗测温仪!我们在使用时需注意环境因素和校准。


测温范围:通常为-70°C至+380°C

工作电压:3-5.5V

测量距离:(BAA-2CMBCC-10cm)DCI-1m)

高精准度:精度可达±0.5°C,适合高精度需求

快速响应:响应时间短,适合动态温度监测

数字输出:通过I2C接口输出数字信号,便于与微控制器连接

体积小巧:便于集成到各种设备中

2.电路原理图

GY906传感器原理图
 🛒GY906传感器产品购买链接


GY906传感器不同型号,测量距离不同


Image

二:树莓派例程

1.Pico接线图

以树莓派Pico开发板为例,提醒: 请按下图的引脚标识接线,务必不能接错。如果接错线通电后会导致设备烧毁!

Image

接好线后实图如下:

Image

2.Python程序

gy906 下载这个gy906的源代码上传至树莓派pico文件内,直接运行查看数据(如下图

如果你还没有搭建好树莓派Python编程环境可参考这个帖子→:如何搭建Python编程环境


Image


将传感器探头对着手,测试检测温度

Image

三:ESP32例程

1.ESP32接线图

本次以ESP32-S3主板为例按下图接好连接线,务必注意不可接反,否则会烧毁传感器。

Image


2.C++程序

1.需要在Arduino IDE中点击左侧栏的 库管理器(Library Manager)(或按 Ctrl + Shift + I),搜索并安装下面这个库:

Adafruit MLX90614

gy906 下载这个gy906源代码直接用Arduino IDE编译上传程序打开串口监视查看(如下图)

如果你还没有搭建好ESP32的ArduinoIDE的编程环境可参考这个帖子→:搭建ArduinoIDE编程环境

Image

Image

3.代码解析

这段 ESP32 读取 GY-906(MLX90614)的代码运行逻辑可以拆解为以下三个核心步骤:


1.驱动与引脚重映射


引入 Wire.h(I2C通信库)和 Adafruit_MLX90614.h(红外传感器驱动)。


将默认的 I2C 引脚重定向定义为 SDA = GPIO 4,SCL = GPIO 18。


2.初始化检测(setup)


串口初始化:开启 115200 波特率串口,用于向电脑输出数据。


I2C 总线挂载:执行 Wire.begin(4, 18),告诉 ESP32 从 GPIO 4 和 18 引脚建立 I2C 通信。


传感器握手:执行 mlx.begin() 检测 0x5A 地址上的 GY-906。若连接失败则进入死循环挂起,防止后续读取异常数据。


3.数据采集与输出(loop)


读取环境温度:调用 mlx.readAmbientTempC(),获取传感器自身周围的空气温度。


读取目标温度:调用 mlx.readObjectTempC(),通过红外探测获取前方物体的表面温度。


打印与延时:将数据格式化后发送至串口监视器,并通过 delay(1000) 实现每秒刷新一次数据。


技术支持(对本页存在疑难问题可联系我们工程师)

联系人:张工
电话:0755-32914578
QQ:2251000002
微信:扫下方二维码添加,请备注来意

提供:人工智能,IOT物联网,工控数显,嵌入式软硬件开发,科创教育,产品定制,生产,方案解决...

作者签名:    楼主  2025-06-25 17:47:36
回复列表
游客
6F
游客
2026-05-10 23:33:39 0
Hey, You don’t need ads to make this work. With the right funnel, a product like O2 Cool Mist can convert directly from your existing traffic. Think: Landing → Soft hook → Problem → Quick solution → Sale No complicated setup. If you’re open, I can send you a ready-to-use structure you can copy. click Here for more : https://sites.google.com/view/openclawmastered/home?authuser=3
共0条回复,点击查看回复
【评论】   
游客
5F
游客
2026-03-24 21:41:21 0
Turn any idea into content, videos, and marketing campaigns in seconds No experience needed, no hard work One tool replaces an entire team Start now and get ahead of everyone else! For more : https://jvz4.com/c/688203/431725/
共0条回复,点击查看回复
【评论】   
游客
4F
游客
2026-03-23 15:53:38 0
Hello Raspi Cc Owner, My name is Eric and I’m betting you’d like your website Raspi Cc to generate more leads. Here’s how: Web Visitors Into Leads is a software widget that works on your site, ready to capture any visitor’s Name, Email address, and Phone Number. It signals you as soon as they say they’re interested – so that you can talk to that lead while they’re still there at Raspi Cc. Visit https://blastleadgeneration.com to try out a Live Demo with Web Visitors Into Leads now to see exactly how it works and even give it a try… it could be huge for your business. Plus, now that you’ve got their phone number, with our new SMS Text With Lead feature, you can automatically start a text (SMS) conversation quickly… which is so powerful because connecting with someone within the first 5 minutes is 100 times more effective than waiting 30 minutes or more later. The new text messaging feature lets you follow up regularly with new offers, content links, even just how are you doing? notes to build a relationship. Everything I’ve just described is extremely simple to implement, cost-effective, and profitable. Visit https://blastleadgeneration.com to discover what Web Visitors Into Leads can do for your business, potentially converting up to 100 times more eyeballs into leads today! Eric PS: Studies show that 70% of a site’s visitors disappear and are gone forever after just a moment. Don’t keep losing them. Web Visitors Into Leads offers a complimentary 14-day trial – and it even includes International Long Distance Calling. You have customers waiting to talk with you right now… don’t keep them waiting. Visit https://blastleadgeneration.com to try Web Visitors Into Leads now. If you'd like to Want to receive fewer emails, or none whatsoever? Update your email preferences by visiting https://blastleadgeneration.com/unsubscribe.aspx?d=raspi.cc
共0条回复,点击查看回复
【评论】   
游客
3F
游客
2026-03-16 03:17:15 0
Hi, I was looking at your website and noticed something interesting. Most businesses are losing potential customers because they are not actively managing their online reviews. Reviews can significantly increase trust and conversions when handled properly. I recently found a tool that automatically collects, manages, and improves online reviews for businesses. You can see how it works here: https://jvz3.com/c/688203/434579/ It’s surprisingly simple and can make a big difference in attracting new customers.
共0条回复,点击查看回复
【评论】   
游客
2F
游客
2026-03-04 09:09:49 0
Most people don’t fail online because they lack opportunity. They fail because the thinking overwhelms them. What should I build? How do I structure it? What comes next? That mental weight is what kills momentum. ClawMate was built to remove that layer completely. It’s not another chatbot waiting for prompts. Click here for more : https://jvz4.com/c/688203/433889/
共0条回复,点击查看回复
【评论】   
Powered by YDXHUO _VERSION
© 2017-2026 跃动芯火版权
您的IP: 216.73.216.115 , 2026-08-21 23:24:33
Powered by YDXHUO _VERSION
© 2017-2026 跃动芯火版权
(13) 分享
分享

请保存二维码或复制链接进行分享

取消
免责声明
1、本站资源,均来自网络与个人作者,所有资源和文章仅限用于学习和研究目的 。
2、不得用于商业或非法用途,否则,一切责任由该用户承担 !

侵权删除请致信 E-Mail:ydxho@qq.com
已有0次打赏