working rfid on hwv2, latest arduino-esp

This commit is contained in:
2021-11-27 11:07:16 +01:00
parent c5291f5566
commit bb9c4c8228
7 changed files with 29 additions and 23 deletions

View File

@@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html
[env:esp32-pico]
platform = espressif32
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
board = m5stack-atom
framework = arduino
lib_deps =
@@ -19,6 +19,6 @@ monitor_speed = 115200
lib_ldf_mode = deep+
extra_scripts = ./littlefsbuilder.py
build_flags =
-DHARDWARE=1
-DHARDWARE=2
;upload_protocol = espota
;upload_port = 192.168.2.254

View File

@@ -1,7 +1,8 @@
#pragma once
#define HARDWARE 1
#ifndef HARDWARE
#define HARDWARE 2
#endif
#if HARDWARE == 2
#define I2S_BCLK 19
@@ -9,16 +10,15 @@
#define I2S_DATA 18
#define DAC_SDMODE 23
#define NFC_SS 27
#define NFC_SCK 25
#define NFC_SS 25
#define NFC_SCK 14
#define NFC_MOSI 26
#define NFC_MISO 14
//#define NFC_RST 22 //not connectedx
#define NFC_MISO 27
#define NFC_IRQ 13
#define PWR_HOLD 4
#define PWR_BTN 9
#define MEAS_EN 10
#define PWR_BTN 5
#define MEAS_EN 12
#define MEAS_ADC 35 //ADC1_CH7
#define HALL_INPUT 36 //ADC1_CH0

View File

@@ -11,7 +11,7 @@
void setup()
{
//initPower();
initPower();
Serial.begin(115200);
delay(2000);
@@ -30,8 +30,8 @@ void loop()
debugHandle();
handleAudio();
handleRfid();
//handleRfid();
//handleGame();
//handlePower();
handlePower();
//handleOta();
}

View File

@@ -1,26 +1,31 @@
#include "rfid.h"
PN532_SPI pn532spi(SPI, NFC_SS, NFC_SCK, NFC_MISO, NFC_MOSI);
NfcAdapter nfc = NfcAdapter(pn532spi);
uint32_t lastRFID = 0;
//*****************************************************************************************//
void initRfid()
{
//int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);
// int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);
nfc.begin(true);
Serial.println(F("rfid init done")); //shows in serial that it is ready to read
Serial.println(F("rfid init done")); // shows in serial that it is ready to read
}
//*****************************************************************************************//
void handleRfid()
{
if (nfc.tagPresent())
uint32_t timeNow = millis();
if (lastRFID - timeNow > RFIDINTERVAL)
{
NfcTag tag = nfc.read();
String uid = tag.getUidString();
Serial.println(uid);
if (nfc.tagPresent())
{
NfcTag tag = nfc.read();
String uid = tag.getUidString();
Serial.println(uid);
}
}
}
//*****************************************************************************************//

View File

@@ -8,6 +8,7 @@
#include "NfcAdapter.h"
#define NDEF_SUPPORT_MIFARE_CLASSIC
#define RFIDINTERVAL 200
void initRfid(void);
void handleRfid(void);