在 Windows IoT 上使用 MAX31855 热电偶传感器读取温度 [英] Read temperature with MAX31855 Thermocouple Sensor on Windows IoT

查看:24
本文介绍了在 Windows IoT 上使用 MAX31855 热电偶传感器读取温度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Windows IoT 开发 Raspberry Pi 2.我想将 Raspberry Pi 与 MAX31855 热电偶传感器连接起来,我在 Adafruit 上买的.GitHub 上有一个 Python 库,可用于从传感器读取当前温度.不幸的是,我无法让这个库在我的 Pi 上工作,因为我不知道如何在我的 Pi 上安装必备的 RPi.GPIO 和 Adafruit_Python_MAX31855 库.我不确定它是否完全适用于 Windows IoT 上的 Python.有人可以确认吗?

I am working on a Raspberry Pi 2 with Windows IoT. I want to connect the Raspberry Pi with a MAX31855 Thermocouple Sensor which I bought on Adafruit. There's a Python libary available on GitHub to read the current temperature from the sensor. Unfortunately, I am not able to get this libary to work on my Pi because I have no idea how to install the prerequisite RPi.GPIO and the Adafruit_Python_MAX31855 libary on my Pi. I am not sure if it is working at all with Python on Windows IoT. Can somebody confirm this?

我发现了从外部获取SPI温度数据的线程StackOverflow 上的 class 这似乎是我想要做的.首先,当我将热电偶与 Pi 连接时,是否需要使用 软件SPI还是硬件SPI?在 Windows IoT 上工作时是否有重要区别?

I've found the thread Getting SPI temperature data from outside of class on StackOverflow which seems to be what I want to do. First, when I connect my Thermocouple with my Pi, do I need to use Software SPI or Hardware SPI? Is there a important difference when working on Windows IoT?

GitHub 上还有一个 C++ 库.是否可以在我的 C# 项目中调用此库中的方法?

There's also a C++ libary on GitHub. Is it possible to call the methods from this libary within my C# project?

推荐答案

在带有 windows IoT 核心的 raspberry pi 上使用该 python 驱动程序之前,您需要做一些移植工作,

You'll need to do some porting work before using that python driver on raspberry pi with windows IoT core,

  1. 遵循此示例 https://developer.microsoft.com/en-us/windows/iot/win10/samples/pythonblinky 开始在 Windows IoT 上进行 Python 编程.
  2. 参见 https://github.com/adafruit/Adafruit_Python_GPIO 的 Platform.py,它用于板版本检测和多板支持.将其添加到您的项目中,您可以对其进行硬编码以仅支持 raspberry pi.

  1. Follow this sample https://developer.microsoft.com/en-us/windows/iot/win10/samples/pythonblinky to get started with python programming on windows IoT.
  2. See to Platform.py from https://github.com/adafruit/Adafruit_Python_GPIO , it is intended for board version detect and multiple board support. Add it to your project, you can hard-code it to only support raspberry pi.

将 MAX31855.py 添加到您的项目中,从 https://github.com/adafruit/Adafruit_Python_MAX31855/blob/master/Adafruit_MAX31855/MAX31855.py

Add MAX31855.py to your project, copy the code from https://github.com/adafruit/Adafruit_Python_MAX31855/blob/master/Adafruit_MAX31855/MAX31855.py

替换

将 Adafruit_GPIO 导入为 GPIOwith import _wingpio as gpio

and import Adafruit_GPIO.SPI as SPI with import _winspi as SPI

此外,将每个 api 调用替换为 PyWinDevices 库中的一个.

Also, replace every api calls with one from PyWinDevices library.

  1. 取决于您使用的是软件 SPI 还是硬件 SPI接线,您可能需要从 https://github 移植 SPI.py 驱动程序.com/adafruit/Adafruit_Python_GPIO/blob/master/Adafruit_GPIO/SPI.py.SetBang api 是 sw/hw spi 控制器的软件包装器,您可以按照示例轻松编写自己的.
  1. depending if you're using the Software SPI or Hardware SPI wiring, you may need to port SPI.py driver from https://github.com/adafruit/Adafruit_Python_GPIO/blob/master/Adafruit_GPIO/SPI.py. That SetBang api is the software wrapper for sw/hw spi controller, you can easily write your own following the example.

完成所有驱动程序移植后,您应该很高兴.

You shall be good to go after all the driver porting.

这篇关于在 Windows IoT 上使用 MAX31855 热电偶传感器读取温度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