Read temperature with MAX31855 Thermocouple Sensor on Windows IoT

2024/10/13 22:21:11

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?

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?

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

Answer

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

  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.

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

  4. Replace

    import Adafruit_GPIO as GPIO with import _wingpio as gpio

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

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

  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.

https://en.xdnf.cn/q/118030.html

Related Q&A

PIP: How to Cascade Requirements Files and Use Private Indexes? [duplicate]

This question already has an answer here:Installing Packages from Multiple Servers from One or More Requirements File(1 answer)Closed 9 years ago.I am trying to deploy a Django app to Heroku where one …

Python error: TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]

Below is a small sample of my dataframe. In [10]: dfOut[10]:TXN_KEY Send_Agent Pay_Agent Send_Amount Pay_Amount 0 13272184 AWD120279 AEU002152 85.99 85.04 1 13272947 ARA03012…

How to remove grey boundary lines in a map when plotting a netcdf using imshow in matplotlib?

Is it possible to remove the grey boundary lines around the in following map? I am trying to plotting a netcdf using matplotlib.from netCDF4 import Dataset # clarify use of Dataset import matplotlib.p…

function that takes one column value and returns another column value

Apologies, if this is a duplicate please let me know, Ill gladly delete.My dataset: Index Col 1 Col 20 1 4, 5, 6 1 2 7, 8, 9 2 3 10, 11, 12 3 …

Python write value from dictionary based on match in range of columns

From my df showing employees with multiple levels of managers (see prior question here), I want to map rows to a department ID, based on a manager ID that may appear across multiple columns:eid, mid…

Merge two dataframes based on a column

I want to compare name column in two dataframes df1 and df2 , output the matching rows from dataframe df1 and store the result in new dataframe df3. How do i do this in Pandas ? df1place name qty unit…

Python/Pandas - building a new column based in columns comparison

I have this dataframe:df:CNPJ Revenues 2016 Revenues 2015 Revenues 2014 0 01.637.895/0001-32 R$ 12.696.658 NaN R$ 10.848.213 1 02.916.265/0001-60 …

Present blank screen, wait for key press -- how?

lo,I am currently trying to code a simple routine for an experiment we are planning to run. The experiment starts by entering a subject number and creating a bunch of files. I got that part working. Ne…

Images appearing in all but 1 flask page

I am creating a web app in flask, python, mysql. When viewing every other page on my website my images load, but when viewing one specific page, I cant get any images to load using already working code…

Python: Write nested list objects to csv file

Im trying to write data from a list of lists to a csv file. This is a simplified version of what I haveclass Point(object): def __init__(self, weight, height):self.weight = weightself.height = heightde…