Skip to content

Instantly share code, notes, and snippets.

@hatsunea
Created July 6, 2022 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hatsunea/77e35339bd2b7b120ed670a8061c072b to your computer and use it in GitHub Desktop.
Save hatsunea/77e35339bd2b7b120ed670a8061c072b to your computer and use it in GitHub Desktop.
void loop() {
if (hasWifi && hasIoTHub)
{
if (messageSending &&
(int)(millis() - send_interval_ms) >= INTERVAL)
{
// Send teperature data
char messagePayload[MESSAGE_MAX_LEN];
Pressure = Bmp.readPressure() / 100;
if(Sht30.get()==0) {
Tmp = Sht30.cTemp;
Hum = Sht30.humidity;
}
snprintf(messagePayload, MESSAGE_MAX_LEN, messageData, messageCount++, Tmp, Hum, Pressure);
Serial.println(messagePayload);
EVENT_INSTANCE* message = Esp32MQTTClient_Event_Generate(messagePayload, MESSAGE);
Esp32MQTTClient_SendEventInstance(message);
send_interval_ms = millis();
}
else
{
Esp32MQTTClient_Check();
}
}
delay(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment