I played Assassin’s Creed Odyssey and again freaked out how the PC is getting hot! I have Windows exclusively for games, so I decided to turn on additional fans there, via Arduino, and in Ubuntu, where I enjoy “silence”, I will automatically turn them off! I will communicate with Arduino through the Serila port!
We need the following equipment:
1. A 9 pin USB to micro USB cable – I had it, from Thermaltake Riing Trio 12 – I used it in the circuit with Arduino at first, as there are two micro USB on this cable, but the Thermaltake controller stops working if on the same USB is Arduino! And tehre is no 80mm fans for that controller …
2. Arduino with micro USB and 5V pin. The original Arduino Nano would work, but I didn’t have it, I had thatRobotDyn UNO R3 CH340G (R3-ATmega328/CH340G)
3. Double relay like this Relay Module 2 relays, 5V
4. Case for Arduino
5. Molex adapter for 4 fan connectors (2x5V 2x12V). I had an old Zalman ZM-MC 1, I had to cut the fan connectors to fit the PWM connectors
6. Cable Molex to Molex
7. And PC fans, i only added two 120mm and 80mm fans
I connect 8-9 pins of Arduino to the relay, 5V power supply and ground respectively. On a Molex wire, I cut the yellow and red wires and connect them to the relay, wires of the same color on a relay.
I maged to put it in the PC case in a more or less decent way!
Arduino programming
It turns out that Arduino reboots if you try to connect to it for the first time via serial port, they say this is a function, not a bug! So we will program with this in mind, we will write the state to memory, but there is no memory on the Arduino, but it somehow shows up there with the EEPROM library.
#include <EEPROM.h> const int PIN9 = 9; const int PIN8 = 8; bool value; String sdata=""; // Initialised to nothing. void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(PIN8, OUTPUT); pinMode(PIN9, OUTPUT); Serial.begin(9600); value = EEPROM.read(0); } void loop(void ) { byte ch; //Serial.println(value); if (value == 0) { digitalWrite(PIN9, HIGH); digitalWrite(PIN8, HIGH); } if (value == 1) { digitalWrite(PIN9, LOW); digitalWrite(PIN8, LOW); } if (Serial.available()) { ch = Serial.read(); sdata += (char)ch; if (ch=='\r') { // Command recevied and ready. sdata.trim(); // Process command in sdata. switch( sdata.charAt(0) ) { case 'n': EEPROM.write(0, 0); value = 0; break; case 'y': EEPROM.write(0, 1); value = 1; break; } // switch sdata = ""; // Clear the string ready for the next command. } } }
If Arduino receives n , it turn off the relay and write 0 to memory
If it receives and it turns on the relay and writes 1 in the memory
When loading, the Arduino reads what is in memory and changes the relay for this value
On/off switch on Arduino in Ubuntu via serial port
First, I look where is Arduino from
dmesg | grep ttyUSB
[ 5.100813] usb 3-5: ch341-uart converter now attached to ttyUSB0
I will get that value automatically, although it is most likely always be ttyUSB0
I create a file, in my folder, you will have a different foder
vi /home/alexandr/.win_fan_off
code
#!/usr/bin/bash utty=`dmesg | grep "ch341-uart converter now attached to" | awk '{printf $10}'` cat /dev/$utty & > /dev/null sleep 10 echo -e 'n\r' > /dev/$utty
Arduino on serial port in Ubuntu works strangely (and not only with it). There is a kind of shamanism, I don’t know what cat does, but it doesn’t work without it. After such a cat , you can send n and y at any time through eсho it will process it!
Sleep added to wait for Arduino to reboot; it happens, but not always!
Making script executable
sudo chmod +x /home/alexandr/.win_fan_off
I tried systemd and others “put the script in this folder” does not work! Only if you add it through Ubuntu windows it works
In Startup Applications Preferences add like this
And everything works, after boot the first click is heard, then after 10 seconds – the second and fans turns off! If it has already been off the clicks of the relay will not be heard!
I also wanted the scripts to make fans turned off on shutting down or reboot, but none of the official ways to do it worked!
On / off switch on Arduino in Windows 10 serial port
Run Windows PowerShell ISE with administrator rights
Create a file called fan_on.ps1 and text
$port= new-Object System.IO.Ports.SerialPort COM4,9600,None,8,one #opens serial port - adjust parameters accordingly $port.open() #opens serial connection $port.Writeline("y`r") #writes your content to the serial connection $port.Close() #closes serial connection Start-Sleep -s 15 $port= new-Object System.IO.Ports.SerialPort COM4,9600,None,8,one #opens serial port - adjust parameters accordingly $port.open() #opens serial connection $port.Writeline("y`r") #writes your content to the serial connection $port.Close() #closes serial connection
I have Arduino on COM4 and this will not change as it is connected internally, in your case you may have another
We send the command to turn on twice, because after the first call to the serial port, the Arduinoa usually reboots.
Create a task in Schedule Task Manager
check – run with highest priority
Trigger
chequa – run when any user logs in
Action
Run the script, it is important with which arguments
Command: powershell
Arguments: -ExecutionPolicy Bypass -File C:\Users\Alexandr\fan_on.ps1
WorkingDirectory:
Ura and it works on Windows too, the fans turn on! One thing, when you enter a blue PowerShell window pops up, I can’t find a functional way to run the script without a window …
Here are the additional fans in my caseCoguar QBX
1 – 120 mm out
2-80 mm inside
In total, 6 fans are spinning in Windows 10. The case maker promised that 3 more 120mm fans should fit, but this turned out to be false. The 120 second on til hits the power supply cable. And at the bottom two 120s do not fit because of the video card, apparently only if the card is one slot, they fit!
[…] take form the article How to turn on additional fans on PC via Arduino! 1. A 9 pin USB to micro USB cable – I had it, from Thermaltake Riing Trio 12 – I used […]