Particle Dev vs. Particle Build = Different Results [RESOLVED]

How can I tell what version firmware the Particle Dev is compiling with?

I successfully compiled the code below for Photon using the Particle Dev and then successfully flashed it a Photon. The Photon connects and breathes cyan, but the code does not run as I get no output text via the serial monitor.

I upload this same code via the Particle Build online for firmware 0.5.3, and the code works just fine.

The Photon had firmware 0.5.3 from the start.

Here is the code if it’s needed:

 called once on startup
void setup() {
    // For simplicity, we'll format our weather data as text, and pipe it to serial.
    // but you could just as easily display it in a webpage or pass the data to another system.

    // Learn more about the serial commands at https://docs.particle.io/reference/firmware/photon/#serial
    //  for the Photon, or https://docs.particle.io/reference/firmware/core/#serial for the Core
    // You can also watch what's sent over serial with the particle cli with
    //  particle serial monitor
    Serial.begin(115200);

    // Lets listen for the hook response
    Particle.subscribe("hook-response/WeatherFishersIN", gotWeatherData, MY_DEVICES);
    Particle.subscribe("hook-response/SunFishersIN", gotSunData, MY_DEVICES);

    // Lets give ourselves 10 seconds before we actually start the program.
    // That will just give us a chance to open the serial monitor before the program sends the request
    for(int i=0;i<10;i++) {
        Serial.println("waiting " + String(10-i) + " seconds before we publish");
        delay(1000);
    }
}


// called forever really fast
void loop() {

    // Let's request the weather, but no more than once every 60 seconds.
    Serial.println("");
    Serial.println("-------------------");
    Serial.println("Requesting Weather!");
    Serial.println("");
    // publish the event that will trigger our Webhook
    //Particle.publish("FishersWeather");
    Particle.publish("WeatherFishersIN");
    delay(250);
    Particle.publish("SunFishersIN");

    // and wait at least 60 seconds before doing it again
    delay(60000 * 5 );
}

// This function will get called when weather data comes in
void gotWeatherData(const char *name, const char *data) {
    // Important note!  -- Right now the response comes in 512 byte chunks.
    //  This code assumes we're getting the response in large chunks, and this
    //  assumption breaks down if a line happens to be split across response chunks.
    //
    // Sample data:
    //  <location>Minneapolis, Minneapolis-St. Paul International Airport, MN</location>
    //  <weather>Overcast</weather>
    //  <temperature_string>26.0 F (-3.3 C)</temperature_string>
    //  <temp_f>26.0</temp_f>


    String str = String(data);
    String locationStr = tryExtractString(str, "<Location>", "</Location>");
    String timeStr = tryExtractString(str, "<Time>", "</Time>");
    String weatherdiscriptionStr = tryExtractString(str, "<WeatherDescription>", "</WeatherDescription>");
    String tempStr = tryExtractString(str, "<Temp>", "</Temp>");
    String humidityStr = tryExtractString(str, "<Humidity>", "</Humidity>");
    String windStr = tryExtractString(str, "<Wind>", "</Wind>");
    String heatindexStr = tryExtractString(str, "<HeatIndex>", "</HeatIndex>");
    String windchillStr = tryExtractString(str, "<WindChill>", "</WindChill>");
    String feelslikeStr = tryExtractString(str, "<FeelsLike>", "</FeelsLike>");
    String visibilityStr = tryExtractString(str, "<Visibility>", "</Visibility>");
    String sunradiationStr = tryExtractString(str, "<SunRadiation>", "</SunRadiation>");
    String uvindexStr = tryExtractString(str, "<UvIndex>", "</UvIndex>");
    String totalrainStr = tryExtractString(str, "<TotalRainInches>", "</TotalRainInches>");
    String iconStr = tryExtractString(str, "<Icon>", "</Icon>");




    if (locationStr != NULL) {
        Serial.println("Weather for: " + locationStr);
    }

    if (timeStr != NULL) {
        Serial.println("Timestamp: " + timeStr);
    }

    if (weatherdiscriptionStr != NULL) {
        Serial.println("Weather Conditon: " + weatherdiscriptionStr);
    }

    if (tempStr != NULL) {
        Serial.println("The Temp is: " + tempStr + String(" F"));
    }

     if (feelslikeStr != NULL) {
        Serial.println("The Real Feel Temp is: " + feelslikeStr + String(" F"));
    }

     if (humidityStr != NULL) {
        Serial.println("The Humidity is: " + humidityStr );
    }

     if (windStr != NULL) {
        Serial.println("Wind Conditions: " + windStr);
    }

     if (heatindexStr != NULL) {
        Serial.println("The Heat Index is: " + heatindexStr + String(" F"));
    }

     if (windchillStr != NULL) {
        Serial.println("The Wind Chill Index is: " + windchillStr + String(" F"));
    }

    if (visibilityStr != NULL) {
        Serial.println("The Visibility is: " + visibilityStr + String(" Miles"));
    }

     if (sunradiationStr != NULL) {
        Serial.println("The Solar Radiation is: " + sunradiationStr + String(" W/m2"));
    }

    if (uvindexStr != NULL) {
        Serial.println("The UV Index is: " + uvindexStr );
    }

     if (totalrainStr != NULL) {
        Serial.println("Total Daily Rain Fall: " + totalrainStr + String(" Inches"));
     }

     if (iconStr != NULL) {
        Serial.println("Icon for current weather: " + iconStr);
     }



}



