This was my problem in January 2023. I finally migrated my Particle hobby project to the new Blynk server. It has been about four years since I originally set it up, so I was rusty and had trouble getting my device to connect.
In my case, I don’t use Blynk to connect to WiFi. Instead, I let the Particle device do that.
I deleted my old iPhone Blynk app and started over by installing the new app on my iPhone.
As far as the Particle application goes, I think I really needed very minimal changes.
First, I created a new program(/sketch). Then, I had to add the Blynk library by searching for it (I use the Particle web ide).
However, the key to making it work was to make sure the #define statements were before the #include <blynk.h> statement! This was the key to making it work.
Once that was corrected, and, my auth token updated, my device was recognized as online in the Blynk dashboard. From there, I could configure my Blynk iOS app.
Here’s a brief outline of my code:
#define BLYNK_TEMPLATE_ID "TMPxxx"
#define BLYNK_DEVICE_NAME "Controller"
#define BLYNK_AUTH_TOKEN "xxx"
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
char auth[] = BLYNK_AUTH_TOKEN;
//define other app variables
bool tankFull;
BlynkTimer timer;
BLYNK_CONNECTED()
{
// I commented all of this out. it's an empty function for me
}
void UpdateBlynk()
{
// this function sends data back to Blynk's virtual pins for use in the app
Blynk.virtualWrite(V4, tempF);
if (digitalRead(D3) == HIGH)
Blynk.virtualWrite(V3, 255);
else
Blynk.virtualWrite(V3, 0);
}
void setup()
{
// declare Particle API calls. this is unique to your application
Particle.function("digitalOut", digitalOut);
Particle.variable ("TankFull", tankFull);
pinMode (D3, OUTPUT);
delay(5000); // Allow board to settle
Blynk.config(auth);
timer.setInterval(1000, UpdateBlynk); // call this function every second to update Blynk with status
}
void loop()
{
// define local variables here
byte i; // loop counter
// read Particle inputs -----------------------------------------------------
// process inputs -----------------------------------------------------------
if (analogRead(A1)<100)
tankFull = true;
else
tankFull=false;
// process actions ---------------------------------------------------------
if (digitalRead(D3) == HIGH && tankFull == true) {
Particle.publish ("safety-off", "D3 turned off b/c tank full", PRIVATE);
digitalWrite (D3, LOW);
}
// set/comm outputs --------------------------------------------------------
// display output ----------------------------------------------------------
// call system functions
Blynk.run();
timer.run();
} // main loop