Hardcode an ip into sketch for connecting to Blynk server

I have migrated to another country and this has caused my Blynk projects controlling various Photons to not connect. Has anyone had a similar issue?
Do to a DNS problem i now use a static ip to connect to Blynk server. How do I do this also in Particle Sketch?

Have a look at setting a static ip in the documents in the wifi section.

I have read through the Particle and Blynk docs. Still having trouble connecting the Particle Photon to the cloud.
This has all started since I moved to another country. I had to use a static ip to connect blynk app to server.
The only way Photon connects to cloud is in safe mode.
Trying to connect to blynk server in my opinion is pointless since the Photon cant even connect to Particle Cloud.
Don’t know where to start from.

#include <blynk.h>
char auth[] = "xxxxxxxxxxxxxxxxxx";  //Demo
//char server[] = "45.55.96.146";

#define SS_PIN A2
#define RST_PIN D2


MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

WidgetLCD lcd(V7);             // Blynk LCD Widget pin V7 LCD
WidgetLCD lcd2(V8);            // Blynk LCD Widget pin V5 LCD

Servo myServo;  
#define A45 V1                 // 45 button V1
#define B90 V2                 // 90 button V2
#define C135 V6                // 135 button V6
#define readValue V5           // read Servo Angle Labeled Display V5
#define BLYNK_PRINT Serial

const int servoPin = D3;       // servo connected to pin D3 on Photon

void setup() {
    Serial.begin(9600);        // Initialize serial communications with the PC
   //Blynk.config(auth, IPAddress(45,55,96,146));
    
    Blynk.begin(auth);
    myServo.attach(servoPin);  // attaches the servo on pin D1 to the servo object
    myServo.write(10);         // Sets Sservo Position to 10 due to jittering at 0degrees
    
    lcd.clear();
    lcd.print(0, 0, "Initialising");
    lcd.print(0, 1, "Please wait.");
    delay(1000);
    lcd.print(0, 1, "Please wait...");
    delay(1000);
    lcd.print(0, 1, "Please wait.....");
    delay(1000);
    lcd.clear();
    lcd.print(0, 0, "Door is");
    lcd.print(0, 1, "-----LOCKED-----");
    lcd2.print(0, 0, "Please present");
    lcd2.print(0, 1, "security pass");
    delay(1000);

  
    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV8);
    
  mfrc522.setSPIConfig();
  mfrc522.PCD_Init(); // Init MFRC522 card

  RGB.control(true); // take control of onboard RGB led
  //Serial.println("Place your security pass near reader...");
}

BLYNK_READ(readValue)
{
Blynk.virtualWrite(readValue, (myServo.read() - 10));  // Push Mode sends value instantly
}

BLYNK_WRITE(A45)                                   //Set angle at 45degrees
{
    int status1 = param.asInt();
    
    if (status1 == 1)
    {
         myServo.write(55);
    
    }
    else if (status1 == 0)
    {
         myServo.write(10);
    }
}

BLYNK_WRITE(B90)                                   //Set angle at 90degrees
{
    int status2 = param.asInt();
    
    if (status2 == 1)
    {
         myServo.write(100);
    
    }
    else if (status2 == 0)
    {
         myServo.write(10);
    }
}

BLYNK_WRITE(C135)                                  //Set angle at 135degrees
{
    int status3 = param.asInt();
    
    if (status3 == 1)
    {
         myServo.write(145);
    
    }
    else if (status3 == 0)
    {
         myServo.write(10);
    }
}

void blinkGreen() {
  
  RGB.color(0, 255, 0);
  delay(150);
  RGB.color(0, 0, 0);
  delay(150);
  RGB.color(0, 255, 0);
  delay(150);
  RGB.color(0, 0, 0);
  
  }

void blinkRed() {
  RGB.color(255, 0, 0);
  delay(150);
  RGB.color(0, 0, 0);
  delay(150);
  RGB.color(255, 0, 0);
  delay(150);
  RGB.color(0, 0, 0);
  
 }
 
