Hey. I’m trying to get my Tracker SoM to publish humidity and temp data to the particle console using this code:
#include "Particle.h"
#include "tracker_config.h"
#include "tracker.h"
#include "./lib/Grove_Temperature_And_Humidity_Sensor/src/Grove_Temperature_And_Humidity_Sensor.h"
#include "./lib/TemperatureHumidityValidatorRK/src/TemperatureHumidityValidatorRK.h"
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);
PRODUCT_ID(TRACKER_PRODUCT_ID);
PRODUCT_VERSION(TRACKER_PRODUCT_VERSION);
SerialLogHandler logHandler(115200, LOG_LEVEL_TRACE, {
{ "app.gps.nmea", LOG_LEVEL_INFO },
{ "app.gps.ubx", LOG_LEVEL_INFO },
{ "ncp.at", LOG_LEVEL_INFO },
{ "net.ppp.client", LOG_LEVEL_INFO },
});
DHT tempSensor(A3);
TemperatureHumidityValidator validator;
// Sample the temperature sensor every 2 seconds. This is done so the outlier values can be filtered out easily.
const unsigned long CHECK_PERIOD_MS = 2000;
unsigned long lastCheck = 0;
void locationGenerationCallback(JSONWriter &writer, LocationPoint &point, const void *context); // Forward declaration
void setup()
{
Tracker::instance().init();
// Callback to add key press information to the location publish
Tracker::instance().location.regLocGenCallback(locationGenerationCallback);
// Initialize temperature sensor
tempSensor.begin();
Particle.connect();
}
void loop()
{
Tracker::instance().loop();
if (millis() - lastCheck >= CHECK_PERIOD_MS) {
lastCheck = millis();
validator.addSample(tempSensor.getTempCelcius(), tempSensor.getHumidity());
Log.info("tempC=%f tempF=%f humidity=%f", validator.getTemperatureC(), validator.getTemperatureF(), validator.getHumidity());
}
}
void locationGenerationCallback(JSONWriter &writer, LocationPoint &point, const void *context)
{
float tempC = validator.getTemperatureC();
if (!isnan(tempC)) {
writer.name("temp").value(tempC, 2);
}
float hum = validator.getHumidity();
if (!isnan(hum)) {
writer.name("hum").value(hum, 1);
}
}
It compiles fine, but I get no output of Humidity or temps on the console or usb serial output. I’m pretty stumped and any help is appreciated!