@susu I would say that your best bet to make things easier for yourself, would be to use an D1 Mini with a relay shield mounted on top.
Total hardware cost = £3.81
The hardware needed for this project is 1 x D1 Mini, 1 x D1 Mini relay shield and a if need be 1 x DC to DC converter, is this cheap enough for you susu
???
What I would order - links below:
D1 Mini
Relay Shield
Being that the above footprint is relatively small (even with the relay shield on top), I would place the finished project securely into the PC case.
You can use MQTT via an android app of your own design to turn your PC On/Off at will. Erel has already written tutorials on how to implement MQTT into your B4X projects. Using MQTT is really easy, I personally use
CloudMQTT as my MQTT broker in my house and over the internet whilst travelling around, you can use CloudMQTT for free, but they also have a paid service.
What I would most probably do (the basics):
- Connect pin 6 to relay shield centre (common).
- Connect pin 8 to relay shield right (NC (Normally Closed)).
- Use ESP8266 (B4R) to activate the relay for 500 milliseconds to turn On your PC. You can activate the relay again for 500 milliseconds to put your computer into sleep mode and again to wake it up (dependig on your Windows power button settings).
- If your PC is already switched On, use ESP8266 (B4R) to activate the relay for 5000+ milliseconds to turn your PC Off (hard shutdown).
- You will need to have the D1 mini connected to a constant 5V power feed. You can just cheat and use an external power source like a mobile phone charger going into your computer case to run the D1 Mini 24/7.
I'm not sure if there are any constant 5V or 12V feeds in an ATX power supply/connector when the PC is switched Off (there probably isn't), but if there is you can either tap into the 5V feed or if there is a 12V feed you can drop the voltage down from 12V to 5V to power your D1 Mini by using this
DC to DC step down converter.
NOTE: To activate/de-activate the relay on the shield, you need to digital write True/False to pin 'D1' on the D1 Mini.
Sorry, I may have made it sound more complicated than it actually is
. Trust me, it's really easy to implement
As you are already an excellent B4A developer, writing the B4R code will be really easy for you to do. Once you have learned the basics on manipulating the Arduino/WeMos I/O pins, everything just falls into place. Watch some YouTube videos on what you can actually do with an Arduino/WeMos (I/O videos), that will give you some great ideas and it will get you thinking.
3V D1 Mini relay shield (sits on top of the D1 Mini)
Relay shield sitting on top of a D1 Mini (can then carefully be placed into your PC case)
Enjoy...