Arduino uno not connecting to LocalServer

Hi all,
I am building a project to connect to Blynk local server on ARDUINO UNO with SIM900 Module.

I have created a blynk local server using terminal in macbook. The ip address is 192.168.1.102 and port is 9443. While creating local server, i got message in terminal as below:
Your Admin url is https://192.168.1.102:9443/admin
Your Admin login email is admin@blynk.cc
Your Admin password is admin
I am also able to create new project using token generated on my email id.

But however, in arduino uno, it doesnot get connected to local server. The code is as below:

BlynkTimer timer;
char auth[] = "*my token as received*";

char apn[]  = "internet";
char user[] = "";
char pass[] = "";
char server[] = "192.168.1.102";
int flag=0;

#define SerialAT Serial1

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

TinyGsm modem(SerialAT);

void setup()
{
  Serial.begin(9600);
  delay(10);

  SerialAT.begin(9600);
  delay(3000);

  Serial.println("Initializing modem...");
  modem.restart();

  Blynk.begin(auth, modem, apn, user, pass, server, 9443);
  pinMode(8,INPUT);    
  pinMode(10,OUTPUT);
  timer.setInterval(1000L,notifyOnFire);
}
void loop()
{
Blynk.run();
timer.run();
}

However, it doesn’t get connected to server, rather following output is generated in serial monitor:

Initializing modem...
[15364] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Uno

[15457] Modem init...
[16477] Connecting to network...
[16774] Network: IND AirTel
[16774] Connecting to internet ...
[20880] Connected to GPRS
[21150] Connecting to 192.168.1.102:9443

Can anyone help me here please.

You need to understand a bit more about how networking works.
The IP address of 192.168.1.102 is local too your home network. I have a device on my network with the same IP address, and so do tens of millions of other people across the world.

If your Arduino was connecting to the your local network’s WiFi or wired Ethernet system then it would find your local server, because your router would assign the Arduino an IP address and ensure that data packets are routed to the correct device.

Your Arduino is connecting to a cellular data network, outside of your local network, and the ISP for that network doesn’t know that it has to route the data packets to your network, or to one of the millions of other networks across the world.

If your home network had its own static public IP address then you could use that in your sketch, then set your router up so that any inbound data intended for port 9443 is routed to local IP 192.168.1.102 so that it goes to your local server.

As you probably don’t have a static public IP address then you’ll need to use a DDNS service like NoIP or DuckDNS. This will give you a url which will then be routed to your current public IP address. To make this work, you need to have a DDNS update client running on your home network which tells your DDNS service what your current public IP address is.

Pete.

I really don’t understand why people still use Uno when it’s expensive and poorly performing.
Better to use an ESP32 for less than 5$ :thinking:

1 Like

And a TTGO T-Call ESP32 if you want a SiM based system.

Pete.

1 Like

I think people buy the basic kit with 150 unnecessary sensors for $ 40 :smile:

Dear @PeteKnight ,
I have installed DDNS service and have got public IP address such as “123.456.789.123”.
Now what should I update in code?

Ensure that your DDNS service is being updated with a client on your network.
In your router, forward the ports you are using in your local server (probably 943 and 8080) to 192.168.1.102
Use your DDNS url in your sketch, like this:

char server[] = "yourDDNSurl";

You should also use the same DDNS urlmin your app’s Custom Server settings, if you want to be able to use the app when your phone is not connected to your local network.

Pete.

Dear @PeteKnight,
I tried using “DDNSurl” as server. But I received following error:

Packet too big: 20527

Please help me.

Explain in detail what steps you have taken and EXACTLY what you see in your serial monitor when you boot your device.

Pete.

I have created public IP address as “XXXX.ddns.net” through no-ip account.
I have also downloaded DDNS update client and is currently running in background.
Actually, Local IP address is 192.168.1.102 which is connected through TP-Link router.
I have port forwarded 9443 to 192.168.1.102 also,

In the sketch, i have edited below:

char apn[]  = "internet";
char user[] = "";
char pass[] = "";
Blynk.begin(auth, modem, apn, user, pass, server,80);

I have used port 80 because 9443, 8080 couldn’t work.
However, i am getting following output:

[15516] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on Arduino Uno

[15609] Modem init...
[16875] Connecting to network...
[17171] Network: IND AirTel
[17171] Connecting to internet ...
[21978] Connected to GPRS
[22253] Connecting to XXXX.ddns.net:80
[27869] Packet too big: 20527

Can you please tell me what I have done wrong or am I missing anything.
It would be of great help to me.
I just want to create a Blynk local server in PC and want to connect to the server through SIM900 module.
While creating blynk local server through “terminal”, I get the confirmation that Blynk local server has started.
Also, I get the address as 192.168.1.102:9443/admin.
But after that everything seems mess as I cant connect to 192.168.1.102 even after no-ip ddns account and port forwarding.

Of you specify port 80 in your connection string then you need port 80 traffic that hits your router to be forwarded to your Blynk server, otherwise the data packets will have no where to be routed to.
However, port 80 is blocked by many ISPs, especially ones that use a GPRS service, so 8080 is a better port to use.

Have you created the Auth code that you are using via the app whe it was connected ted to your local server?
Have you tested using you No-IP DDNS address and port 9443 in your app’s customer server settings and turning off WiFi on your phone so that it forces an external connection, via the No-IP and port forwarding that you’ve set-up?

Pete.

Dear @PeteKnight,
Thanks for your help.
It seems that it is working now.
I have port forwarded external 9443 to internal 8080.
Also i used “XXXX.ddns.net” for server address.
For connecting with blynk app, I used below configurations :

Port : 9443

The blynk app worked and auth token generated.
In the sketch, i have edited below:

char apn[]  = "internet";
char user[] = "";
char pass[] = "";
char server[] = "XXXX.ddns.net";
Blynk.begin(auth, modem, apn, user, pass, server, 8080);

After that i run the code and the local server is working now as the GSM module is now connected to XXXX.ddns.net:8080.
Thanks a lot for for your guidance.
Truly a genius Sir.

Why?
The sensible thing to do would be to forward external 9443 to internal 9443 and external 8080 to internal 8080.

Pete.

I don’t understand how could work 9443 to 8080 :thinking:
It makes no sens.

1 Like


Please see the snapshot attached.
Please tell me if something is wrong or being missed here.

That’s OK
9443 to 9443
8080 to 8080

It would be okay if that was what he’s set up, but it isn’t.

@sashikant edit the second row, and change the “external port start” and “external port end” to 8080.

I think each entry should have a unique server name too, but maybe not?

Your two entries also have different WAN interfaces. I don’t know how many WAN interfaces your router has but all interfaces that could have incoming Blynk data need to be port-forwarded for both sets of ports, so 2x WAN interfaces and 2x Blynk ports (8080 and 9443) = 4 entries in this table - assuming that your WAN interface drop down doesn’t allow you to choose “all”.

Pete.