void loop() {
     Blynk.run();
     RGB.color(255, 0, 0);
  // Look for new cards
  if ( mfrc522.PICC_IsNewCardPresent()) {
    // Serial.println("New card present...");
    if ( mfrc522.PICC_ReadCardSerial()) {
      // Dump debug info about the card. PICC_HaltA() is automatically called.
      //mfrc522.PICC_DumpToSerial(&(mfrc522.uid));

      String UID = "";
      

      for (byte i = 0; i < mfrc522.uid.size; i++) {
        //UID += String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : "");
        //UID += String(mfrc522.uid.uidByte[i], HEX);
        UID.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
        UID.concat(String(mfrc522.uid.uidByte[i], HEX));
      }
      
      mfrc522.PICC_HaltA();
      //Serial.print("UID: "); //----------------------------------------------------------------------------
      //Serial.println(UID);   //----------------------------------------------------------------------------
      //delay(500);            //----------------------------------------------------------------------------
      //blink(); // visual feedback of read using onboard led
      
UID.toUpperCase();

if (UID.substring(1) == "04 83 26 02 84 46 80") //change here the UID of the card/cards that you want to give access
  { 
      /*
    Serial.println();  
    Serial.println("Welcome back Nick...  Access is Granted.");
    Serial.println();
    Serial.println("           Door is now open");
    Serial.println();
    Serial.println("========================================");
    Serial.println();
     
    Serial.println();
    Serial.println();
    Serial.println("Place your security pass near reader...");
    Serial.println();
    */
      blinkGreen();
      lcd.clear();
      lcd.print(0, 0, "UID:");
      lcd.print(0, 1, UID);
      delay(1000);
      lcd.clear();
      lcd.print(0, 0, "Door is");
      lcd.print(0, 1, "----UNLOCKED----");
      lcd2.clear();
      lcd2.print(0, 0, "Welcome Nick...");
      lcd2.print(0, 1, " Access Granted ");
      Blynk.virtualWrite(readValue, 90);
      myServo.write(100);
      delay(3000);
      lcd.clear();
      lcd2.clear();
      lcd.print(0, 0, "Door is");
      lcd.print(0, 1, "-----LOCKED-----");
      lcd2.print(0, 0, "Please present");
      lcd2.print(0, 1, "security pass");
      myServo.write(10);
      RGB.color(255, 0, 0);
      
      
  }

  
  
  else if (UID.substring(1) == "85 08 06 AB") //change here the UID of the card/cards that you want to give access
  { 
      /*
    Serial.println();
    Serial.println("Welcome back Elena...  Access is Granted.");
    Serial.println();
    Serial.println("           Door is now open");
    Serial.println();
    Serial.println("=========================================");
    Serial.println();
     
    Serial.println();
    Serial.println();
    Serial.println("Place your security pass near reader...");
    Serial.println();
    */
      blinkGreen();
      lcd.clear();
      lcd.print(0, 0, "UID:");
      lcd.print(0, 1, UID);
      delay(1000);
      lcd.clear();
      lcd.print(0, 0, "Door is");
      lcd.print(0, 1, "----UNLOCKED----");
      lcd2.clear();
      lcd2.print(0, 0, "Welcome Elena...");
      lcd2.print(0, 1, " Access Granted ");
      Blynk.virtualWrite(readValue, 45);
      myServo.write(55);
      delay(3000);
      lcd.clear();
      lcd.print(0, 0, "Door is");
      lcd.print(0, 1, "-----LOCKED-----");
      lcd2.clear();
      lcd2.print(0, 0, "Please present");
      lcd2.print(0, 1, "security pass");
      myServo.write(10);
      RGB.color(255, 0, 0);
  }

  else   {
      blinkRed();
      myServo.write(10);
      lcd.clear();
      lcd.print(0, 0, "UID:");
      lcd.print(0, 1, UID);
      delay(1000);
      lcd2.clear();
      lcd2.print(0, 0, "Unauthorised....");
      lcd2.print(0, 1, " ACCESS DENIED ");
      delay(2000);
      lcd.clear();
      lcd2.clear();
      lcd2.print(0, 0, "Please present");
      lcd2.print(0, 1, "security pass");
      RGB.color(255, 0, 0);
     
      } 
     
    }
  }
}

Managed to connect Particle Photons with Blynk Cloud with the following.

char auth[] = "××××××××××××××××××××";
char server[] = "45.55.96.146:8443";

Blynk.begin(auth, server);

Mark as solved.

1 Like

Thank you for posting your solution!