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:
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?
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.
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 (Which is also the answer to your last question)
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
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.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?
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!
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?
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.