Nordic Thingy:52 MCP 服务器
将您的Nordic Thingy:52转变为由AI控制的物联网强大力量
一个已准备好投入生产的模型上下文协议(MCP)服务器,能够将物理传感器数据与人工智能推理相连接。通过与Claude进行自然语言对话,控制和监控您的Nordic Thingy:52物联网设备。
 
为何选择这台MCP服务器?
- 25种综合工具完整的传感器套件、设备控制和自动化功能
- 3 MCP资源实时连接状态、传感器指南和自动化示例
- 2个智能提示快速访问传感器读数和设备控制
- 自动重连强大的连接管理功能,支持自动恢复
- 零配置开箱即用,与Claude Desktop完美兼容
- 已准备好投入生产经过实战检验,具备全面的错误处理能力
快速入门
安装
- 克隆仓库
git clone https://github.com/hemantkamalakar/nordic-thingy52-mcp.git
cd nordic-thingy52-mcp- 安装依赖项
uv pip install -r requirements.txt或者使用 pip:
pip install -r requirements.txt- 配置Claude桌面版
在您的Claude Desktop配置文件中添加:
MacOS(麦金塔操作系统): ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"thingy52": {
"command": "uv",
"args": [
"--directory",
"/Users/hemantkamalakar/Hemant/Research/Thingy52MCPServer",
"run",
"python",
"run_server.py"
]
}
}
}注将目录路径替换为您实际的安装路径。请使用绝对路径,而非相对路径。
- 重启Claude桌面版
- 开始探索吧!
"Find my Thingy device and show me all available sensors"设备功能
环境传感器
- 温度-40°C至85°C的精确监测
- 湿度0-100%相对湿度,用于舒适度追踪
- 压力260-1260百帕的气压读数
- 空气质量二氧化碳(400-8192 ppm)和总挥发性有机化合物(0-1187 ppb)
- 光与色RGB + 清晰通道环境光感应
高级动作追踪
- 9轴融合加速度计 + 陀螺仪 + 磁力计
- 四元数三维方向的旋转表示
- 欧拉角滚转、俯仰、偏航计算
- 标题磁罗盘方向(0-360°)
- 计步器活动与运动检测
- 点击事件物理交互检测
设备控制
- RGB LED灯1670万种颜色,支持3种模式(常亮、呼吸、单次闪烁)
- 扬声器8个预设声音样本
- 电池监测器实时功率水平跟踪
- 自动重连无缝连接恢复
25款MCP工具
设备管理(4种工具)
scan_devices()- 发现附近的Thingy:52设备connect_device(address)- 连接到特定设备disconnect_device()- 优雅地断开连接get_device_status()- 连接状态和电池状态configure_auto_reconnect(enabled, max_attempts)- 配置重新连接
环境传感器(8种工具)
read_temperature()- 当前温度(摄氏度)read_humidity()- 相对湿度百分比read_pressure()- 气压(以百帕为单位)read_air_quality()- 二氧化碳(CO2)和总挥发性有机化合物(TVOC)浓度read_color_sensor()- RGBC颜色值read_light_intensity()- 环境光照度(勒克斯)read_all_sensors()- 完整的环境快照configure_sensor_intervals()- 调整采样率
运动与方向(6种工具)
read_quaternion()- 三维方向四元数read_euler_angles()- 滚转角、俯仰角、偏航角read_heading()- 方位角(0-360°)read_orientation()- 人类可读的方向read_raw_motion()- 原始加速度计/陀螺仪/磁力计数据read_step_count()- 活动追踪
设备控制(4种工具)
set_led_color(color, intensity)- 单色LEDset_led_breathe(color, intensity, delay)- 呼吸效果turn_off_led()- 关闭LED灯play_sound(sound_id)- 播放预设声音(1-8)beep()- 快速通知铃声
电池(1件工具)
read_battery()- 电池电量百分比
MCP Resources(公司名,可译为“MCP资源公司”或根据具体语境保留原名)
1. 连接状态(thingy://status)
实时连接信息,包括设备地址、电池电量、自动重连状态和连接状态。
2. 传感器指南(thingy://sensors/guide)
全面参考指南,涵盖所有可用传感器的功能、范围及使用案例。
3. 自动化示例(thingy://automation/examples)
预构建的自动化场景和工作流模板。
MCP 提示/指令
1. 快速传感器检查
一键访问,读取所有环境传感器数据,并以格式化输出。
2. 设备控制面板
带视觉反馈的LED与声音交互控制界面。
高级用法示例
智能家居环境监测
场景;情景监控房间舒适度,条件不佳时自动发出警报
"Monitor the temperature and humidity every 30 seconds. If temperature exceeds 26°C
or humidity goes above 65%, set the LED to orange and notify me. If CO2 exceeds
1000 ppm, make it red and play sound 3."会议室占用检测
场景;情景检测会议室是否被占用并追踪空气质量
"Read the step counter and motion data. If motion is detected and CO2 is rising,
the room is likely occupied. Track CO2 levels and alert me if it exceeds 1200 ppm
(indicating poor ventilation). Flash the LED yellow as a warning."3D方向追踪
情景;场景;剧本将该设备用作动作控制器或倾斜传感器
"Read the quaternion and euler angles. Tell me the current 3D orientation.
If the device is tilted more than 45 degrees from level, change LED to red.
If it's level, make it green."植物健康监测器
情景;场景监测环境条件以促进植物最佳生长
"Create a plant health monitoring system:
1. Read temperature (ideal: 18-24°C)
2. Read humidity (ideal: 40-60%)
3. Read light intensity (needs >500 lux)
4. If all conditions are good: green LED
5. If any condition is poor: yellow LED + beep
6. If multiple conditions are bad: red LED + sound 5"空气质量预警系统
场景;情景实时空气质量监测,配备多级预警
"Monitor air quality continuously:
- CO2 1500 ppm: Red LED breathe + sound 3 (poor - ventilate!)
Also track TVOC and alert if it exceeds 500 ppb"感应式夜灯
场景检测移动并提供临时照明
"Use tap detection and motion sensors. When a tap is detected:
1. Read the light intensity
2. If it's dark (3 hPa drop): Red LED - storm approaching
- Slowly falling: Yellow LED - weather may worsen
- Rising pressure: Green LED - improving weather
- Stable: Blue LED - weather steady
Also display current temperature and humidity"桌面姿势提醒器
情景;场景利用方向检测驼背或不良姿势
"Mount the Thingy on my monitor. Read the euler angles every minute:
- If pitch angle changes by more than 15° from the baseline, I might be slouching
- Flash yellow LED and play sound 1 as a gentle reminder
- After 2 hours, play sound 4 as a break reminder regardless of posture
Track total sitting time using the step counter"智能实验室孵化器监控器
场景;情景为科学应用提供精准的环境控制
"Monitor incubator conditions:
1. Read temperature (target: 37°C ± 0.5°C)
2. Read humidity (target: 80-90%)
3. Read CO2 (5% CO2 environment = ~50000 ppm)
4. If any parameter is out of range:
- Red LED breathe
- Play sound 8 (urgent alert)
- Report exact values and deviation
5. If all parameters stable: slow green breathe
Log readings every 2 minutes"包裹配送检测
场景;情境检测包裹是否被放置在门附近
"Use as a package detector:
1. Monitor light sensor (package blocks light)
2. Detect tap/impact when package is set down
3. Check orientation change if package knocks device
4. When delivery detected:
- Play sound 6 (delivery notification)
- Flash green LED 3 times
- Report: 'Package delivered at [time]'
5. Send me the light level change and tap strength"自然语言指令示例
设备发现与连接
"Scan for Thingy devices nearby"
"Connect to the Thingy with the strongest signal"
"What's the battery level of my Thingy?"
"Enable auto-reconnect with 5 retry attempts"环境监测
"What's the current temperature and humidity?"
"Read all environmental sensors and format as a table"
"Is the air quality good in this room?"
"How bright is it right now? Give me the light intensity"
"What color is the ambient light? Read the RGB sensor"运动与方向
"What direction is the device pointing? Give me the compass heading"
"Tell me the 3D orientation as euler angles"
"Is the device moving? Check the accelerometer"
"How many steps have been counted today?"
"Read the quaternion for 3D orientation tracking"LED控制
"Set the LED to warm white at 70% brightness"
"Make the LED breathe slowly in blue"
"Create a gentle red pulse effect with 2 second interval"
"Turn off the LED"
"Flash purple 5 times to signal completion"音效
"Play sound pattern 3"
"Make a beep to confirm the action"
"Play all 8 sounds in sequence so I can hear them"复杂的工作流程
"Create a focus mode: Set LED to cool white at 40%, then monitor CO2.
If it exceeds 1000 ppm, remind me to open a window with sound 2"
"Build a temperature alarm: If temp goes above 28°C, flash red LED
and play sound 8. If it drops below 18°C, flash blue and play sound 4"
"Make a presence detector: Use motion, step counter, and CO2 to determine
if someone is in the room. Adjust LED color based on occupancy status"项目结构
nordic-thingy52-mcp/
├── README.md # This file
├── PROMPT_GUIDE.md # Advanced automation examples
├── requirements.txt # Python dependencies
├── pyproject.toml # Project configuration
├── run_server.py # MCP server entry point
├── test_mcp_tools.py # Comprehensive test suite
└── src/
├── __init__.py
├── bluetooth_client.py # BLE communication layer
├── server.py # MCP server (25 tools, 3 resources, 2 prompts)
├── models.py # Data models for sensor readings
└── constants.py # BLE UUIDs and device constants测试
运行全面的测试套件以验证所有25个工具:
python test_mcp_tools.py这将测试:
- 设备发现与连接
- 所有环境传感器
- 运动和方向传感器
- LED控制(常亮、呼吸灯、关闭)
- 声音播放
- 自动重连功能
- 电池监控
故障排除
未找到设备
- 确保Thingy:52已开机(按下按钮,LED灯应闪烁)
- 检查您的电脑上是否已开启蓝牙
- 将设备移近(蓝牙低功耗范围约10米)
- 尝试
scan_devices()具有更长的超时时间
连接失败
- 一次仅连接一个设备(如已运行,请关闭Nordic Thingy应用)
- 重置设备:按住按钮10秒,直到LED灯熄灭
- 检查电池电量(若电量低于20%,请充电)
- 在您的电脑上重新启动蓝牙
传感器返回空值
- 连接后等待2-3秒,让传感器初始化
- 有些传感器需要先进行配置(使用
configure_sensor_intervals()) - 检查设备是否未处于睡眠模式(轻触或按下按钮)
LED灯不更换
- 呼吸模式可能需要一些时间才能开始生效
- 先尝试关闭LED灯,然后设置新模式
- 检查是否有其他应用程序正在控制LED
MCP服务器未出现在Claude中
- 验证配置文件路径是否为绝对路径,而非相对路径
- 检查JSON语法(常见错误:缺少逗号)
- 完全重启Claude桌面版
- 查看Claude日志以排查MCP服务器错误
技术细节
BLE(蓝牙低功耗)实现
- 图书馆Bleak(支持跨平台的蓝牙低功耗技术)
- 协议蓝牙低能耗5.0
- 服务5项GATT服务(环境、运动、用户界面、声音、电池)
- 特点25+个BLE特性
- 连接用于提升性能的异步/等待(Async/Await)模式
传感器规格
- 温度BME280传感器,±0.5°C精度
- 湿度BME280传感器,湿度精度±3%
- 压力BME280传感器,±1百帕精度
- 空气质量CCS811传感器(eCO2和TVOC)
- 动作;运动MPU-9250 9轴惯性测量单元(IMU)
- 颜色BH1745 RGB传感器
- 光BH1745环境光传感器
演出
- 扫描时间设备发现时间为5-10秒
- 连接2-3秒,这是典型情况
- 传感器读数每次读取需50-200毫秒
- 重新连接自动重试,采用指数退避策略
- 电池续航时间3-7天为典型周期(视使用情况而定)
贡献
欢迎贡献!需要改进的方面:
- 固件更新OTA固件更新支持
- 数据记录历史传感器数据存储
- 警报;提醒条件满足时发送电子邮件/短信通知
- 多设备支持多个Thingy设备
- 自定义声音上传自定义音频样本
- 校准传感器校准程序
许可证
MIT 许可证 - 详见 许可证 详情请见。
资源
- Nordic Thingy:52 官方页面
- Thingy:52 硬件文档
- 模型上下文协议文档
- “Bleak Documentation”可以翻译为“寒酸的文档”或“简陋的文档”,具体取决于语境和想要传达的细微差别。在这里,“Bleak”通常用来形容某种状态或情况的凄凉、贫乏或不足,所以“寒酸的”或“简陋的”都能较好地传达出原文的含义
致谢
构建于:
作者
赫曼特·卡马拉卡尔
- 电子邮箱:hemant.kamalakar@gmail.com
- GitHub: @hemantkamalakar(这个用户名或标签在中文中通常保持不变,直接音译或保留原样,表示在社交媒体或论坛上关注或提及的用户)
______________________________________________________________________
专为物联网(IoT)和人工智能(AI)社区打造
将您的传统物联网设备升级为AI驱动的自动化节点!
