DS3231_Temperature.pde 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // DS3231_Temperature
  2. // Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
  3. // web: http://www.RinkyDinkElectronics.com/
  4. //
  5. // A quick demo of how to use my DS3231-library to
  6. // quickly send the current temperature over a serial link
  7. //
  8. // To use the hardware I2C (TWI) interface of the chipKit you must connect
  9. // the pins as follows:
  10. //
  11. // chipKit Uno32/uC32:
  12. // ----------------------
  13. // DS3231: SDA pin -> Analog 4
  14. // SCL pin -> Analog 5
  15. // *** Please note that JP6 and JP8 must be in the I2C position (closest to the analog pins)
  16. //
  17. // chipKit Max32:
  18. // ----------------------
  19. // DS3231: SDA pin -> Digital 20 (the pin labeled SDA)
  20. // SCL pin -> Digital 21 (the pin labeled SCL)
  21. //
  22. // The chipKit boards does not have pull-up resistors on the hardware I2C interface
  23. // so external pull-up resistors on the data and clock signals are required.
  24. //
  25. // You can connect the DS3231 to any available pin but if you use any
  26. // other than what is described above the library will fall back to
  27. // a software-based, TWI-like protocol which will require exclusive access
  28. // to the pins used.
  29. //
  30. #include <DS3231.h>
  31. // Init the DS3231 using the hardware interface
  32. DS3231 rtc(SDA, SCL);
  33. void setup()
  34. {
  35. // Setup Serial connection
  36. Serial.begin(115200);
  37. // Initialize the rtc object
  38. rtc.begin();
  39. }
  40. void loop()
  41. {
  42. // Send current temperature
  43. Serial.print("Temperature: ");
  44. Serial.print(rtc.getTemp());
  45. Serial.println(" C");
  46. delay (1000);
  47. }