[SOLVED] iOS app not receiving writes from Particle Core

Hi all,

I’m having difficulty connecting to my Particle Core devices from my iOS Blynk app. This worked before without issue.

I am always receiving the error "Particle Core is offline" when I run a Blynk project on my iPhone.

These Cores currently work just fine with my IFTTT setups. I can flash them from the particle.io IDE. And, I’m able to login (via a Windows CMD prompt) to the blynk.cc server from within the same intranet as the Cores.

Here’s what I’ve tried so far:

o I reviewed my existing iOS Blynk project and discovered virtual pin assignments for the existing widgets were lost. I re-set them within the project to point the the same functions within the Particle code.

o I refreshed the auth token between iOS app and Particle IDE code.

o I tried three different Particle Core modules.

o I created a brand new Blynk project and used the sample code from the Particle.io IDE.

No luck.

OF NOTE: My DSL provider recently switched from Verizon to another provider and the DNS addresses my home router provides are non-functional. I’ve manually set all my computers and phones to 8.8.8.8 (a Google DNS) and all works fine. If the Particle Cores rely on DNS as part of their communication scheme for Blynk, that might be a point of failure. Again, the Cores have no issues with my IFTTT communications and control.

=========================

Here’s the code for my custom IoT application:

/**************************************************************
 * North Lake Back Yard
 **************************************************************/

//Turn these on for serial debug output
#define BLYNK_DEBUG // Optional, this enables lots of prints
#define BLYNK_PRINT Serial

#include "blynk/blynk.h"
#include "blynk/BlynkSimpleParticle.h"

// You should get Auth Token in the Blynk App.
//char auth[] = "c7667e0f9234494393986793716f09f0";
char auth[] = "263e67ddd4954acd908d9a7a5cbe0faa";

int led1 = D7;
int led2 = D6;
int led3 = D5;
int led4 = D4;
WidgetLCD lcd(20);

void setup()
{
    Serial.begin(9600); //for serial debug output
    
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
    pinMode(led4, OUTPUT);
    delay(5000); // Allow board to settle
    Blynk.begin(auth);
}

BLYNK_WRITE(V0) {
    if (param.asInt() == 1) { // On button down...
        digitalWrite(led1, HIGH);
        Blynk.virtualWrite(V10, 1); //pushes value to Blynk app
        lcd.print(0,0, "PUMP ON   ");
    }
    else {
        digitalWrite(led1, LOW);
        Blynk.virtualWrite(V10, 0); //pushes value to Blynk app
        lcd.print(0,0, "PUMP OFF  ");
    }
}

BLYNK_WRITE(V1) {
    if (param.asInt() == 1) { // On button down...
        digitalWrite(led2, HIGH);
        Blynk.virtualWrite(V11, 1); //pushes value to Blynk app
        lcd.print(0,0, "ZONE 1 ON ");
    }
    else {
        digitalWrite(led2, LOW);
        Blynk.virtualWrite(V11, 0); //pushes value to Blynk app
        lcd.print(0,0, "ZONE 1 OFF");
    }
}

BLYNK_WRITE(V2) {
    if (param.asInt() == 1) { // On button down...
        digitalWrite(led3, HIGH);
        Blynk.virtualWrite(V12, 1); //pushes value to Blynk app
        lcd.print(0,0, "ZONE 2 ON ");
    }
    else {
        digitalWrite(led3, LOW);
        Blynk.virtualWrite(V12, 0); //pushes value to Blynk app
        lcd.print(0,0, "ZONE 2 OFF");
    }
}

BLYNK_WRITE(V3) {
    if (param.asInt() == 1) { // On button down...
        digitalWrite(led4, HIGH);
        Blynk.virtualWrite(V13, 1); //pushes value to Blynk app
        lcd.print(0,0, "ZONE 3 ON ");
    }
    else {
        digitalWrite(led4, LOW);
        Blynk.virtualWrite(V13, 0); //pushes value to Blynk app
        lcd.print(0,0, "ZONE 3 OFF");
    }
}

BLYNK_WRITE(V9) {
    if (param.asInt() > 0) {
        RGB.control(true);
        byte rgb[3];
        HsvToRgb(param.asDouble()/255, 1, 1, rgb);
        RGB.color(rgb[0], rgb[1], rgb[2]);
    } else {
        RGB.control(false);
    }
}

void loop()
{
    Blynk.run();
    
    if (ModeBtnPressed()) {
        //Blynk.notify("Mode button was pressed");
    }
}

// *** Utility functions

bool ModeBtnPressed() {
    if(millis() > 5000) {
        if(BUTTON_GetDebouncedTime(BUTTON1) >= 50) {
            BUTTON_ResetDebouncedState(BUTTON1);
            return 1;
        }
    }
    return 0;
}

