Simple code error compiling

Hi everyone,
I just got my Particle Photon and I am currently trying to run a simple program. I have a local Blynk server running on my Raspberry Pi. I was trying to verify a simple code but ran into an error when verifying the code on Particle’s web IDE. Here is the code some numbers/letter have been filled with ‘X’:

// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"
     
char auth[] = "8b87948ea2174237abd584c6760XXXXX";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth,"MyAccespoint","AcesspointPassword", IPAddress(192,168,0,XXX));
  pinMode(D0, OUTPUT);
}

void loop()
{
    Blynk.run();    
}

And the error I’m getting is this:

In file included from blynk/BlynkSparkCore.h:16:0,
                 from blynk/BlynkSimpleSparkCore.h:14,
                 from blynk/blynk.h:2,
                 from garage.cpp:2:
blynk/BlynkApiSparkCore.h:74:6: warning: #warning "analogInputToDigitalPin not defined => Named analog pins will not work" [-Wcpp]
     #warning "analogInputToDigitalPin not defined => Named analog pins will not work"
      ^
garage.cpp: In function 'void setup()':
garage.cpp:11:72: error: no matching function for call to 'BlynkSparkCore::begin(char [33], const char [6], const char [15], IPAddress)'
 char auth[] = "8b87948ea2174237abd584c6760XXXXX";
                                                                        ^

garage.cpp:11:72: note: candidates are:
In file included from blynk/BlynkSimpleSparkCore.h:14:0,
                 from blynk/blynk.h:2,
                 from garage.cpp:2:
blynk/BlynkSparkCore.h:78:10: note: void BlynkSparkCore::begin(const char*, const char*, uint16_t)
     void begin( const char* auth,
          ^
blynk/BlynkSparkCore.h:78:10: note:   candidate expects 3 arguments, 4 provided
blynk/BlynkSparkCore.h:87:10: note: void BlynkSparkCore::begin(const char*, IPAddress, uint16_t)
     void begin( const char* auth,
          ^
blynk/BlynkSparkCore.h:87:10: note:   candidate expects 3 arguments, 4 provided
make[1]: *** [../build/target/user/platform-6garage.o] Error 1
make: *** [user] Error 2

Any help or input is greatly appreciated thanks!

Hello!

If you have your particle already connected to WIFI, you need only Blynk.begin(auth);

I made a two door garage controller with photon and my code is here below.



// Garage door controller, using BLYNK and Particle photon
// *******************************************************
// Inputs if doors are open or not... ...micro switches
// Small door D1 => info about state to led widget on V1
// Big door D2 => info about state to led widget on V2
//
// relays are connected as following:
// Lights D5 (switch button widget)
// Small door D6 (push button widget)
// Big door D7 (push button widget)
//
// ********************************************************
// This #include statement was automatically added by the Particle IDE.
#include "SparkCorePolledTimer/SparkCorePolledTimer.h"
// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"

// Timer is needed to check state of the doors. We read the state 1 second intervals.
SparkCorePolledTimer updateTimer(1000);  //Create a timer object and set it's timeout in milliseconds 
void OnTimer(void);   //Prototype for timer callback method 
char auth[] = "69bc53daa33b4984935437e88a7c1f40";

WidgetLED led1(1); // widget for small door
WidgetLED led2(2); // widget for big door
int smallState = LOW; // small doors switch state
int bigState = LOW; // big doors switch state 

void setup() 
{
  Serial.begin(9600);
  Blynk.begin(auth);
//  while (Blynk.connect() == false) { }     // Wait until connected
  updateTimer.SetCallback(OnTimer); 
  pinMode(D1, INPUT); //is the small door open?
  pinMode(D2, INPUT); //is the big door open?
  pinMode(D5, OUTPUT); //relay for lights
  pinMode(D6, OUTPUT); //relay for small door
  pinMode(D7, OUTPUT); //relay for big door
}


void loop()
{
    Blynk.run();
    updateTimer.Update(); 
}

void OnTimer(void) {  //Handler for the timer, will be called automatically 
// check digital inputs of doors & set their values into variables
smallState = digitalRead(D1);
bigState = digitalRead(D2);

smallState = LOW; // setting these manually anyway for testing purposes...
bigState = HIGH;

  if (smallState == LOW) {
    led1.on();
  } else {
    led1.off();
  }
  if (bigState == LOW) {
    led2.on();
  } else {
    led2.off();
  }
}

Hi Saastamo,
Thank you for the response. With your help I no longer have the error codes but it seems that my Blynk application does not communicate with my Particle Photon. I was looking at the logs on my Blynk local server and I am receiving the commands from my Blynk app. So i’m curious on how the Particle photon knows whether to use the Blynk server online or to use my local Blynk server.

Look here https://github.com/blynkkk/blynk-server#app-and-sketch-changes

Hey, everyone I finally got it working. Here is what I had to do.

For my local server running on my Raspberry Pi you will need to set the Blynk App to run on the IP of the Raspberry Pi with port 8443. Now for the code.

// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"
  
char auth[] = "8b87948ea2174237abd584c676XXXXXX";

IPAddress server_ip (192, 168, 0, 105);

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, server_ip, 8442);
  pinMode(D0, OUTPUT);
}

void loop()
{
    Blynk.run();    
}

The key part in this code is this line:

Blynk.begin(auth, server_ip, 8442);

so it’s the AUTH TOKEN you get from your application, the server ip of your Blynk server and the hardware port. Take note the application port is 8443 and the hardware port for your Particle Photon sketch is 8442