Error flashing Code to Boron

I have this code, I have been flashing to my electrons. And the code always works. But recently, I purchased borons, and tried to flash the same code from the web IDE as I do all the time. I’m getting a weird error. I have a hunch that maybe the boron has different development parameters I didn’t consider because the code works for the electrons and not the borons. Here is my code:

const int trigPin = D2;
const int echoPin = D6;

int tempC;
int analogvalue;
int aString;
// defines variables
long duration;
double distance;

String inWord;
char inByte;
String data;
int LockLED = D1;  

void setup() {
    Particle.variable("distance", &distance, DOUBLE);
    Particle.variable("duration", &duration);
    Particle.variable("analogvalue", &analogvalue, INT);
    pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
    pinMode(echoPin, INPUT); // Sets the echoPin as an Input
    Serial.begin(9600); // Starts the serial communication
    // cloud variable
    Particle.variable("GPS", data);
    // GPS Serial
    pinMode(LockLED, OUTPUT);
    digitalWrite(LockLED, HIGH);
    digitalWrite(LockLED, LOW);
    //String data = String(10);
  // Trigger the integration
    //Particle.publish("distance", data, PRIVATE);
  // Wait 60 seconds


void loop() {

    // Clears the trigPin
    digitalWrite(trigPin, LOW);
    // Sets the trigPin on HIGH state for 10 micro seconds
    digitalWrite(trigPin, HIGH);
    digitalWrite(trigPin, LOW);
    // Reads the echoPin, returns the sound wave travel time in microseconds
    duration = pulseIn(echoPin, HIGH);
    //analogvalue = addition(distance + 0);
    // Calculating the distance
    distance= duration*0.034/2;
    // Prints the distance on the Serial Monitor
    Serial.print("Distance: ");
    Particle.publish("distance", String(distance), PRIVATE);

    analogvalue = 129;
     while (Serial1.available() > 0) {
        inByte =;
        if (inByte == '\n') {
            // END OF LINE
            Serial.print("inWord: ");
            // check is data we want
            // you can change this to get any data line values
            if (inWord.startsWith("$GPRMC")) {
                // put data string in variable
                data = inWord;
                Serial.print("data: ");
                Particle.publish("GPS", String(data), PRIVATE);
                digitalWrite(LockLED, HIGH);
                digitalWrite(LockLED, LOW);
                // clear the inword variable
                inWord = "";
                // does the GPS Receiver have lock?
                // get the char at pos 17 and test to see if it is an A i.e VALID, V = INVALID
                char lock = data.charAt(17);
                Serial.print("lock: ");
                if (lock == 'A') {
                    // YES Switch on Lock LED
                    digitalWrite(LockLED, HIGH);
                } else {
                    // NO turn off lock led
                    //digitalWrite(LockLED, LOW);  
            } else {
                // clear the inword variable as not the data we want
                inWord = "";
        } else {
            // build data string
            inWord += inByte;   
    } // end if serial

long microsecondsToCentimeters(long microseconds) {
   return microseconds / 29 / 2;

The error I get is :

../wiring/inc/spark_wiring_cloud.h:108:91: no type named 'type' in 'struct std::enable_if<false, std::nullptr_t>'
../wiring/inc/spark_wiring_cloud.h:435:103: no type named 'type' in 'class std::result_of<long int*()>'

I’m quite new to particle in general, so your help will be appreciated.

Have you double checked that this code actually works on Electrons with the same device OS target as your Boron?

The first indication for (years ago) deprecated syntax is here

This would be written today as

    Particle.variable("distance", distance);
    Particle.variable("duration", duration);
    Particle.variable("analogvalue", analogvalue);

BTW, on these devices int and long are actually the same thing :wink:
Also if you look at the SHOW RAW output of Web IDE compiling this code for either Boron or Electron you’d get some more elaborate info about the issue which may point you at the actual place of the problem in your code.

1 Like

Thanks man! I checked the device target issue and it does turn out it was different on the electron. My hunch is I did a particle update on the boron, but I’ve never done it on any of my five electrons. So the deprecated code works on the old electron firmware but doesn’t on the updated firmware boron. In any case, changing to the new syntax worked. and the boron was flashed. Thanks for the timely assistance!

1 Like