Advertisement
pleasedontcode

"Temperature Tracker" rev_01

Mar 5th, 2024
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: "Temperature Tracker"
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-03-05 22:40:56
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* I integrate the JDY-31 Bluetooth module with your */
  21.     /* Arduino Uno R3, along with a thermistor */
  22.     /* temperature sensor write a code that reads the */
  23.     /* resistnace from the thermistor, converts it to */
  24.     /* temprature using this equation y = */
  25.     /* 25.76e^-0.039x,where y is the T */
  26. /****** END SYSTEM REQUIREMENTS *****/
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <SoftwareSerial.h>
  30. #include <math.h>
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35.  
  36. /***** DEFINITION OF Software Serial *****/
  37. const uint8_t JDY31_HC05_mySerial_PIN_SERIAL_TX_A0 = A0;
  38. const uint8_t JDY31_HC05_mySerial_PIN_SERIAL_RX_A1 = A1;
  39. SoftwareSerial JDY31_HC05_mySerial(JDY31_HC05_mySerial_PIN_SERIAL_RX_A1, JDY31_HC05_mySerial_PIN_SERIAL_TX_A0);
  40.  
  41. // Define the pins for the thermistor
  42. const int thermistorPin = A2;
  43.  
  44. void setup(void)
  45. {
  46.   // put your setup code here, to run once:
  47.   JDY31_HC05_mySerial.begin(9600);
  48.   Serial.begin(9600); // Initialize the Serial Monitor
  49. }
  50.  
  51. void loop(void)
  52. {
  53.   // put your main code here, to run repeatedly:
  54.  
  55.   // Read the resistance from the thermistor
  56.   int thermistorValue = analogRead(thermistorPin);
  57.  
  58.   // Convert the resistance to temperature using the equation y = 25.76e^-0.039x
  59.   float temperature = 25.76 * exp(-0.039 * thermistorValue);
  60.  
  61.   // Print the temperature to the Serial Monitor
  62.   Serial.print("Temperature: ");
  63.   Serial.print(temperature);
  64.   Serial.println(" degrees Celsius");
  65.  
  66.   // Delay for 1 second
  67.   delay(1000);
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement