-->
Page 1 of 2

GPIO or TX/RX

PostPosted: Thu Mar 09, 2017 1:29 pm
by manny009
So i'm trying to connect an RFID reader to the ESP8266-01.

I have connected the TX pin of the RFID reader to the RX on the ESP module.
Am I right in saying that the RX and TX pins on the ESP module are only used for programming/flashing the module?

In which case I should be connecting the TX pin of the reader to the GPIO2 pin of the ESP module instead?

If so how would I read the data form the GPIO2 pin?
Can someone explain what can be connected to the GPIO pins as I can only see the "LED on/off' example online and not something like a sensor input.


Thanks

Re: GPIO or TX/RX

PostPosted: Thu Mar 09, 2017 4:01 pm
by martinayotte
No, TX/RX can be used for any kind of serial communication, you just need to have some kind of jumper or switch on RX to temporarily disconnect your RFID if you wish to upload new firmware.

Re: GPIO or TX/RX

PostPosted: Thu Mar 09, 2017 6:25 pm
by manny009
Hmmm Interesting.

Then how can I read the data conning into the ESP RX pin?

Right now asking it to read the UART but am getting nothing out from it.

ie.

#include <ESP8266WiFi.h>
const char* ssid = "xxxxxxx";//type your ssid
const char* password = "xxxxxxx";//type your password

char val = 0; //variable to store the char read from the RFID button
/*Using RFID ID-12 to read unique character that is assigned to each RFID button or tag*/

void loop () {
//read the serial port
if(Serial.available() > 0)
val = Serial.read(); //read from one char from the ID-12 and store it
Serial.print(val); //display the char in the serial monitor
}

This should be right because when I use this code on an Arduino, The serial monitor reads the Arduino UART and print the tag info.

Re: GPIO or TX/RX

PostPosted: Fri Mar 10, 2017 1:15 am
by gbafamily1
The UART must be initialized in setup. Use the correct baud rate to match the RFID reader.

Code: Select allvoid setup()
{
  Serial.begin(9600);
}