ESP32 using SIM800 and RDM6300 can not connect to Thinger

I have a very simple project which uses TTGO T-Call ESP32 with SIM800L GPRS Module and RDM6300 RFID Module.

const char apn[]      = "..."; // APN (example: internet.vodafone.pt) use https://wiki.apnchanger.org
const char gprsUser[] = "..."; // GPRS User
const char gprsPass[] = "..."; // GPRS Password

// SIM card PIN (leave empty, if not defined)
const char simPIN[]   = "0000"; 

// TTGO T-Call pins
#define MODEM_RST            5
#define MODEM_PWKEY          4
#define MODEM_POWER_ON       23
#define MODEM_TX             27
#define MODEM_RX             26

// Set serial for debug console (to Serial Monitor, default speed 115200)
#define SerialMon Serial
// Set serial for AT commands (to SIM800 module)
#define SerialAT Serial1

// Configure TinyGSM library
#define TINY_GSM_MODEM_SIM800      // Modem is SIM800
#define TINY_GSM_RX_BUFFER   1024  // Set RX buffer to 1Kb

#include <TinyGsmClient.h>

TinyGsm modem(SerialAT);

// TinyGSM Client for Internet connection
TinyGsmClient client(modem);

void connectToApn(){
  SerialMon.println("Connecting to: internet.vivacom.bg ... ");
  while(!modem.gprsConnect(apn, gprsUser, gprsPass))
    delay(500);

  SerialMon.println("Successfully connected to: internet.vivacom.bg");
}

#define USERNAME "peepnee"
#define DEVICE_ID "vhR4bfqyo9Uqn2ONbgPv"
#define DEVICE_CREDENTIAL "n82Q94%MD5X%HQ0v"

#include <ThingerTinyGSM.h>
ThingerTinyGSM thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL, Serial1);

#include <rdm6300.h>
#define RFID_ESP8266_PIN 34
Rdm6300 rdm6300;

void setup() {
  // Set serial monitor debugging window baud rate to 115200
  SerialMon.begin(115200);

  // Set modem reset, enable, power pins
  pinMode(MODEM_PWKEY, OUTPUT);
  pinMode(MODEM_RST, OUTPUT);
  pinMode(MODEM_POWER_ON, OUTPUT);
  digitalWrite(MODEM_PWKEY, LOW);
  digitalWrite(MODEM_RST, HIGH);
  digitalWrite(MODEM_POWER_ON, HIGH);


  // Set GSM module baud rate and UART pins
  SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
  delay(3000);

  SerialMon.println("Initializing modem...");
  modem.init();

  // Unlock your SIM card with a PIN if needed
  if (strlen(simPIN) && modem.getSimStatus() != 3 ) {
    modem.simUnlock(simPIN);
  }
  
  connectToApn();
  // rdm6300.begin(RFID_ESP8266_PIN);
}

void loop() { 
  thing.handle();

  // RFID TAG WAS SCANNED
  if (rdm6300.get_new_tag_id()){
    SerialMon.println("TAG WAS SCANNED!!!!");
    SerialMon.println(rdm6300.get_tag_id(), HEX);
    SerialMon.println("Wohooo!!!!");
  }

  //SerialMon.println("\n ~~~~~~Working~~~~~ \n");
}

If I run the above code in the controller - it works well and it connects both to GPRS internet and thinger’s IoT platform. But, if I uncomment this line 77:

// rdm6300.begin(RFID_ESP8266_PIN);

It gets connected to the Internet but can not connect to the Thinger’s IoT platform where I host my devices. Interesting observation is that when I take a look at the frequency of the iterations of the loop changes when I have line 77 uncommented. For example, I get 5 iterations in 10 seconds but if I comment that - then I get 50-60 iterations in 10 seconds.

I also tried to position this initiation line at different places in the setup but this is what I get:

modem.init()
>>rdm6300.begin(RFID_ESP8266_PIN); 
connectToApn()
=> Modem doesn't get initialized (not connected to GPRS internet)
>>rdm6300.begin(RFID_ESP8266_PIN);
modem.init() 
connectToApn()
=> Modem doesn't get initialized (not connected to GPRS internet)
>>rdm6300.begin(RFID_ESP8266_PIN);
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
modem.init() 
connectToApn()
=> IS IT CONNECTED TO THINGER: YES, IS IT READING TAGS: NO

Hi,

Enable the debug output by the following line:

#define _DEBUG_

this will show at serial console why it cannot connect, paste the output here to see what is going on.

I just tried it. When I un-comment this line:

rdm6300.begin(RFID_ESP8266_PIN);

I keep on getting the following message:

[NETWORK] Starting connection...
[NETWORK] Cannot connect without setting the APN!
[NETWORK] Cannot connect!

No matter the network error - I can read RFID tags:

[NETWORK] Starting connection...
[NETWORK] Cannot connect without setting the APN!
[NETWORK] Cannot connect!
TAG WAS SCANNED!!!!
F3F8D91
Wohooo!!!!
[NETWORK] Starting connection...
[NETWORK] Cannot connect without setting the APN!
[NETWORK] Cannot connect!

Hi,

Set the APN at the main code, in the following line:

How is connected the RFID reader?

I have a valid APN there. I just removed it so I don’t expose too much information on the internet. The value that I have there is:

internet.vivacom.bg

The way RDM6300 is connected to TTGO CALL ESP32 SIM800 chip is as follows:

[RDM6300] TX  => [TTGO CALL ESP32 SIM800] GPIO 34
[RDM6300] RX => [TTGO CALL ESP32 SIM800] GPIO 35

and of course I get it (RDM6300) powered by the 5V coming from TTGO CALL ESP32 SIM800

The issue seems to come up when I try to create an instance of RDM6300 object:
rdm6300.begin(RFID_ESP8266_PIN);
This seems to interfere somehow with the APN setup and initialization.

Hi,

Where are defined those reader pins? Does it connect by a serial port?

Please post both debugs, when it connects to thinger and when it doesn’t, without your impressions.

I have already answered what connects to what and how is it defined in the code.

[RDM6300] TX and [RDM6300] RX are serial communication ports of the RFID module. Then, on the other end we have the [TTGO CALL ESP32 SIM800] GPIO 34 and [TTGO CALL ESP32 SIM800] GPIO 35

@ega without the exclamations this is how it looks like:

WHEN CONNECTED TO THINGER:

WHEN FAILING TO CONNECTED TO THINGER:
when_disconnected

Hi,

Add this at your setup

  // set APN (you can remove user and password from call if your apn does not require them)
  thing.setAPN(APN_NAME, APN_USER, APN_PSWD);

I would recommend you to use the original thinger´s tinygsm sketch, you are using other intructions to get the connection, that could be an issue if the device losses connection because there is no connection status checking at the main loop.

Hope this helps.

What solved the issue for me was to migrate from this library:

#include <rdm6300.h>
#define RFID_ESP8266_PIN 34
Rdm6300 rdm6300;

to EspSoftwareSerial as documented here: EspSoftwareSerial - Arduino Reference

Now I can read the RFID tags and connect to Thinger’s platform. This is the article that I followed more or less: https://microcontrollerslab.com/rdm6300-rdm630-rfid-reader-esp32-tutorial/

3 Likes