title: read MFRD522 data using raspberry pi and send this data by http(python3)
body: <p>I'm working on a project and I want to use RFID as a position reference(when raspberry pi and MFRC522 read the data, send it to server and make sure where is the position or adjust position while RFID reader is fixed)</p>
  
  <p>My code is below:</p>
  
  <pre><code>import RPi.GPIO as GPIO
  import MFRC522
  import signal
  import socket
  HOST = '192.168.11.48'
  PORT = 9009
  
  continue_reading = True
  
  # Capture SIGINT for cleanup when the script is aborted
  def end_read(signal,frame):
      global continue_reading
      print("Ctrl+C captured, ending read.")
      continue_reading = False
      GPIO.cleanup()
  
  # Hook the SIGINT
  signal.signal(signal.SIGINT, end_read)
  
  # Create an object of the class MFRC522
  MIFAREReader = MFRC522.MFRC522()
  
  # Welcome message
  print("Welcome to the MFRC522 data read example")
  
  # This loop keeps checking for chips. If one is near it will get the UID     and authenticate
  
  with socket.socket(socket.AF_INET,socket.SOCK_STREAM) as sock:
      sock.connect((HOST,PORT))
  
  
  #print("closing client")            
      while True:
          while continue_reading:
  
            # Scan for cards    
              (status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
  
          # If a card is found
              if status == MIFAREReader.MI_OK:
                  print("Card detected")
  
             # Get the UID of the card
                  (status,uid) = MIFAREReader.MFRC522_Anticoll()
  
              # If we have the UID, continue
              if status == MIFAREReader.MI_OK:
  
                  # Print UID
                  print("Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3]))
  
                  # This is the default key for authentication
                  key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]
  
                  # Select the scanned tag
                  MIFAREReader.MFRC522_SelectTag(uid)
  
  
              # Authenticate
                  status = MIFAREReader.MFRC522_Auth(MIFAREReader.PICC_AUTHENT1A, 8, key, uid)
              data = "str(uid[0])"
  
                  msg = data
                  sock.sendall(msg.encode())
                  data = sock.recv(128)
                  print('date from Echo server is [%s]'%data.decode())
  
              # Check if authenticated
                  if status == MIFAREReader.MI_OK:
                      MIFAREReader.MFRC522_Read(8)
                      MIFAREReader.MFRC522_StopCrypto1()
                  else:
                      print("Authentication error")
  </code></pre>
  
  <p><em>I am using echo server to make sure that it's working
  code for echo server is:</em></p>
  
  <pre><code>import socketserver
  
  HOST = ''
  PORT = 9009
  
  
  class MyTcpHandler(socketserver.BaseRequestHandler):
      def handle(self):
          print("[%s]conneted"%self.client_address[0])
  
          try:
              while True:
                  self.data = self.request.recv(1024)
                  if self.data.decode() == "/quit":
                      print('ended by user [%s]'%self.client_address[0])
                      return
  
                  print('[%s]'%self.data.decode())
                  self.request.sendall(self.data)
          except Exceptions as e:
              print(e)
  
  
  def runServer():
      print("starting echo server")
      print("if you want to close echo server, click Ctrl+C")
  
     try:
          server = socketserver.TCPServer((HOST,PORT), MyTcpHandler)
          server.serve_forever()
      except KeyboardInterrupt:
          print("--- closing server")
  
  runServer()        
  </code></pre>
  
  <p>I ran fist piece of code while the second one was running, but only result I got was -</p>
  
  <pre><code>Welcome to the MFRC522 data read example
  Card detected
  Card read UID:178,29,209,48
  size:8.
  </code></pre>
  
  <p>Anyone had idea what I should change to make it work?</p>
  
  <p>thanks</p>