Chat freely about anything...

User avatar
By julezrules
#92918 I'm rlly about to switch to Arduino. So many bugs and problems with these ESP bullshit boards..

I have a simple script. nothing much to say about it it just sends serial data by "Serial.print".
I plug the board into my computer and open a serial monitor program. It doesnt work until I press the reset button on the board, then it gets the serial data. WTH? I wanna built a device that's installed permanently and I don't wanna press the reset button everytime it gets powered on. On Arduino that works just fine.

Code: Select all#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN D8
#define RST_PIN D3
 
MFRC522 rfid(SS_PIN, RST_PIN);

MFRC522::MIFARE_Key key;

void setup() {
  pinMode(D1, OUTPUT);
  digitalWrite(D1, LOW);
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
  rfid.PCD_SetAntennaGain(rfid.RxGain_max);
  Serial.println("B");
  digitalWrite(D1, HIGH);
}
 
void loop() {
  if ( ! rfid.PICC_IsNewCardPresent())
    return;

  if ( ! rfid.PICC_ReadCardSerial())
    return;

  char str[32] = "";
  array_to_string(rfid.uid.uidByte, 4, str);
  Serial.println(str);
 
  rfid.PICC_HaltA();
  rfid.PCD_StopCrypto1();
}

void array_to_string(byte array[], unsigned int len, char buffer[])
{
  for (unsigned int i = 0; i < len; i++)
  {
    byte nib1 = (array[i] >> 4) & 0x0F;
    byte nib2 = (array[i] >> 0) & 0x0F;
    buffer[i*2+0] = nib1  < 0xA ? '0' + nib1  : 'A' + nib1  - 0xA;
    buffer[i*2+1] = nib2  < 0xA ? '0' + nib2  : 'A' + nib2  - 0xA;
  }
  buffer[len*2] = '\0';
}
User avatar
By QuickFix
#92969 On a Wemos D8 is GPIO15 and D3 is GPIO0, these GPIO's are used to boot the ESP in a certain way:
BootModes.png
BootModes.png (7.5 KiB) Viewed 4349 times


Please use other GPIO's for the RFID reader or disconnect the reader at boot (but I can imagine the latter won't be handy at all). :idea:
User avatar
By julezrules
#92995
QuickFix wrote:On a Wemos D8 is GPIO15 and D3 is GPIO0, these GPIO's are used to boot the ESP in a certain way:
BootModes.png


Please use other GPIO's for the RFID reader or disconnect the reader at boot (but I can imagine the latter won't be handy at all). :idea:



omg thank you so much! It works!
I've seen a photo on google which showed which pins you can use for the wemos board. They never mentioned that though and it says these pins are OK to use. Thank you!!!