# Putting computer to sleep through USB.

Status
Not open for further replies.

#### alphacat

##### New Member
Hello,
my microcontroller is connected to the PC through the USB, and they both communicating through a USB-to-UART bridge.
I'd like the MCU to put the PC into sleep (standby mode), and wanted to ask you please, how is it done?
What command should the microcontroller issue for that?

Thank you very much.

#### alphacat

##### New Member
The OS installed in my computer is Microsoft XP 2002 (Service Pack 3).
Generally, I'd like to be able to put into sleep any OS.

#### AtomSoft

##### Well-Known Member
Its as simple as picking a OS. You can have the PIC send a command to PC and in your program have it determine the OS and send the correct Sleep Instruction.

What are you using to program the PC side application?

#### blueroomelectronics

##### Well-Known Member
If it's just to shutdown then look at the UPS mode in the POWER settings. You could emulate a UPS with either RS232 or USB.

#### 3v0

##### Coop Build Coordinator
Forum Supporter
There is a load of info on the net on how you can cause XP to sleep programmaticly.

One way is to have the program on the PC run this.

rundll32.exe powrprof.dll,SetSuspendState

#### AtomSoft

##### Well-Known Member
yeah you can also from VB6:
Code:
Private Declare Function SetSuspendState Lib "Powrprof" (ByVal Hibernate As Long, ByVal ForceCritical As Long, ByVal DisableWakeEvent As Long) As Long
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@allapi.net
'start hibernating, but don't force it and don't disable all wake events
SetSuspendState 1, 0, 0
End Sub

#### alphacat

##### New Member
Thank you very much guys.
Your help is much appreciated!

Status
Not open for further replies.

Replies
3
Views
837
Replies
25
Views
3K
Replies
1
Views
1K
Replies
17
Views
7K
Replies
8
Views
10K

Loading