A7 with Mega

I have an AI Thinker A7 module connected to n Arduino Mega 2560 R3. I have loaded a sample sketch that I found in this community

#define BLYNK_PRINT Serial

#define TINY_GSM_MODEM_A7 //gsm A7

// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30

#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
#include <SimpleTimer.h>

const char auth[] = "blah blah blah"; //auth token blynk
const char apn[]  = "blah blah blah"; //apn mobile
const char user[] = "";
const char pass[] = "";

// Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial1

// or Software Serial on Uno, Nano
//#include <SoftwareSerial.h>
//SoftwareSerial SerialAT(6,7); // RX, TX

TinyGsm modem(SerialAT);

// Select your pin with physical button

const int Relay1 = 13; //relay pin 13 arduino
WidgetLED led3(V3); //v3 in wiget blynk

SimpleTimer timer;

// V3 LED Widget represents the physical button state
boolean btnState = false;
void buttonLedWidget()
  // Read button
  boolean isPressed = (digitalRead(Relay1) == LOW);

  // If state has changed...
  if (isPressed != btnState) {
    if (isPressed) {
    } else {
    btnState = isPressed;

void setup()
  // Debug console


  // Set GSM module baud rate

  // Restart takes quite some time
  // To skip it, call init() instead of restart()

  // Unlock your SIM card with a PIN

  Blynk.begin(auth, modem, apn, user, pass);

  // Setup physical button pin (active low)
  pinMode(Relay1, INPUT_PULLUP);

  timer.setInterval(500L, buttonLedWidget);

void loop()

I also used the AT Debug tool to verify that I had the correct baud rate…

I attempt to connect to the cloud and everything goes great until I keep getting booted for Invalid Auth Token. I have verified, refreshed and re-tried a couple of Auth Tokens with the same results.

I searched the forum and found mostly info pertaining to wifi or blutooth boards. Nothing related to Invalid Auth Tokens and A7. So, I am at a loss and looking for help. I am not sure if it has to do with the library or something I have missed? I tried using the same sim card with a SIM800l without success. I am able to connect an Electron to Blynk cloud with the same sim card.

Thanks in advance

@mpo881 what do you get in a web browser when you use the latest token in the app and in the sketch with the following url?


@Costas I am not sure I follow you but I clicked on the link and it says invalid auth token in the upper left hand corner of the browser.

you can’t click the link, enter your real token in place of the word token.

Based on your last comment does your sketch include “blah blah blah” or a real token.

LOL no it contains a real token and a real APN. The reason I cannont enter it in your link is because it is HTML and there is no provision to type it in.

@mpo881 thanks for sending me your token by PM. Browser gives invalid token for that token but that could be a geo-dns issue.

Ping me blynk-cloud.com and tell me the IP it gives you.

Do you move between cloud and local servers? Is your app set for cloud or local?

Ok well I figured out what you are talking about by copying the link in a new browser and replacing TOKEN with the token. Now I can see when I created the project, etc

1 Like

Sorry, forgot to reply to this question. I do not use Local Sever at all, only cloud


Ok that does give a valid json file in a browser that starts with:

{"id":2004684070,"parentId":-1,"isPreview":false,"name":"blink blynk","createdAt":1483644230,"updatedAt":1498062912937,"widgets":

Your A7 must be connecting to a different server. In the app move the slider at the login page and change blynk-cloud.com to the IP and you should be good to go.

Before I do that, will that impact my other projects that I have running?

Yes if you have other projects that are not using the A7 then you will have to move the slider back and forth depending which project you are running.

Thanks very much for the help. Ill give it a try

You might need to ping from the A7 to be sure you have the correct IP address and you might also need to create a new account on that particular Blynk server.

Ok, Thanks again. Ill have to try to figure out how to do that. I appreciate your time

Well I tried the custom IP and got the same results. The thing that I dont understand is that it is trying to connect to port 8442 in the serial monitor regardless if I use BLYNK or CUSTOM in the slider yet when I choose CUSTOM I am given the option of port 8443. If I change that to 8442 the app complains about the server being busy.