void HsvToRgb(double h, double s, double v, byte rgb[]) {
    double r, g, b;

    int i = int(h * 6);
    double f = h * 6 - i;
    double p = v * (1 - s);
    double q = v * (1 - f * s);
    double t = v * (1 - (1 - f) * s);

    switch(i % 6){
        case 0: r = v, g = t, b = p; break;
        case 1: r = q, g = v, b = p; break;
        case 2: r = p, g = v, b = t; break;
        case 3: r = p, g = q, b = v; break;
        case 4: r = t, g = p, b = v; break;
        case 5: r = v, g = p, b = q; break;
    }

    rgb[0] = r * 255;
    rgb[1] = g * 255;
    rgb[2] = b * 255;
}

"I’m having difficulty connecting to my Particle Core devices from my iOS Blynk app. This worked before without issue.

I am always receiving the error “Particle Core is offline” when I run a Blynk project on my iPhone."

Just curious, what version of IOS and Blynk are you running?

What does serial output show?

Interesting. It was showing repeated “connecting to Blynk server” messages. Now, it’s showing nothing.

BTW, I included the authorization token in my code sample so anyone can try out the device. As you can see, it includes responses on channels v10-v13 and an LCD widget.

EDIT: Actually, the auth token should be c7667e0f9234494393986793716f09f0.

As of now, the latest IoS and Blynk app.

[SOLVED]

As I suspected, and reviewed in another thread, my intranet DNS pushed from my DHCP router was the problem.

The DNS addresses were non-functioning for everything else in my house (computers, iPhones.) I fixed that problem by manually setting DNS on each device to 8.8.8.8. But, that doesn’t help with the particle cores. Finally, I went back to the router and found the means to manually set the DNS for the intranet to a working IP.

Now, everything is talking.

[STILL AN ISSUE]

With the update of the DNS, I have my iPhone Blynk app talking to the Particle Core within my intranet. However, the core doesn’t appear to be talking back out to the app.

As you can read in my code, I have some feedback set up to LCD and LED gadgets. I receive no response there.

Hmmm. Here’s the serial debug output from a brief session (for some reason, the Arduino IDE serial monitor won’t let me cut/paste text from the session, hence the snapshot):

The picture looks ok… Are you sure there is an issue?

My photon is similar. App is frozen/not receiving info from photon but my photon is online and happy…i recieve emails and push notifications from my photon but vslue display linked to analog pins and buttons linked to virtual pins etc dont work

Hello Dylan
What I did with my photon is delete the include lib for Blynk and included again in the code and I flash it in my photon it works good now

Thanks… I already tried that😭

I have currently no access to my Core, but I will re-check it as soon as I get it back…

So others can try and test, here’s the QR code of the shared app project.

Yessir. The LED and LCD widgets inside the Blynk app do not respond to those outgoing messages.

Your app is offline for now

Pavel, I’m not sure what being offline means. But, I hit the [play] button in my app. Does that bring it online for others to use?

I can see your app, but LCD is empty and LEDs are idle.
@vshymanskyy, code seems to be ok, right?

Yes. Code is the same that worked before. I saw the LED on the Core come on. I presume that was you. :smiley:

I just flashed the 01_blynk.ino app (with a D7 LED conditional within the V1 function. My iOS phone does not respond to the Blynk.notify() call.

Michael

Hmm. Interesting. I set up the following from the sample code and received one particle.notify() response on my iOS app. Waited a couple minutes, and haven’t seen one again.


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

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "de6dae381be04ad9a85b52964695fa99";
int led1 = D7;

void setup()
{
    Serial.begin(9600);
    delay(5000); // Allow board to settle
    pinMode(led1, OUTPUT);
    Blynk.begin(auth);
}

BLYNK_WRITE(V1) {
    if (param.asInt() == 1) { // On button down...
        digitalWrite(led1, HIGH);
        Blynk.virtualWrite(V10, 1);
    }
    else {
        digitalWrite(led1, LOW);
        Blynk.virtualWrite(V10, 0);
    }

        Blynk.notify("You pressed the button and I know it ;)");
}

RGB led!
BLYNK_WRITE(V2) {
    int r = param[0].asInt();
    int g = param[1].asInt();
    int b = param[2].asInt();
    if (r > 0 && g > 0 && b > 0) {
        RGB.control(true);
        RGB.color(r, g, b);
    } else {
        RGB.control(false);
    }
}

void loop()
{
    Blynk.run();
    
    if (ModeBtnPressed()) {
        Blynk.notify("Mode button was pressed");
    }
}

// *** Utility functions

bool ModeBtnPressed() {
    if(millis() > 5000) {
        if(BUTTON_GetDebouncedTime(BUTTON1) >= 50) {
            BUTTON_ResetDebouncedState(BUTTON1);
            return 1;
        }
    }
    return 0;
}

@Dmitriy, from the log screen-shot above, the board is sending messages correctly, and heartbeat is OK (so communication is alive in both directions).
msg_id is a bit different, because it’s sent in the context of BLYNK_WRITE handler. But this shouldn’t matter.