Raspberry Pi CPU Temp - c#

I have a Raspberry Pi 3 running Windows 10 IoT Core. My question is; would it be possible, or is there a way to monitor the CPU temperature of the device either via a remote PowerShell connection, locally on the device in the command line console or if all else fails using a C# deployed app on the device?
I confess to being a C# noob, hence it being my third option.
Why?... I'm planning on building a custom case out of Lego for a stack of several devices and want to assess whether I need to purchase a bunch of heat sinks and cooling fans etc.
Many thanks for your time and assistance.

I hope this can guide you to the right track.
In order to access to low-level BCM2836 peripherals that the IoT SDK or PowerShell client does not provide, you'll 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.
I guess eventually you'll end up with something like one of those samples under the drivers sample.
When you're done, deploy your driver follow this tutorial https://developer.microsoft.com/en-us/windows/iot/win10/samples/driverlab3
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.

Related

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...
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.
You can achieve this using MCP9808 chip.
There is an article by Jeremy Lindsay which walks you through the process of how to make it work using C# on Window 10 IoT Core.
https://jeremylindsayni.wordpress.com/2016/06/09/how-to-measure-temperature-using-c-raspberry-pi-windows-10-iot-core-and-the-adafruit-mcp9808-sensor/
Some excerpts from the article:
How does the MCP9808 work?
This sensor uses the I2C protocol, which is supported by Windows 10 IoT Core on the Pi 3. As there’s already extensive integration of this protocol in the framework, this makes coding significantly easier. The MCP9808 can be initialised using the slave address of 0x18, and the ambient temperature can be read back from two bytes of data after writing 0x05 to the device.
Connecting the MCP9808 to the Raspberry Pi
There are 4 pins on the MCP9808 temperature sensor that we need to use to get a basic temperature reading. I connected mine to the Pi using the pins specified below.
• Supply Voltage – Pin 2
• Ground – Pin 6
• Serial Clock – Pin 5
• Serial Data – Pin 3
Jeremy has also shared the code on GitHub: https://github.com/jeremylindsayni/Magellanic.Sensors.MCP9808
Hope this help!
I think you could try to calculate the current CPU temperature by reading the current consumption and then using this formula to calculate the temperature.
I don't know how current cellphone manufacturers measure the device's temperature today. But this is not much different than how Nokia used to measure temperature based on IBATT (battery current) and VBATT (battery voltage) readings back in the day (when I worked there).

Can't SELECT and ENABLE Voice Input on PC (non build in microphone)

I have a program (written on C#) which should record some speech and analyze & do something. But the problem is that I'm using desktop PC and it has not build in mic (that's why program does not records anything). I've tested it on laptop (what has build in mic) and it is working.
So can someone help me and explain how can I get plugged in mics list and choose the right one that I need and activate it (or some other decision)? I've made a research but seems like its impossible to do on C#, So i might consider C++ dev help too.
Thanks in advance.
The low-level (Win32) functions are waveInGetNumDevs (returns number of devices) and waveInOpen (identifies sources by a number from 0 to waveInGetNumDevs()-1).
For a nicer list, use waveInGetDevCaps to query the devices.

Digital Input device to c#

The Problem:
I'm writing an application that needs to receive electrical input from a machine every time the machine does something.
I have a Limit switch set up to the machine and it currently completes a circuit every time the machine does it's thing
I need it to input into a computer using usb as oppose to just complete a circuit.
I had a dataq 'dl-148u-sp' And i got the c# code to produce a graph using ActiveX controls but all i really need is the digital output from the circuit being completed (which for the life of me i couldn't figure out how to do)..
I ended up frying the device(i think) even the software it came with doesn't recognize it anymore...
I need a new device, and it turns out they discontinued the one i had, and the next one up after shipping is like 90$.
The Question:
Is there a Better/Cheaper/Easier way of doing this? Or can anyone suggest a Good device that's easy to get the output using c# code so i can incorporate it into a program i made?
It's not clear if you are asking for a hardware or software solution here. Are you asking what the best way to facilitate that data transfer from your machine to the PC? If so, this may not be the place to ask, but you might look at a USB to GPIO module.
http://numato.com/8-channel-usb-gpio-module is an example.
I'd recommend an Arduino:
http://www.arduino.cc/playground/Main/InterfacingWithHardware
They dev kits are cheap and there's a ton of open/free libraries that interface the Arduino to C#.
More expensive and complex board is IOFirebug with c# library and many functions. Input voltage range is from 5V to 30V.

Suggestion on geoloaction and application type

I'm trying to make a program using c# that will allow me to determine where a computer of mine is located using geolocation services. I was wondering what you would suggest as far as geolocatio APis go and whether you think i should just make a background process or a windows service or if it is even possible to make it a service. I've heard of one by w3c, google, windows, and skyhook. I'm hoping to be able to determine an address from it and I was also hoping that the service would be free (even if its only for a few look-ups a day.
Thanks for the help!
I'm not really clear why you're asking about background process or Windows service. You application will not be able to get the location of the computer from services like google.
I suggest you install the Geosense driver for Windows 7 to add a Location driver (see http://geosenseforwindows.com/ ) I would then use something like the Location and Sensor interop library to query that sensor to find the rough location of the computer. (see http://archive.msdn.microsoft.com/SensorsAndLocation/Release/ProjectReleases.aspx?ReleaseId=2359)
If that's not what you we wanting to do; please provide more information.

how to make call from pc using local landline phone services

I have a desktop application of address diary, developed in C# .Net.
I want to make call from software throw land line phone service,
in my office we have 8 phone lines, so i want to select line before call,
i want to use headphone and mic in place of phone instrument.
how to connect phone lines to pc. i have more then 8 phone lines
is it possible ? if yes then how and which hardware i need for this.
Have you thought of the Skype API: http://developer.skype.com/public/skypekit
or
http://www.twilio.com
Get rid of the landlines and use a service. Much easier in my opinion. Then it would be far more scalable as well.
If you want to go down the telephony services path check out this library: https://github.com/markjulmar/atapi.net/
Hardware for landlines would just include 8 modems and selecting which one to use, before making a call.
I would assume that the atapi library contains functions to select the audio input and output. If not there are plenty of c# libraries for recording audio, in which you could pass the stream through to the library.
I wasn't going to point you down this direction but as per #Saif Khan comment you can use Asterix.
Using Asterix
Step 1 - Get a server install Asterix on it. http://www.asterisk.org. It's open source.
Step 2 - Get supported hardware e.g. http://www.asterisk.org/hardware
Step 3 - Communicate to it with http://sourceforge.net/projects/asterisk-dotnet/ (open source c# to asterisk library.
This maybe overkill for you, I don't know. I suppose I shouldn't assume :)
Since Google Voice is still free in United States and Canada. You can use this Google Voice API in C#.
http://sourceforge.net/projects/gvoicedotnet/
Doesn't want to sound like a noob, but did you try out Windows Dialer? You will need x number of 56k dialup voice modem depending on the no. of connections you have and you want to use.
It should work just fine. Test it out, and if it works well, you can get your app synced with your existing software to export the number to the dialer upon calling. (There is no such functions on the dialer app yet.)

Categories

Resources