skdrx
Published © MIT

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

IntermediateFull instructions provided614
Smart PC Case Temperature Monitor #CloudGames2022Untitled

Things used in this project

Hardware components

Arduino Oplà IoT Kit
Arduino Oplà IoT Kit
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LM35 Analog Temperature sensor
×3

Story

Read more

Code

Main Code

Arduino
Main code for case fans monitoring tool
/* 
  Sketch generated by the Arduino IoT Cloud Thing "Case Fans"
  https://create.arduino.cc/cloud/things/7e5d8198-9873-4993-9433-0284165f966b 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float pcHum;
  float pcTemp1;
  float pcTemp2;
  float pcTemp3;
  int caseFan1;
  int caseFan2;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include <Arduino_MKRIoTCarrier.h>
#define p1 A1
#define p2 A2
#define p3 A3
MKRIoTCarrier carrier;

float getTemp(int Pin){
  
  int reading = analogRead(Pin);
  // Convert the reading into voltage:
  float voltage = reading * (5000 / 1024.0);
  // Convert the voltage into the temperature in degree Celsius:
  float temperature = voltage / 10;
  return temperature;
}

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
 
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);
 
  // Defined in thingProperties.h
  initProperties();
 
  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
 
  //Get Cloud Info/errors , 0 (only errors) up to 4
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
 
  //Wait to get cloud connection to init the carrier
  while (ArduinoCloud.connected() != 1) {
    ArduinoCloud.update();
    delay(500);
  }
 
  delay(500);
  CARRIER_CASE = false;
  carrier.begin();
  carrier.display.setRotation(0);
  
}

void loop() {
  ArduinoCloud.update();
  pcHum = carrier.Env.readHumidity();
  pcTemp1 = getTemp(1);
  pcTemp2 = getTemp(2);
  pcTemp3 = getTemp(3);
  float avg_temp = (pcTemp1 + pcTemp2 +pcTemp3)/3.0; 
  Serial.println(caseFan1);
  Serial.println(caseFan2);
  Serial.println(".");
  delay(1000);
  carrier.display.fillScreen(ST77XX_BLACK);
  carrier.display.setTextColor(ST77XX_WHITE);
  carrier.display.setTextSize(3);
 
  carrier.display.setCursor(30, 110);
  carrier.display.print("avg temp: \n   ");
  carrier.display.print(avg_temp);
  carrier.display.print(" C");
  
  
}

/*
  Since PcTemp1 is READ_WRITE variable, onPcTemp1Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onPcTemp1Change()  {
  // Add your code here to act upon PcTemp1 change
}

/*
  Since PcTemp2 is READ_WRITE variable, onPcTemp2Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onPcTemp2Change()  {
  // Add your code here to act upon PcTemp2 change
}

/*
  Since PcTemp3 is READ_WRITE variable, onPcTemp3Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onPcTemp3Change()  {
  // Add your code here to act upon PcTemp3 change
}

/*
  Since PcHum is READ_WRITE variable, onPcHumChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onPcHumChange()  {
  // Add your code here to act upon PcHum change
}

/*
  Since CaseFan1 is READ_WRITE variable, onCaseFan1Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onCaseFan1Change()  {
  // Add your code here to act upon CaseFan1 change
}

/*
  Since CaseFan2 is READ_WRITE variable, onCaseFan2Change() is
  executed every time a new value is received from IoT Cloud.
*/
void onCaseFan2Change()  {
  // Add your code here to act upon CaseFan2 change
}

Credits

skdrx

skdrx

1 project • 0 followers

Comments