#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <WiFi.h>
#include <PubSubClient.h>
#define TRIGGER_PIN 12
#define ECHO_PIN 14
#define DISTANCE_THRESHOLD 100
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
const char* mqttServer = "YOUR_MQTT_SERVER";
const int mqttPort = 1883;
const char* mqttUsername = "YOUR_MQTT_USERNAME";
const char* mqttPassword = "YOUR_MQTT_PASSWORD";
const char* topic = "YOUR_TOPIC";
WiFiClient espClient;
PubSubClient client(espClient);
Adafruit_BME280 bme;
void setup() {
Serial.begin(115200);
// Initialize ultrasonic sensor
pinMode(TRIGGER_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status(…