Photon can't connect to wireless router using local server

Hello,

I have been using a particle photon with a Blynk local server on a raspberry pi. Connection is done by my local wireless router. Everything works fine until I disconnect my internet connection. I assume when using a raspberry pi as a Blynk local server you should be able to use a photon without internet connection. To sum up:

Anybody an idea what is wrong? Should my wireless router be set to a different mode like WISP?

Thanks in advance,
Bart

Your Photon is apparently trying to connect to the cloud, which it obviously can’t reach. As such, it’ll go into blinking Cyan. To disable the Cloud features, look into the System Modes.

Hello,

If I look at your suggestion I don’t see a solution. What I want to do is connect to a local Blynk server (on a raspberry pi) through a wireless network. If I would use Semi-automatic of manual mode the photon will on execute its offline code. But connecting to the Blynk server is not offline, it is within my own network.

I think the question is as follows: can you use a particle photon in a wireless network without connection to the cloud? If my wireless network in connected to the internet the photon can login to the network en communicate with my local Blynk server. Once the internet connection is disabled the photon stops working.

Is there a way to get photon working in a wireless network without connection to the cloud?

Greetings,
Bart

The manual system mode is essentially the “don’t automatically connect to the cloud” mode. That should enable you to work without even attempting to connect to the Particle cloud. But the Particle cloud is only one service that you might want from the Internet.

How are you connecting to your local Blynk server? By IP address? By name? If the router’s internet connection is down, I would bet that it can no longer answer DNS name queries so you will not be able to get to it by name, only IP address. Have you configured a local static IP address for the Blynk server?

Can any other host, such as a laptop, connect to the Blynk server when the router’s internet is down? That would be a good test.

1 Like

My answer remains exactly the same.
Being connected to a local network does not mean it’s ‘online’. Being online implies a connection to the internet. As such, a blynk server on your local network is most definitely “offline”. To establish a connection to the Cloud, you need internet access. If it doesn’t have that, it will keep trying to connect and block your code while doing so.
To prevent it from continuously looking for a Cloud connection, look into System modes :wink: (Which is also the answer to your last question)

2 Likes

To add to the comments of @bko and @Moors7, non-AUTOMATIC system modes can still be cloud connected, or only WiFi connected or completely untethered.
The degree of connectivity is at your own discretion and control.

In connection with SYSTEM_MODE() you may want to read up on WiFi.connect(), Particle.connect() and their relatives to get a full picture to avoid misinterpretations like

2 Likes

Hello,

Thanks for the quick and useful reply. I think I am getting closer. I am 100% sure there is no problem with the local blynk server, my particle program or the wireless rouer since everything works fine when the wireless router has internet connection. Form the moment I disconnect the internet connection the photon won’t connect due to not being able to connect to the cloud.

I have left my setup the same (with internet connection) and try to get my program running without the photon connecting to the cloud. I have added the following to my code:

  • SYSTEM_MODE(SEMI_AUTOMATIC); ->added just before “void setup()”
  • WiFi.on();
    WiFi.connect(); -> added just after “void loop()”

I would think that would solve it but now the photon-LED blinks very slowly green but I don’t know what this means. It doesn’t seem to be a mode I can find in the documentation. Below you can find my code. Do you know what I am doing wrong?

Thanks for all the help,
Bart

 #include "blynk/blynk.h"
 #define BLYNK_PRINT Serial
 #include "blynk/blynk.h"

char auth[] = "e83de3428cff41bf9f63b3aa3fc89578";
IPAddress server_ip (192,168,0,100);

int ledPin = D7;
Servo motor;
Servo actuator;
Servo grijper;
Servo vlag;

SYSTEM_MODE(SEMI_AUTOMATIC);

void setup()
{
    Serial.begin(9600);
    Blynk.begin(auth, server_ip, 8442);
    vlag.attach(D3);
    grijper.attach(D2);
    actuator.attach(D1);
    motor.attach(D0);
}

void loop()
{
  WiFi.on();
  WiFi.connect();
  Blynk.run();

  if (digitalRead(D5)==HIGH)
   {
        vlag.write(133);
        digitalWrite(ledPin, HIGH);
    }
    else
    {
        vlag.write(0);
        digitalWrite(ledPin, LOW);
    }
}

BLYNK_WRITE(V1)
{
  motor.writeMicroseconds(param.asInt());
}
BLYNK_WRITE(V2)
{
  actuator.writeMicroseconds(param.asInt());
}
BLYNK_WRITE(V3)
{
  grijper.writeMicroseconds(param.asInt());
}

Every time the device runs through loop() it will now try to fire Wifi.on(). You should probably do that in setup instead or at least check if a wifi connection exists before trying to make one again.

2 Likes

Hello,

Of course, rather stupid of me. Now it works without internet connection. Thank you very much! And I must say: Great product!!!
As a teacher electrical engineering I hope to use this device in future lessons!

Greetings,
Bart

1 Like

One final question. Suppose you want the photon to execute offline code and connect to the cloud once there is an internet connection. Can this be done for instance by executing every 5 seconds “Particle.connect();” in semi_automatic mode? Or will this result in the photon to stay in trying to connecting to the cloud and thus no longer execute the offline code as long as there is no internet connection?

Greetings,
Bart

To decouple the system (cloud) stuff from your application code, you may want to consider using SYSTEM_THREAD(ENABLED).
And you don’t want to try every 5 seconds (one attempt may even take longer than that) and just have the connection attempts hang around forever.
You start an attempt and if you couldn’t get a connection within due time, you should finish the attempt by explicitly calling WiFi.disconnect() or even WiFi.off()

This response doesn’t indicate what worked. Could you please add a final post (or alter the original) so that we know what the solution is? I’m also trying to get my Photon to play nice on the LAN and resolve local servers without resorting to external routing and port forwarding.

Thanks. I see now that even though the WiFi radio is clearly already on and connected, the call to WiFi.connect() gets you onto the LAN.