@ScruffR I knew you would come to the rescue
I didn’t leave any of the Particle.publish code I tried in there since it didn’t work and I wanted to ideally just ask for help and start over and quit wasting what little spare time I have at the moment. I looked at the docs and it only confused me more. Just saying I tried before asking for help.
So breaking down your code real quick here is how I interpret it:
// both readings in one event
Particle.publish("rwbAmbient", String::format("t=%d;h=%d\%", temp_f, humidity));
Particle.publish sets up the publish even with the cloud.
“rwbAmbient” is the name of the published event that I will need to listen for when trying to receive the published events.
String
the next line is where we indicate the data format? And it looks like this is where we can format the data before its sent out also which is what the format("t=%d;h=%d\%", temp_f, humidity));
line does.
So I added your code in the main loop. So this should be working now I’m assuming.
// This #include statement was automatically added by the Spark IDE.
#include "SHT1x/SHT1x.h"
// Specify data and clock connections and instantiate SHT1x object
#define dataPin D0
#define clockPin D1
SHT1x sht1x(dataPin, clockPin);
int temp_f;
int humidity;
int LED = D7;
void setup()
{
pinMode(LED, OUTPUT);
Serial.begin(9600); // Open serial connection to report values to host
Serial.println("Starting up");
}
void loop()
{
//float temp_f;
//float humidity;
// Read values from the sensor
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();
Particle.publish("Ambient", String::format("t=%d;h=%d\%", temp_f, humidity));
// Print the values to the serial port
Serial.print("Temperature: ");
Serial.print(temp_f, 1);
Serial.print("F. Humidity: ");
Serial.print(humidity);
Serial.println("%");
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW);
delay(500);
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW);
delay(2000);
}
I’m trying to get these published events to show up using the Spark Node in Node Red but I can’t seem to get it working. Below is a screen shot of the settings I’m trying to use to pull in these Published events.
I’ve played with the Name and Parameter boxes by leaving one blank and the other one filled out but I still get no output in the debug window.
What is the easiest way to test that this Particle.publish function is spitting this temp and humidity data out?