Particle.Publish - Complete Weather Information

So please excuse my stupid question and be gentle. :slight_smile: I am but a lowly sales puke learning Particle. :slight_smile:

So I am taking this example and want to instead of printing to a serial port, send as the data in a Particle Publish command.

What is the correct syntax or the easiest way to do this?

void loop()
{
      //Get readings from all sensors
      getWeather();

/*This math looks at the current time vs the last time a publish happened
      if(millis() - lastPrint > 5000) //Publishes every 5000 milliseconds, or 5 seconds
      {
        // Record when you published
        lastPrint = millis();

        // Use the printInfo() function to print data out to Serial
        printInfo();
*/        
        Particle.publish("Weather", getWeather(), 60, PRIVATE);
      }
}
1 Like

So @david showed me the errors of my ways. :slight_smile:

    String myWeather = String::format("Temp: %f, Humidity: %f, Pressure: %f hPa", tempf, humidity, pascals/100);
    Particle.publish("getWeather()", myWeather);