Extract sht31 temp and humidity to publish separately

I've tried for a few days now, but I'm not making any headway (actually getting more confused!) About how to extract the SHT 31 temperature and humidity values from the Edge buffer so I can do a separate publish for those values.

It looks like BackgroundPublish.cpp is the right place for the extra publish, but the SHT temp and humidity are not declared in that scope, so I need to pull them out of the buffer, yes?

Any push in the right direction is greatly appreciated!

Why exactly do you want to publish those values separately? It will increase data operations, and the data won't be stored in the cloud properly if it's not in the loc event in the normal format.

In any case, if you really do need to publish them separately you should do by adding something to loop to periodically use Particle.publish() directly to publish those values not as part of the loc event. Don't use delay() to block loop as that will cause Tracker Edge to not work properly, but probably use a millis() based counter to do it periodically. Leave the loc event and background publish unchanged.

Hi, Rick!

Original Goal:
The goal (and I should have been clearer about that in my first message) is to be able to publish JUST the SHT-31 temp and humidity every hour or so (using a millisec timer, and then use a web hook to send that to an SMS via Pushover. As you said, I want to keep the data usage down to a dull roar. I can likely do that from MAIN.CPP, but no, I don't want to delay / hold anything else up and have the Tracker not work properly, so a timer is likely the best way to go, yes?

First Efforts:
My first approach: I tried first going down the path of trying to parse the JSON buffer in order to pull sht31_temp and sht31_humid directly, and I hit a dead end there. Since backgroundpublish can't see temp and humid (outside of scope), the only to get those values seems to be by peeking into the buffer. This approach would also have the advantage -- if published in backgroundpublish -- of being timed to the publish timing parameters set for the Tracker in the Console. Probably too frequent, but hey, it's fun to try.

Currently:
I'm using Particle.variable to let me see the temp and humidity. Works well, but it requires the Particle app, whereas an SMS is more "universal" through Pushover.

I can also see temp and humidity in the Console for the device, but the Console is a tough way to go on a phone compared to a full-size screen.

I assume you're using the M8 temperature and humidity sensor. In that case, just use the same code that's in myLocationGenerationCallback except generate your payload instead of adding it to the location publish.

You'd put something like this in loop:

static unsigned long lastPublish = 0;
if (Particle.connected() && millis() - lastPublish > 3600000) {
	lastPublish = millis();

	double temp, humid;

    int err = sensor.get_reading(&temp, &humid);
    if (err == 0)
    {
        // Put code to generate the Particle.publish payload here

        Log.info("temp=%.2lf hum=%.2lf", temp, humid);
    }
    else {
        Log.info("no sensor err=%d", err);
    }
}