Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <deprecated.h>
- #include <MFRC522.h>
- #include <MFRC522Extended.h>
- #include <require_cpp11.h>
- #include <SPI.h>
- #include <MFRC522.h>
- // Program odczytuje temperaturę z czujnika
- #include <OneWire.h>
- #include <DS18B20.h>
- // Numer pinu do którego podłaczasz czujnik
- #define ONEWIRE_PIN 2
- // Adres czujnika
- byte address[8] = {0x28, 0xFF, 0xB9, 0xB3, 0xA1, 0x17, 0x5, 0xD};
- OneWire onewire(ONEWIRE_PIN);
- DS18B20 sensors(&onewire);
- #define SS_PIN 10
- #define RST_PIN 9
- MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
- void setup() {
- Serial.begin(9600); // Initialize serial communications with the PC
- SPI.begin(); // Init SPI bus
- mfrc522.PCD_Init(); // Init MFRC522 card
- //Serial.println("Scan PICC to see UID and type...");
- //Serial.println("Scan PICC to see UID and type...");
- sensors.begin();
- sensors.request(address);
- }
- void loop() {
- // Look for new cards
- if ( ! mfrc522.PICC_IsNewCardPresent()) {
- return;
- }
- // Select one of the cards
- if ( ! mfrc522.PICC_ReadCardSerial()) {
- return;
- }
- //Serial.println("IDDDDDDDD");
- //Serial.println(mfrc522.uid);
- // Dump debug info about the card. PICC_HaltA() is automatically called.
- // mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
- if (mfrc522.uid.uidByte[0] == 0x69 &&
- mfrc522.uid.uidByte[1] == 0xF4 &&
- mfrc522.uid.uidByte[2] == 0x1F &&
- mfrc522.uid.uidByte[3] == 0x2B) {
- if (sensors.available())
- {
- float temperature = sensors.readTemperature(address);
- Serial.print(temperature);
- Serial.println(F(" 'C"));
- sensors.request(address);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement