{"action":"created","issue":{"url":"https://api.github.com/repos/miguelbalboa/rfid/issues/359","repository_url":"https://api.github.com/repos/miguelbalboa/rfid","labels_url":"https://api.github.com/repos/miguelbalboa/rfid/issues/359/labels{/name}","comments_url":"https://api.github.com/repos/miguelbalboa/rfid/issues/359/comments","events_url":"https://api.github.com/repos/miguelbalboa/rfid/issues/359/events","html_url":"https://github.com/miguelbalboa/rfid/issues/359","id":295670128,"number":359,"title":"RFID on Heltec WiFi LoRa 32","user":{"login":"IvanDreamer","id":1818105,"avatar_url":"https://avatars1.githubusercontent.com/u/1818105?v=4","gravatar_id":"","url":"https://api.github.com/users/IvanDreamer","html_url":"https://github.com/IvanDreamer","followers_url":"https://api.github.com/users/IvanDreamer/followers","following_url":"https://api.github.com/users/IvanDreamer/following{/other_user}","gists_url":"https://api.github.com/users/IvanDreamer/gists{/gist_id}","starred_url":"https://api.github.com/users/IvanDreamer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IvanDreamer/subscriptions","organizations_url":"https://api.github.com/users/IvanDreamer/orgs","repos_url":"https://api.github.com/users/IvanDreamer/repos","events_url":"https://api.github.com/users/IvanDreamer/events{/privacy}","received_events_url":"https://api.github.com/users/IvanDreamer/received_events","type":"User","site_admin":false},"labels":[{"id":760725762,"url":"https://api.github.com/repos/miguelbalboa/rfid/labels/help_wanted","name":"help_wanted","color":"159818","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-02-08T21:23:23Z","updated_at":"2018-03-26T17:15:04Z","closed_at":"2018-02-08T23:54:37Z","author_association":"NONE","body":"\r\n * OS version: MAC OS\r\n * Arduino IDE version: 1.8.6\r\n * MFRC522 Library version: 1.3.6 <!-- comment: important! v1.x.x or master-branch? -->\r\n * Arduino device: ESP32 Heltec WiFi LoRa 32 \r\n * MFRC522 device\r\n  \r\nI'd like to make work Heltec WiFi LoRa 32  board and RFID together, but did not find any working advice how to make it. \r\n\r\nCould someone help with it? \r\n"},"comment":{"url":"https://api.github.com/repos/miguelbalboa/rfid/issues/comments/376242288","html_url":"https://github.com/miguelbalboa/rfid/issues/359#issuecomment-376242288","issue_url":"https://api.github.com/repos/miguelbalboa/rfid/issues/359","id":376242288,"user":{"login":"infu","id":24810,"avatar_url":"https://avatars0.githubusercontent.com/u/24810?v=4","gravatar_id":"","url":"https://api.github.com/users/infu","html_url":"https://github.com/infu","followers_url":"https://api.github.com/users/infu/followers","following_url":"https://api.github.com/users/infu/following{/other_user}","gists_url":"https://api.github.com/users/infu/gists{/gist_id}","starred_url":"https://api.github.com/users/infu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infu/subscriptions","organizations_url":"https://api.github.com/users/infu/orgs","repos_url":"https://api.github.com/users/infu/repos","events_url":"https://api.github.com/users/infu/events{/privacy}","received_events_url":"https://api.github.com/users/infu/received_events","type":"User","site_admin":false},"created_at":"2018-03-26T17:15:04Z","updated_at":"2018-03-26T17:15:04Z","author_association":"NONE","body":"@paulmassen @IvanDreamer thanks guys for figuring out most of it. Here is the code that makes RFID and LORA work on Heltec and TTGO WIFI LORA ESP32\r\n\r\n`#include <SPI.h>\r\n#include <LoRa.h>\r\n#include <Wire.h>  \r\n\r\n#define LORA_SCK     5    \r\n#define LORA_MISO    19   \r\n#define LORA_MOSI    27 \r\n#define LORA_SS      18  \r\n#define LORA_RST     14   \r\n#define LORA_DI0     26  \r\n#define LORA_BAND    868E6\r\n\r\n#include <SPI.h>\r\n#include <MFRC522.h>\r\n\r\n#define RFID_SDA 5 \r\n#define RFID_SCK 18 \r\n#define RFID_MOSI 23\r\n#define RFID_MISO 19\r\n#define RFID_RST 22\r\n\r\nMFRC522 mfrc522(RFID_SDA, RFID_RST);  // Create MFRC522 instance\r\n\r\nint current_spi = -1; // -1 - NOT STARTED   0 - RFID   1 - LORA\r\n\r\nvoid setup() {\r\n  Serial.begin(9600);   // Initialize serial communications with the PC\r\n  while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)\r\n  \r\n}\r\n\r\nvoid loop() {\r\n  bool card_present = RFID_check();\r\n  if (card_present) LORA_send();\r\n}\r\n\r\nvoid spi_select(int which) {\r\n     if (which == current_spi) return;\r\n     SPI.end();\r\n     \r\n     switch(which) {\r\n        case 0:\r\n          SPI.begin(RFID_SCK, RFID_MISO, RFID_MOSI);\r\n          mfrc522.PCD_Init();   \r\n        break;\r\n        case 1:\r\n          SPI.begin(LORA_SCK,LORA_MISO,LORA_MOSI,LORA_SS);\r\n          LoRa.setPins(LORA_SS,LORA_RST,LORA_DI0);\r\n        break;\r\n     }\r\n\r\n     current_spi = which;\r\n}\r\n\r\nint RFID_check() {\r\n  spi_select(0);\r\n  // Look for new cards\r\n  if ( ! mfrc522.PICC_IsNewCardPresent()) {\r\n    delay(100);\r\n    return false;\r\n  }\r\n\r\n  // Select one of the cards\r\n  if ( ! mfrc522.PICC_ReadCardSerial()) {\r\n    return false;\r\n  }\r\n\r\n  // Dump debug info about the card; PICC_HaltA() is automatically called\r\n  mfrc522.PICC_DumpToSerial(&(mfrc522.uid));\r\n  \r\n  return true;\r\n}\r\n\r\nvoid LORA_send() {\r\n  spi_select(1);\r\n  \r\n  Serial.println(\"LoRa Sender Test\"); \r\n  \r\n  if (!LoRa.begin(868E6)) {\r\n    Serial.println(\"Starting LoRa failed!\");\r\n    while (1);\r\n  }\r\n\r\n  Serial.println(\"init ok\");\r\n \r\n  delay(1500);\r\n\r\n  // send packet\r\n  LoRa.beginPacket();\r\n  LoRa.print(\"hello \");\r\n\r\n  LoRa.endPacket();\r\n\r\n  Serial.println(\"sent one\");\r\n  delay(2000);                       // wait for a second\r\n }\r\n  \r\n`\r\n\r\nYour pins worked out. I am not sure how you selected them? Before that I tried using the MOSI, MISO, CLK from the schematic (also used by LORA) and I didn't get the RFID to run at all.\r\n\r\nThere is probably a better way to do it and have both modules work at the same time, without having to switch with SPI.begin and SPI.end the way I am doing it. But for that I guess we need to have same MOSI, MISO and CLK. But well, I guess this one is good enough. Currently it sends LORA msg when RFID chip is nearby. I guess the only thing thats left is to try and see if we can receive LORA messages while scanning for RFID chips"}}
{"actor":{"display_login":"infu"}}