Search code examples
c#raspberry-piwindows-10-iot-core

CPU temperature of Raspberry Pi in C#


I have read a lot of articles and forum posts about this topic, but almost everything is quite complicated and all from over 2+ years ago.

So I was wondering, What is the best way tot get the CPU temperature of the Raspberry Pi in C#?

I have the newest version of Windows 10 IoT Core.

Update

I dont want to reduce the CPU temperature. I am using the Sense HAT. The temperature sensor of that thing is located near the CPU so the reading is inaccurate. I have found a python script what makes the reading accurate, but it needs the CPU temperature.

NOTE:

I am using Windows 10 IoT Core! I DO NOT have this file: /sys/class/thermal/thermal_zone0/temp

Update 2:

If the only way is to write your own driver, please guide me how to do that. I don't know anything about writing drivers or anything so low-level...


Solution

  • As far as i know, there is no IoT SDK or powershell client could access to low-level BCM2836 peripherals.You need to write your own drivers. You can follow the code samples from https://github.com/ms-iot/bsp/tree/master/drivers, it's written under WDK framework so you'll need to get yourself familiar with that in order to get started.

    Another option is, measure temperature using DS18B20 thermal sensors. This thermal sensor connects the raspberry pi via I2C. And you need to install Rinsen.OneWire package via nuget in your solution, this library is written in C# and it has built-in support for DS18B20 and DS18S20 sensors.

    I'm not 100 percent sure this is the right way to go, but if someone could correct me or point out a better solution, I would be more than happy to learn from it.