Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Wifi stuff
- #include <ESP8266WiFi.h>
- #include <ESP8266HTTPClient.h>
- const char *ssid = "Android hspot";
- const char *pass = "yodamaster";
- int SendReqFlag = 0;
- #include <SPI.h>
- #include <MFRC522.h>
- #define RST_PIN 5 // Configurable, see typical pin layout above
- #define SS_PIN 4 // Configurable, see typical pin layout above
- MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
- unsigned long card_uid;
- void setup() {
- Serial.begin(115200); // Initialize serial communications with the PC
- while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
- SPI.begin(); // Init SPI bus
- mfrc522.PCD_Init(); // Init MFRC522
- mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
- Serial.println(F("RFID inited!"));
- WiFi.begin(ssid, pass);
- while (WiFi.status() != WL_CONNECTED) {
- delay(1000);
- Serial.println("Connecting..");
- }
- Serial.println("WIFI inited");
- Serial.println(WiFi.localIP());
- }
- void wifi_loop(unsigned long UID)
- {
- /*if (WiFi.status() == WL_CONNECTED)
- {
- if (SendReqFlag)
- {
- SendReqFlag = 0;
- HTTPClient http; //Declare an object of class HTTPClient
- http.begin("127.0.0.1/kappa/>??????<"); //Specify request destination
- int httpCode = http.GET(); //Send the request
- if (httpCode > 0)
- { //Check the returning code
- String payload = http.getString();
- Serial.println(payload);//send it further
- }
- http.end();
- }
- }*/
- }
- void loop() {
- // Look for new cards
- if ( ! mfrc522.PICC_IsNewCardPresent()) {
- return;
- }
- // Select one of the cards
- if ( ! mfrc522.PICC_ReadCardSerial()) {
- return;
- }
- card_uid = mfrc522.uid.uidByte[0] << 24;
- card_uid += mfrc522.uid.uidByte[1] << 16;
- card_uid += mfrc522.uid.uidByte[2] << 8;
- card_uid += mfrc522.uid.uidByte[3];
- Serial.println(card_uid, HEX);
- wifi_loop(card_uid);
- //SendReqFlag = 1;
- mfrc522.PICC_HaltA();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement