Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #include <deprecated.h>
  2. #include <MFRC522.h>
  3. #include <MFRC522Extended.h>
  4. #include <require_cpp11.h>
  5. #include <SPI.h>
  6. #include <MFRC522.h>
  7.  
  8. // Program odczytuje temperaturę z czujnika
  9.  
  10. #include <OneWire.h>
  11. #include <DS18B20.h>
  12.  
  13. // Numer pinu do którego podłaczasz czujnik
  14. #define ONEWIRE_PIN 2
  15.  
  16. // Adres czujnika
  17. byte address[8] = {0x28, 0xFF, 0xB9, 0xB3, 0xA1, 0x17, 0x5, 0xD};
  18.  
  19. OneWire onewire(ONEWIRE_PIN);
  20. DS18B20 sensors(&onewire);
  21.  
  22.  
  23. #define SS_PIN 10
  24. #define RST_PIN 9
  25. MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
  26.  
  27. void setup() {
  28. Serial.begin(9600); // Initialize serial communications with the PC
  29. SPI.begin(); // Init SPI bus
  30. mfrc522.PCD_Init(); // Init MFRC522 card
  31. //Serial.println("Scan PICC to see UID and type...");
  32. //Serial.println("Scan PICC to see UID and type...");
  33.  
  34. sensors.begin();
  35. sensors.request(address);
  36. }
  37.  
  38. void loop() {
  39. // Look for new cards
  40. if ( ! mfrc522.PICC_IsNewCardPresent()) {
  41. return;
  42. }
  43.  
  44. // Select one of the cards
  45. if ( ! mfrc522.PICC_ReadCardSerial()) {
  46. return;
  47. }
  48. //Serial.println("IDDDDDDDD");
  49. //Serial.println(mfrc522.uid);
  50.  
  51.  
  52. // Dump debug info about the card. PICC_HaltA() is automatically called.
  53. // mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
  54.  
  55. if (mfrc522.uid.uidByte[0] == 0x69 &&
  56. mfrc522.uid.uidByte[1] == 0xF4 &&
  57. mfrc522.uid.uidByte[2] == 0x1F &&
  58. mfrc522.uid.uidByte[3] == 0x2B) {
  59. if (sensors.available())
  60. {
  61. float temperature = sensors.readTemperature(address);
  62. Serial.print(temperature);
  63. Serial.println(F(" 'C"));
  64. sensors.request(address);
  65. }
  66. }
  67.  
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement