commit 0dbf1fc658763bf67757ee4b923e658ea0407f7a Author: curtainman Date: Fri Apr 7 23:45:18 2023 -0500 Add collection.ino diff --git a/collection.ino b/collection.ino new file mode 100644 index 0000000..b2ccf51 --- /dev/null +++ b/collection.ino @@ -0,0 +1,151 @@ +#include +#include +#include +#include "sensirion_common.h" +#include "sgp30.h" + +#define WIFISSID "REDACTED" // Put your WifiSSID here +#define PASSWORD "REDACTED" // Put your wifi password here +#define TOKEN "REDACTED" // Put your Ubidots' TOKEN +#define VARIABLE_LABEL1 "voc" // Assign the variable label +#define VARIABLE_LABEL2 "co2" +#define DEVICE_LABEL "co2-monitor-device" // Assign the device label +#define MQTT_CLIENT_NAME "REDACTED" // MQTT client Name + +const long interval = 100; +unsigned long previousMillis = 0; + +char mqttBroker[] = "industrial.api.ubidots.com"; + +WiFiClient wifiClient; +PubSubClient client(wifiClient); + +TFT_eSPI tft = TFT_eSPI(); + +static unsigned short int VOC = 0; +static unsigned short int CO2 = 0; + +// Space to store values to send +char str_voc[6]; +char str_co2[6]; +char payload[700]; +char topic[150]; + +void callback(char* topic, byte* payload, unsigned int length){ + Serial.print("Message arrived ["); + Serial.print(topic); + Serial.print("] "); + for (int i=0;i