I need to create a Monitor.Health service that receives pings on each of the client's raspberries each 5 minutes , showing tempreture of the device , is it online and other hardware info that is shows that the device is healthy.

I have tried to find libraries that work with it and so far I have managed to find this:


However, this is on Raspberry that does not has the SenseHat add-on.

Then I found out those articles:


CPU temperature of Raspberry Pi in C#

However, it is only about raspberry hosted on Windows 10 IOT, which to my knowledge is a type of windows OS hosted on the raspberry.

Can anyone point me to the right direction?

  • Windows 10 IoT is completely unsupported since March 2018. It won't boot on a 3B+ or any 4B model. Think again about how you're going to run C# on your Raspberry Pi.
    – Dougie
    Commented Sep 23, 2020 at 15:33

2 Answers 2


Sounds like you want to read cpu temp. On raspberry pi os, this is as simple as reading the contents of /sys/class/thermal/thermal_zone0/temp Whether it's C or C#, you should be able to find a way to open a "file" for read only and read in the contents. Contents are a (human readable) base 10 string. The units are milli deg C. In other words, 50123 means 50.123 deg C.

  • Yeah but I want to get stastics and info like is it online, what is the tempreture, cpu usage and all this. For each piece of information I need to read a file ? It sounds like a lot of work, I am sure they should be a library that I can use.. Commented Sep 23, 2020 at 14:23
  • 1
    It's not a "real file" in the sense of something stored on disk (or in memory) somewhere; it's a language agnostic kernel interface (sysfs). Someone somewhere probably has written a library for it in whatever language, the problem is that pretty much no one else would bother with one since (even in plain C) you can write a ~10-20 line function with appropriate parameters such that you can get values from whatever sysfs node you want in one simple call...
    – goldilocks
    Commented Sep 23, 2020 at 14:36
  • I use an app called raspi check from time to time. It's method involves opening an ssh connection and issuing several commands to get the info it needs. Neat pre-built solutions for this stuff tend to come in terminal commands rather than libraries. Executing "top -n 1" and parsing its output will likely get you the rest of what you seek.
    – Abel
    Commented Sep 23, 2020 at 14:36
  • ...There are (often undocumented and prone to depreciation) ioctl calls for some of them, but, although it is (of course) a contentious issue, in most cases there isn't any advantage to them.
    – goldilocks
    Commented Sep 23, 2020 at 14:37
  • Also, if the pi were NOT 'online', how would your tool ping it for this info? (Is this tool on the same LAN, in which case the LAN may not have internet and not be 'online') "ifconfig" will get you network adapter info, but being connected to the internet is a function of the network and not the pi. You can have the pi reach out to an internet server and grab something ("wget") to check, but failure tells you that the network could not route to the server, rather than pi specifically is 'offline'.
    – Abel
    Commented Sep 23, 2020 at 14:49

Operating system aside, I'm inclined to believe the C# code you link to is .Net Framework which does not exist in Linux. There is .net core, but a quick glance seems to suggest the API is different.

The cool thing is .net core works wonders on Raspberry Pi OS. In the last few versions, you don't even need to install anything. Just copy your executables and you're good to go.

I have used I2C very sparingly but I use GPIO and SPI extensively so I expect I2C to work just as well.

There are unfortunately a few caveats on working on the Pi; they're good material for another time. For now, try fetching some different words to google and check if it's enough.

  • 1
    I2C works fine with the dotnet/iot library.
    – PMF
    Commented Sep 23, 2020 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.