// This function will get called when weather data comes in
void gotSunData(const char *name, const char *data) {
    // Important note!  -- Right now the response comes in 512 byte chunks.
    //  This code assumes we're getting the response in large chunks, and this
    //  assumption breaks down if a line happens to be split across response chunks.
    //
    // Sample data:
    //  <location>Minneapolis, Minneapolis-St. Paul International Airport, MN</location>
 https://build.particle.io/build/5714505f328841b54e0002c2#   //  <weather>Overcast</weather>
    //  <temperature_string>26.0 F (-3.3 C)</temperature_string>
    //  <temp_f>26.0</temp_f>


    String str = String(data);
    String sunrisehourStr = tryExtractString(str, "<SunriseHour>", "</SunriseHour>");
    String sunriseminuteStr = tryExtractString(str, "<SunriseMin>", "</SunriseMin>");
    String sunsethourStr = tryExtractString(str, "SunsetHour>", "</SunsetHour>");
    String sunsetminuteStr = tryExtractString(str, "<SunsetMinute>", "</SunsetMinute>");

    uint hourofsunset = sunsethourStr.toInt();
    int adjsunsethour = (hourofsunset-12);


    if (sunrisehourStr != NULL) {
        Serial.println("Sunrise at: " + sunrisehourStr + String(":") + sunriseminuteStr + String(" AM") + " / Sunset at: " + adjsunsethour + String(":") + sunsetminuteStr + String(" PM"));
    }






    Serial.println("-------------------");
    Serial.println("");


}

// Returns any text found between a start and end string inside 'str'
// example: startfooend  -> returns foo
String tryExtractString(String str, const char* start, const char* end) {
    if (str == NULL) {
        return NULL;
    }

    int idx = str.indexOf(start);
    if (idx < 0) {
        return NULL;
    }

    int endIdx = str.indexOf(end);
    if (endIdx < 0) {
        return NULL;
    }

    return str.substring(idx + strlen(start), endIdx);
}

One possible reason might be that you didn’t actally build that code (that’s a Dev speciality).
I usually try deliberately adding a syntax error and see if the build fails - if not, I’m building the wrong project.

How are you flashing the binary?

Here is what Particle Dev looked like after I hit the compile and upload button.

So how do I set which code get’s compiled?

What do the blue lines mean next to the folders or open tab’s like shown below?

You can only have one main file (containing setup() and loop()) in your project folder and any subfolders of it.
It’s not the file you’re editing that matters but the project folder you’ve selected.

I think that is what happened :smile:

I see that one of the folders will have a blue line to the left of the folder but I can’t figure out how to pick which folder I want to compile against. How do you choose a folder?

I usually do it via the File menu Open Folder …

Same here but there is no indication that it has selected that folder for compiling.

The blue line beside the folder does not change to the folder I just opened using the File menu Open Folder either.

I just figured that blue line to the left of the folder is what identifies which folder is selected for compiling. Or maybe the blue line means something completely different? Who should we ask to find out?

That screenshot does not look as if you actually opened the final branch of your tree which doesn’t contain any nested projects. When opening a new folder I get a new instance of Atom/Dev opened and the old one still hangs around - maybe that’s happened for you too - have another look.
After doing it right you should only see Weather Status Via Webhook and its - and only its - contents in the tree view.

BTW, try not to use blanks in your directory and file names. I know it’s possible, but some tools don’t like them - so I’d always go for camelCase and absolutely avoid blanks (and non ASCII chatacters - in German we’d have some but still) in file names.

1 Like

Yea that worked. I right clicked on that Weather Status Via Webhook folder and selected Open In New Window

Then it opened a new Atom window with only the Weather Status Via Webhook folder as shown below:

All is good now :smiley:

Good advice! I’ll change that.

2 Likes