Very new.
Currently successful at controlling an ultrasonic humidifier based on sensor readings by comparing the sensor value against a global int. Would love to be able to change this variable via particle.function, but I don’t know how. Here’s what I have so far.
//Particle Photon placed in garden to first control humidity, eventually will read sensors,
//spit out data to Thingspeak, and take input for parameters.
//For now, it is keeping humidity in this room at 60% by turning on and off an ultrasonic humidifier based on sensor readings
//Would like to control what the desired RH is via particle.Function
#include "math.h"
#include "adafruit-sht31.h"
int humdisc = D4; //24v ultrasonic disc
int setHumidity =60; //desired %RH
Adafruit_SHT31 sht31 = Adafruit_SHT31();
void setup() {
Serial.begin(115200);
Serial.println("SHT31 test");
Particle.publish("Oh, here we go again"); //following the train, publishing to Particle about it.
if (! sht31.begin(0x44)) { // Copied from sht31test.ino
Serial.println("Couldn't find SHT31");
Particle.publish("All you had to do...."); //bad references
}
pinMode(humdisc, OUTPUT); //wired to relay.
}
void loop() {
double t = sht31.readTemperature();
double h = sht31.readHumidity();
Particle.variable("Temp", t);
Particle.variable("Hum", h);
if (setHumidity > (h)){ //Would like to edit setHumidity from a Particle.function, how do?
digitalWrite(humdisc, LOW);
} else {
digitalWrite(humdisc, HIGH);
}
if (! isnan(t)) { // check if 'is not a number'
//Temperature in C
Serial.print("Temp C = "); Serial.println(t);
} else {
Serial.println("Failed to read temperature");
}
if (! isnan(h)) { // check if 'is not a number'
Serial.print("Hum. % = "); Serial.println(h);
} else {
Serial.println("Failed to read humidity");
}
String output = "T:" + String(t,2) + ",H:" + String(h,2);
Serial.println(output);
Particle.publish("TempHumidity", output, PRIVATE);
delay(5000);
}
Very eager to learn the required vocabulary to articulate what I’m tryna do here. Thanks for any time you spend on this in advance.