How do I shut down my computer with arduino uno?

So, I'm doing a project for a comp sci, and the main goal of this project is for my computer to shut down when the thermistor notices that the temperature it is reading has fallen below body temperature. I have done research, though admittedly I don't fully know how to research this, and I have found a lot of ways to control arduino through a computer with things like the command prompt, etc, but I can't seem to find anything that goes the other way. Is there a way to have arduino upload code that can open the command prompt and enter the shutdown code? Or maybe there is another way? Any help you can provide would be greatly appreciated.
Thank you.

I am afraid we need more information. What is the hardware like, what computer are you shutting down, what is the OS. Realize most computers that have an operating system simply cannot be shut down without eventually causing fatal problems. There is a shut down procedure that must be followed, this closes open files etc. You will need to design a hardware interface to read the temperature, then learn how to properly shut down the computer, then you can start coding. This is not a simple project.

I made you a basic tool that will shut down your PC when the received temperature is below the target temperature, all the Arduino needs to do is print the current temperature using Serial.println() at 115200, just poll it out every 1 second or whatever. I have tested everything except the shutdown call in the code as i do not want to shut down my PC but i am 99.9% sure the tool will work.

Oh and make sure to run it as admin else it will not be able to shut down your PC, also it will show a prompt message when its is about to shut down with 10 seconds for you to click cancel.

See file attachment below.

Release.zip (13.2 KB)

There is a "Keyboard Power" keycode for a USB keyboard but it has a footnote:
"9) Reserved for typical keyboard status or keyboard errors. Sent as a member of the keyboard array. Not a physical key."

If you have an Arduino Leonardo or Arduino Pro Micro you can give it a try:

  Keyboard.write(238);  // Or Keyboard.write(0xEE);  Both send keycode 102/0x66: "Keyboard Power"

KawasakiZx10r:
See file attachment below.

Look up the forum guidelines (sticky at top of every section). It tells you how to best form a question, what information to include, how to post a picture and how to use code tags.

Do not post a zip file as most of us won't open it.

KawasakiZx10r:
I made you a basic tool that will shut down your PC when the received temperature is below the target temperature, all the Arduino needs to do is print the current temperature using Serial.println() at 115200

First of all, thank you so much. I don’t know anything about coding and wouldn’t have even known where to start making something like this, even if it is basic. That being said, it’s not working quite right. The code is all set up and everything is wired correctly, when I open the serial monitor it reads out the temperature which it updates every two seconds. Now, I’m having trouble running both the serial monitor and your program at the same time, but I suspect that is more to do with the limits of the technology and less with your programming.
The bigger issue I’m having is that when your program runs, it doesn’t shut down the PC or give the prompt that it will. I’m almost wondering if it’s because it requires the exact shutdown temperature to be read out to trigger the sequence, which if that’s the case I can handle, but what you said about using Serial.printIn() at 115200 made me wonder if that was it. The arduino code that I’m using has several instances of the Serial.printIn() command, but those are used to print the temperature and something called the calibrated pre-exponential constant, and I’m not totally sure what you mean by using it at 115200. If you could clarify I would appreciate that a lot, I’m sorry that it took me this long to get back to you but exams have been taking priority.
Thank you.

gilshultz:
I am afraid we need more information. What is the hardware like, what computer are you shutting down, what is the OS. Realize most computers that have an operating system simply cannot be shut down without eventually causing fatal problems. There is a shut down procedure that must be followed, this closes open files etc. You will need to design a hardware interface to read the temperature, then learn how to properly shut down the computer, then you can start coding. This is not a simple project.

Sorry, I should have realized. I'm using a Lenovo Yoga running Windows 10. I'll look into how to do this safely. Thanks.

KawasakiZx10r:
I made you a basic tool that will shut down your PC when the received temperature is below the target temperature, all the Arduino needs to do is print the current temperature using Serial.println() at 115200, just poll it out every 1 second or whatever. I have tested everything except the shutdown call in the code as i do not want to shut down my PC but i am 99.9% sure the tool will work.

Oh and make sure to run it as admin else it will not be able to shut down your PC, also it will show a prompt message when its is about to shut down with 10 seconds for you to click cancel.

See file attachment below.

Hey, since my last post I've done a bit of troubleshooting and I figured it out. It is working properly. Thank you for your help, you did the hard part for me.

@KawasakiZx10r - did you forget to include the sketch - .exe isnt easy to decompile!

AFAIK an UNO can not (reasonably) function as a "pretend keyboard" to send commands via USB.

Arduinos based on the 32U4 can, and you would just issue a windows shutdown command.

To make life easier you could create a shutdown script as a shortcut, and just use the arduino to issue a command to run it.

I have a project here that uses a 32U4 (micro PRo) to run commands on a pc.

A real UNO contains a 16U4 USB interface that can function as a HID. You need to use the "DFU" functionality.

Many boards sold as "UNO"s are fakes, essentially only variants of the older Duemilanove.