Smart PC Case Temperature Monitor #CloudGames2022Untitled
Ever since GPUs and CPUs have been getting a lot hotter, case thermals have never been more important. My tool monitors case temperature
Components and supplies
3
LM35 Analog Temperature sensor
1
Arduino Oplà IoT Kit
1
Jumper wires (generic)
Project description
Code
Main Code
arduino
Main code for case fans monitoring tool
1/* 2 Sketch generated by the Arduino IoT Cloud Thing "Case Fans" 3 https://create.arduino.cc/cloud/things/7e5d8198-9873-4993-9433-0284165f966b 4 5 Arduino IoT Cloud Variables description 6 7 The following variables are automatically generated and updated when changes are made to the Thing 8 9 float pcHum; 10 float pcTemp1; 11 float pcTemp2; 12 float pcTemp3; 13 int caseFan1; 14 int caseFan2; 15 16 Variables which are marked as READ/WRITE in the Cloud Thing will also have functions 17 which are called when their values are changed from the Dashboard. 18 These functions are generated with the Thing and added at the end of this sketch. 19*/ 20 21#include "thingProperties.h" 22#include <Arduino_MKRIoTCarrier.h> 23#define p1 A1 24#define p2 A2 25#define p3 A3 26MKRIoTCarrier carrier; 27 28float getTemp(int Pin){ 29 30 int reading = analogRead(Pin); 31 // Convert the reading into voltage: 32 float voltage = reading * (5000 / 1024.0); 33 // Convert the voltage into the temperature in degree Celsius: 34 float temperature = voltage / 10; 35 return temperature; 36} 37 38void setup() { 39 // Initialize serial and wait for port to open: 40 Serial.begin(9600); 41 42 // This delay gives the chance to wait for a Serial Monitor without blocking if none is found 43 delay(1500); 44 45 // Defined in thingProperties.h 46 initProperties(); 47 48 // Connect to Arduino IoT Cloud 49 ArduinoCloud.begin(ArduinoIoTPreferredConnection); 50 51 //Get Cloud Info/errors , 0 (only errors) up to 4 52 setDebugMessageLevel(2); 53 ArduinoCloud.printDebugInfo(); 54 55 //Wait to get cloud connection to init the carrier 56 while (ArduinoCloud.connected() != 1) { 57 ArduinoCloud.update(); 58 delay(500); 59 } 60 61 delay(500); 62 CARRIER_CASE = false; 63 carrier.begin(); 64 carrier.display.setRotation(0); 65 66} 67 68void loop() { 69 ArduinoCloud.update(); 70 pcHum = carrier.Env.readHumidity(); 71 pcTemp1 = getTemp(1); 72 pcTemp2 = getTemp(2); 73 pcTemp3 = getTemp(3); 74 float avg_temp = (pcTemp1 + pcTemp2 +pcTemp3)/3.0; 75 Serial.println(caseFan1); 76 Serial.println(caseFan2); 77 Serial.println("."); 78 delay(1000); 79 carrier.display.fillScreen(ST77XX_BLACK); 80 carrier.display.setTextColor(ST77XX_WHITE); 81 carrier.display.setTextSize(3); 82 83 carrier.display.setCursor(30, 110); 84 carrier.display.print("avg temp: \ 85 "); 86 carrier.display.print(avg_temp); 87 carrier.display.print(" C"); 88 89 90} 91 92/* 93 Since PcTemp1 is READ_WRITE variable, onPcTemp1Change() is 94 executed every time a new value is received from IoT Cloud. 95*/ 96void onPcTemp1Change() { 97 // Add your code here to act upon PcTemp1 change 98} 99 100/* 101 Since PcTemp2 is READ_WRITE variable, onPcTemp2Change() is 102 executed every time a new value is received from IoT Cloud. 103*/ 104void onPcTemp2Change() { 105 // Add your code here to act upon PcTemp2 change 106} 107 108/* 109 Since PcTemp3 is READ_WRITE variable, onPcTemp3Change() is 110 executed every time a new value is received from IoT Cloud. 111*/ 112void onPcTemp3Change() { 113 // Add your code here to act upon PcTemp3 change 114} 115 116/* 117 Since PcHum is READ_WRITE variable, onPcHumChange() is 118 executed every time a new value is received from IoT Cloud. 119*/ 120void onPcHumChange() { 121 // Add your code here to act upon PcHum change 122} 123 124/* 125 Since CaseFan1 is READ_WRITE variable, onCaseFan1Change() is 126 executed every time a new value is received from IoT Cloud. 127*/ 128void onCaseFan1Change() { 129 // Add your code here to act upon CaseFan1 change 130} 131 132/* 133 Since CaseFan2 is READ_WRITE variable, onCaseFan2Change() is 134 executed every time a new value is received from IoT Cloud. 135*/ 136void onCaseFan2Change() { 137 // Add your code here to act upon CaseFan2 change 138}
Comments
Only logged in users can leave comments