Connecting ifttt/adafruit

In file included from c:\Users\pgnan\OneDrive\Documents\Arduino\libraries\libraries\Adafruit_ADXL345/Adafruit_ADXL345_U.h:36,
from C:\Users\pgnan\OneDrive\Desktop\5 PROJECTS\esp32_car_Me\esp32_car_Me.ino:12:
c:\Users\pgnan\OneDrive\Documents\Arduino\libraries\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:10:36: error: 'TwoWire' has not been declared
Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
^~~~~~~
c:\Users\pgnan\OneDrive\Documents\Arduino\libraries\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:30:3: error: 'TwoWire' does not name a type; did you mean 'TwoWire_h'?
TwoWire *_wire;
^~~~~~~
TwoWire_h
c:\Users\pgnan\OneDrive\Documents\Arduino\libraries\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:10:56: error: 'Wire' was not declared in this scope
Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
^~~~
c:\Users\pgnan\OneDrive\Documents\Arduino\libraries\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:10:56: note: suggested alternative: 'WiFi'
Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
^~~~
WiFi
C:\Users\pgnan\OneDrive\Desktop\5 PROJECTS\esp32_car_Me\esp32_car_Me.ino: In function 'void setup()':
C:\Users\pgnan\OneDrive\Desktop\5 PROJECTS\esp32_car_Me\esp32_car_Me.ino:67:3: error: 'Wire' was not declared in this scope
Wire.begin();
^~~~
C:\Users\pgnan\OneDrive\Desktop\5 PROJECTS\esp32_car_Me\esp32_car_Me.ino:67:3: note: suggested alternative: 'WiFi'
Wire.begin();
^~~~
WiFi

exit status 1

Compilation error: 'Wire' was not declared in this scope

#define BLYNK_TEMPLATE_ID "TMPL3srS9Y7ys"
#define BLYNK_TEMPLATE_NAME "IOT EV CAR V 1"
#define BLYNK_AUTH_TOKEN "yBwqUetfEcg2TqzWH5OcYKO8voBcKrNN"

#include <Wire.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#include <MQ135.h> // Include MQ135 library
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
#include <UniversalTelegramBot.h>

char auth[] = "yBwqUetfEcg2TqzWH5OcYKO8voBcKrNN";
char ssid[] = "IOT";
char pass[] = "1230987654321";

int IN1 = 19;
int IN2 = 18;
int IN3 = 5;
int IN4 = 17;

#define echoPin 15 // attach pin GPIO 18 ON ESP32 to pin Echo of HC-SR04
#define trigPin 4 // attach pin GPIO 5 ON ESP32 to pin Trig of HC-SR04
#define DHTPIN 33 // Pin where the DHT11 is connected
#define DHTTYPE DHT11 // DHT 11
#define MQ135PIN 35 // Pin where the MQ135 is connected
#define FIRE_PIN 32 // Pin where the fire detection sensor is connected
#define CRASH_PIN 13 // Pin where the crash switch is connected
#define ADXL345_ADDRESS (0x53) // I2C address for the ADXL345 accelerometer

#define BOT_TOKEN "7177790916:AAEJPS__PSGZfSAt0YYTQ3VCUghy9rl55BM"
#define CHAT_ID "5131145538"
long duration; // variable for the duration of sound wave travel
float distance; // variable for the distance measurement

#define BOT_MTBS 1000 // mean time between scan messages
unsigned long bot_lasttime; // last time messages' scan has been done
float temperatureC;
float temperatureF;
float humidity;
String orientation; // Declaring orientation as a global variable

WiFiClientSecure secured_client;
UniversalTelegramBot bot(BOT_TOKEN, secured_client);
DHT dht(DHTPIN, DHTTYPE);
MQ135 gasSensor = MQ135(MQ135PIN); // Use MQ135 library
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345); // Some unique ID for accelerometer

void setup() {
Serial.begin(115200); /* Set the baudrate to 115200 */

pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);

pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

pinMode(FIRE_PIN, INPUT);
pinMode(CRASH_PIN, INPUT_PULLUP); // Internal pull-up resistor for the switch

dht.begin();

Wire.begin();

// Initialize accelerometer
if (!accel.begin(ADXL345_ADDRESS)) {
Serial.println("Could not find a valid ADXL345 sensor, check wiring!");
while (1);
}

Blynk.begin(auth, ssid, pass, "blynk.cloud", 8080);
secured_client.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add root certificate for api.telegram.org
}

BLYNK_WRITE(V0) { // X-axis joystick control
int x_motor = param.asInt();
if (x_motor > 70) {
carRight();
Serial.println("carRight");
} else if (x_motor < 30) {
carLeft();
Serial.println("carLeft");
} else {
carStop();
Serial.println("carStop");
}
}

BLYNK_WRITE(V1) { // Y-axis joystick control
int y_motor = param.asInt();
if (y_motor > 70) {
carBackward();
Serial.println("carBackward");
} else if (y_motor < 30) {
carForward();
Serial.println("carForward");
} else {
carStop();
Serial.println("carStop");
}
}

void carForward() {
digitalWrite(IN2, HIGH);
digitalWrite(IN4, HIGH);
digitalWrite(IN1, LOW);
digitalWrite(IN3, LOW);
}

void carBackward() {
digitalWrite(IN1, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN4, LOW);
}

void carLeft() {
digitalWrite(IN1, HIGH);
digitalWrite(IN4, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
}

void carRight() {
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN1, LOW);
digitalWrite(IN4, LOW);
}

void carStop() {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
}

void loop() {
Blynk.run();

digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;

Serial.print("Distance: ");
Serial.println(distance);

Blynk.virtualWrite(V5, distance); // Send distance data to Blynk

delay(50);

if (distance <= 10) {
Serial.println("Object is behind Robot");
} else {
Serial.println("Object is not behind Robot");
}

// Read temperature and humidity from DHT sensor
float temperature = dht.readTemperature();
float humidityValue = dht.readHumidity(); // Read humidity separately

if (!isnan(temperature) && !isnan(humidityValue)) {
Serial.print("Temperature: ");
Serial.println(temperature);
Serial.print("Humidity: ");
Serial.println(humidityValue);

// Update global variables
temperatureC = temperature;
temperatureF = temperature * 9 / 5 + 32;
humidity = humidityValue;

// Send data to Blynk
Blynk.virtualWrite(V6, temperatureC);
Blynk.virtualWrite(V8, humidity);

} else {
Serial.println("Failed to read from DHT sensor!");
}

float gasValue = gasSensor.getPPM(); // Use MQ135 library method to get PPM value

Serial.print("Gas Value: ");
Serial.println(gasValue);

int fireStatus = digitalRead(FIRE_PIN);
Serial.print("Fire Status: ");
//Serial.println(fireStatus);
if (fireStatus == HIGH) {
Serial.println("Fire Detected");
Blynk.virtualWrite(V5, 1); // Send fire status to V5
} else {
Serial.println("No Fire Detected");
Blynk.virtualWrite(V5, 0); // Send no fire status to V5
}

int crashStatus = digitalRead(CRASH_PIN);
//Serial.print("Crash Status: ");
//Serial.println(crashStatus);
if (crashStatus == LOW) {
Serial.println("Crash Detected");
Blynk.virtualWrite(V3, 1); // Send crash status to V3
} else {
Serial.println("No Crash Detected");
Blynk.virtualWrite(V3, 0); // Send no crash status to V3
}

// Read data from the ADXL345 accelerometer
sensors_event_t event;
accel.getEvent(&event);

// Calculate the angle using the accelerometer data
float angleX = atan2(event.acceleration.x, event.acceleration.z) * RAD_TO_DEG;
float angleY = atan2(event.acceleration.y, event.acceleration.z) * RAD_TO_DEG;

// Determine orientation as text
if (angleX > 45 && angleX < 135)
{
orientation = "Back";
}
else if (angleX < -45 && angleX > -135)
{
orientation = "Front";
}
else if (angleY > 45 && angleY < 135)
{
orientation = "Right";
}
else if (angleY < -45 && angleY > -135)
{
orientation = "Left";
}
else if (angleX >= 135 || angleX <= -135 || angleY >= 135 || angleY <= -135)
{
orientation = "Flip";
}
else
{
orientation = "Normal";
}

Serial.print("Orientation: ");
Serial.println(orientation);

Blynk.virtualWrite(V4, orientation); // Send orientation data to V4

// Check if it's time to scan for new messages from the Telegram bot
if (millis() - bot_lasttime > BOT_MTBS) {
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
while (numNewMessages) {
Serial.println("got response");
handleNewMessages(numNewMessages);
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
}
bot_lasttime = millis();
}
}

void handleNewMessages(int numNewMessages) {
Serial.print("handleNewMessages ");
Serial.println(numNewMessages);
for (int i = 0; i < numNewMessages; i++) {
String chat_id = String(bot.messages[i].chat_id);
if (chat_id != CHAT_ID ) {
bot.sendMessage(chat_id, "Unauthorized user", "");
} else {
String text = bot.messages[i].text;
if (text == "/data") {
// Respond with all sensor readings
String msg = "sensor readings.\n";
msg += "Temperature in Celsius: " + String(temperatureC) + "°C\n";
msg += "Temperature in Fahrenheit: " + String(temperatureF) + "°F\n";
msg += "Humidity: " + String(humidity) + "%\n";
msg += "Gas value: " + String(gasSensor.getPPM()) + "\n";
int fireStatus = digitalRead(FIRE_PIN);
msg += "Fire status: " + String(fireStatus == HIGH ? "Detected" : "Not Detected") + "\n";
int crashStatus = digitalRead(CRASH_PIN);
msg += "Crash status: " + String(crashStatus == LOW ? "Detected" : "Not Detected") + "\n";
msg += "Distance: " + String(distance) + "cm\n";
msg += "Orientation: " + orientation + "\n";
bot.sendMessage(chat_id, msg, "");
}

  if (text == "/tempC") {
    String msg = "Temperature is ";
    msg += msg.concat(temperatureC);
    msg += "C";
    bot.sendMessage(chat_id, msg, "");
  }
  if (text == "/tempF") {
    String msg = "Temperature is ";
    msg += msg.concat(temperatureF);
    msg += "F";
    bot.sendMessage(chat_id, msg, "");
  }
  if (text == "/humidity") {
    String msg = "Humidity is ";
    msg += msg.concat(humidity);
    msg += "%";
    bot.sendMessage(chat_id, msg, "");
  }
  if (text == "/gas") {
    String msg = "Gas value is ";
    msg += msg.concat(gasSensor.getPPM());
    bot.sendMessage(chat_id, msg, "");
  }
  if (text == "/fire") {
    int fireStatus = digitalRead(FIRE_PIN);
    if (fireStatus == HIGH) {
      bot.sendMessage(chat_id, "Fire Detected", "");
    } else {
      bot.sendMessage(chat_id, "No Fire Detected", "");
    }
  }
  if (text == "/crash") {
    int crashStatus = digitalRead(CRASH_PIN);
    if (crashStatus == LOW) {
      bot.sendMessage(chat_id, "Crash Detected", "");
    } else {
      bot.sendMessage(chat_id, "No Crash Detected", "");
    }
  }
  if (text == "/distance") {
    String msg = "Distance is ";
    msg += msg.concat(distance);
    msg += "cm";
    bot.sendMessage(chat_id, msg, "");
  }
  if (text == "/orientation") {
    bot.sendMessage(chat_id, "Orientation is " + orientation, "");
  }
  if (text == "/start") {
    String welcome = "sensor readings.\n";
    welcome += "/data : all sensor data \n";
    welcome += "/tempC : Temperature in Celsius \n";
    welcome += "/tempF : Temperature in Fahrenheit\n";
    welcome += "/humidity : Humidity\n";
    welcome += "/gas : Gas value\n";
    welcome += "/fire : Fire status\n";
    welcome += "/crash : Crash status\n";
    welcome += "/distance : Distance\n";
    welcome += "/orientation : Orientation\n";
    bot.sendMessage(chat_id, welcome, "Markdown");
  }
}

}
}

In file included from c:\Users\pgnan\OneDrive\Documents\Arduino\libraries\libraries\Adafruit_ADXL345/Adafruit_ADXL345_U.h:36,
                 from C:\Users\pgnan\OneDrive\Desktop\5 PROJECTS\esp32_car_Me\esp32_car_Me.ino:12:
c:\Users\pgnan\OneDrive\Documents\Arduino\libraries\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:10:36: error: 'TwoWire' has not been declared
   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
                                    ^~~~~~~
c:\Users\pgnan\OneDrive\Documents\Arduino\libraries\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:30:3: error: 'TwoWire' does not name a type; did you mean 'TwoWire_h'?
   TwoWire *_wire;
   ^~~~~~~
   TwoWire_h
c:\Users\pgnan\OneDrive\Documents\Arduino\libraries\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:10:56: error: 'Wire' was not declared in this scope
   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
                                                        ^~~~
c:\Users\pgnan\OneDrive\Documents\Arduino\libraries\libraries\Adafruit_BusIO/Adafruit_I2CDevice.h:10:56: note: suggested alternative: 'WiFi'
   Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire);
                                                        ^~~~
                                                        WiFi
C:\Users\pgnan\OneDrive\Desktop\5 PROJECTS\esp32_car_Me\esp32_car_Me.ino: In function 'void setup()':
C:\Users\pgnan\OneDrive\Desktop\5 PROJECTS\esp32_car_Me\esp32_car_Me.ino:67:3: error: 'Wire' was not declared in this scope
   Wire.begin();
   ^~~~
C:\Users\pgnan\OneDrive\Desktop\5 PROJECTS\esp32_car_Me\esp32_car_Me.ino:67:3: note: suggested alternative: 'WiFi'
   Wire.begin();
   ^~~~
   WiFi

exit status 1

Compilation error: 'Wire' was not declared in this scope
#define BLYNK_TEMPLATE_ID "TMPL3srS9Y7ys"
#define BLYNK_TEMPLATE_NAME "IOT EV CAR V 1"
#define BLYNK_AUTH_TOKEN "yBwqUetfEcg2TqzWH5OcYKO8voBcKrNN"

#include <Wire.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#include <MQ135.h> // Include MQ135 library
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
#include <UniversalTelegramBot.h>

char auth[] = "yBwqUetfEcg2TqzWH5OcYKO8voBcKrNN";
char ssid[] = "IOT";
char pass[] = "1230987654321";

int IN1 = 19;
int IN2 = 18;
int IN3 = 5;
int IN4 = 17;

#define echoPin 15    // attach pin GPIO 18 ON ESP32 to pin Echo of HC-SR04
#define trigPin 4     // attach pin GPIO 5 ON ESP32 to pin Trig of HC-SR04
#define DHTPIN 33      // Pin where the DHT11 is connected
#define DHTTYPE DHT11 // DHT 11
#define MQ135PIN 35   // Pin where the MQ135 is connected
#define FIRE_PIN 32   // Pin where the fire detection sensor is connected
#define CRASH_PIN 13  // Pin where the crash switch is connected
#define ADXL345_ADDRESS (0x53) // I2C address for the ADXL345 accelerometer

#define BOT_TOKEN "7177790916:AAEJPS__PSGZfSAt0YYTQ3VCUghy9rl55BM"
#define CHAT_ID "5131145538"
long duration; // variable for the duration of sound wave travel
float distance; // variable for the distance measurement

#define BOT_MTBS 1000 // mean time between scan messages
unsigned long bot_lasttime; // last time messages' scan has been done
float temperatureC;
float temperatureF;
float humidity;
String orientation; // Declaring orientation as a global variable

WiFiClientSecure secured_client;
UniversalTelegramBot bot(BOT_TOKEN, secured_client);
DHT dht(DHTPIN, DHTTYPE);
MQ135 gasSensor = MQ135(MQ135PIN); // Use MQ135 library
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345); // Some unique ID for accelerometer

void setup() {
  Serial.begin(115200); /* Set the baudrate to 115200 */

  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  pinMode(FIRE_PIN, INPUT);
  pinMode(CRASH_PIN, INPUT_PULLUP); // Internal pull-up resistor for the switch

  dht.begin();

  Wire.begin();

  // Initialize accelerometer
  if (!accel.begin(ADXL345_ADDRESS)) {
    Serial.println("Could not find a valid ADXL345 sensor, check wiring!");
    while (1);
  }

  Blynk.begin(auth, ssid, pass, "blynk.cloud", 8080);
  secured_client.setCACert(TELEGRAM_CERTIFICATE_ROOT); // Add root certificate for api.telegram.org
}

BLYNK_WRITE(V0) { // X-axis joystick control
  int x_motor = param.asInt();
  if (x_motor > 70) {
    carRight();
    Serial.println("carRight");
  } else if (x_motor < 30) {
    carLeft();
    Serial.println("carLeft");
  } else {
    carStop();
    Serial.println("carStop");
  }
}

BLYNK_WRITE(V1) { // Y-axis joystick control
  int y_motor = param.asInt();
  if (y_motor > 70) {
    carBackward();
    Serial.println("carBackward");
  } else if (y_motor < 30) {
    carForward();
    Serial.println("carForward");
  } else {
    carStop();
    Serial.println("carStop");
  }
}

void carForward() {
  digitalWrite(IN2, HIGH);
  digitalWrite(IN4, HIGH);
  digitalWrite(IN1, LOW);
  digitalWrite(IN3, LOW);
}

void carBackward() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN4, LOW);
}

void carLeft() {
  digitalWrite(IN1, HIGH);
  digitalWrite(IN4, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
}

void carRight() {
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN1, LOW);
  digitalWrite(IN4, LOW);
}

void carStop() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

void loop() {
  Blynk.run();

  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2;

  Serial.print("Distance: ");
  Serial.println(distance);

  Blynk.virtualWrite(V5, distance); // Send distance data to Blynk

  delay(50);

  if (distance <= 10) {
    Serial.println("Object is behind Robot");
  } else {
    Serial.println("Object is not behind Robot");
  }

  // Read temperature and humidity from DHT sensor
  float temperature = dht.readTemperature();
  float humidityValue = dht.readHumidity(); // Read humidity separately

  if (!isnan(temperature) && !isnan(humidityValue)) {
    Serial.print("Temperature: ");
    Serial.println(temperature);
    Serial.print("Humidity: ");
    Serial.println(humidityValue);

    // Update global variables
    temperatureC = temperature;
    temperatureF = temperature * 9 / 5 + 32;
    humidity = humidityValue;

    // Send data to Blynk
    Blynk.virtualWrite(V6, temperatureC);
    Blynk.virtualWrite(V8, humidity);
  } else {
    Serial.println("Failed to read from DHT sensor!");
  }

  float gasValue = gasSensor.getPPM(); // Use MQ135 library method to get PPM value

  Serial.print("Gas Value: ");
  Serial.println(gasValue);

  int fireStatus = digitalRead(FIRE_PIN);
  Serial.print("Fire Status: ");
  //Serial.println(fireStatus);
  if (fireStatus == HIGH) {
    Serial.println("Fire Detected");
    Blynk.virtualWrite(V5, 1); // Send fire status to V5
  } else {
    Serial.println("No Fire Detected");
    Blynk.virtualWrite(V5, 0); // Send no fire status to V5
  }

  int crashStatus = digitalRead(CRASH_PIN);
  //Serial.print("Crash Status: ");
  //Serial.println(crashStatus);
  if (crashStatus == LOW) {
    Serial.println("Crash Detected");
    Blynk.virtualWrite(V3, 1); // Send crash status to V3
  } else {
    Serial.println("No Crash Detected");
    Blynk.virtualWrite(V3, 0); // Send no crash status to V3
  }

  // Read data from the ADXL345 accelerometer
  sensors_event_t event;
  accel.getEvent(&event);

  // Calculate the angle using the accelerometer data
  float angleX = atan2(event.acceleration.x, event.acceleration.z) * RAD_TO_DEG;
  float angleY = atan2(event.acceleration.y, event.acceleration.z) * RAD_TO_DEG;

  // Determine orientation as text
  if (angleX > 45 && angleX < 135)
  {
    orientation = "Back";
  }
  else if (angleX < -45 && angleX > -135)
  {
    orientation = "Front";
  }
  else if (angleY > 45 && angleY < 135)
  {
    orientation = "Right";
  }
  else if (angleY < -45 && angleY > -135)
  {
    orientation = "Left";
  }
  else if (angleX >= 135 || angleX <= -135 || angleY >= 135 || angleY <= -135)
  {
    orientation = "Flip";
  }
  else
  {
    orientation = "Normal";
  }

  Serial.print("Orientation: ");
  Serial.println(orientation);

  Blynk.virtualWrite(V4, orientation); // Send orientation data to V4

  // Check if it's time to scan for new messages from the Telegram bot
  if (millis() - bot_lasttime > BOT_MTBS) {
    int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
    while (numNewMessages) {
      Serial.println("got response");
      handleNewMessages(numNewMessages);
      numNewMessages = bot.getUpdates(bot.last_message_received + 1);
    }
    bot_lasttime = millis();
  }
}

void handleNewMessages(int numNewMessages) {
  Serial.print("handleNewMessages ");
  Serial.println(numNewMessages);
  for (int i = 0; i < numNewMessages; i++) {
    String chat_id = String(bot.messages[i].chat_id);
    if (chat_id != CHAT_ID ) {
      bot.sendMessage(chat_id, "Unauthorized user", "");
    } else {
      String text = bot.messages[i].text;
      if (text == "/data") {
        // Respond with all sensor readings
        String msg = "sensor readings.\n";
        msg += "Temperature in Celsius: " + String(temperatureC) + "°C\n";
        msg += "Temperature in Fahrenheit: " + String(temperatureF) + "°F\n";
        msg += "Humidity: " + String(humidity) + "%\n";
        msg += "Gas value: " + String(gasSensor.getPPM()) + "\n";
        int fireStatus = digitalRead(FIRE_PIN);
        msg += "Fire status: " + String(fireStatus == HIGH ? "Detected" : "Not Detected") + "\n";
        int crashStatus = digitalRead(CRASH_PIN);
        msg += "Crash status: " + String(crashStatus == LOW ? "Detected" : "Not Detected") + "\n";
        msg += "Distance: " + String(distance) + "cm\n";
       msg += "Orientation: " + orientation + "\n";
       bot.sendMessage(chat_id, msg, "");
}

      if (text == "/tempC") {
        String msg = "Temperature is ";
        msg += msg.concat(temperatureC);
        msg += "C";
        bot.sendMessage(chat_id, msg, "");
      }
      if (text == "/tempF") {
        String msg = "Temperature is ";
        msg += msg.concat(temperatureF);
        msg += "F";
        bot.sendMessage(chat_id, msg, "");
      }
      if (text == "/humidity") {
        String msg = "Humidity is ";
        msg += msg.concat(humidity);
        msg += "%";
        bot.sendMessage(chat_id, msg, "");
      }
      if (text == "/gas") {
        String msg = "Gas value is ";
        msg += msg.concat(gasSensor.getPPM());
        bot.sendMessage(chat_id, msg, "");
      }
      if (text == "/fire") {
        int fireStatus = digitalRead(FIRE_PIN);
        if (fireStatus == HIGH) {
          bot.sendMessage(chat_id, "Fire Detected", "");
        } else {
          bot.sendMessage(chat_id, "No Fire Detected", "");
        }
      }
      if (text == "/crash") {
        int crashStatus = digitalRead(CRASH_PIN);
        if (crashStatus == LOW) {
          bot.sendMessage(chat_id, "Crash Detected", "");
        } else {
          bot.sendMessage(chat_id, "No Crash Detected", "");
        }
      }
      if (text == "/distance") {
        String msg = "Distance is ";
        msg += msg.concat(distance);
        msg += "cm";
        bot.sendMessage(chat_id, msg, "");
      }
      if (text == "/orientation") {
        bot.sendMessage(chat_id, "Orientation is " + orientation, "");
      }
      if (text == "/start") {
        String welcome = "sensor readings.\n";
        welcome += "/data : all sensor data \n";
        welcome += "/tempC : Temperature in Celsius \n";
        welcome += "/tempF : Temperature in Fahrenheit\n";
        welcome += "/humidity : Humidity\n";
        welcome += "/gas : Gas value\n";
        welcome += "/fire : Fire status\n";
        welcome += "/crash : Crash status\n";
        welcome += "/distance : Distance\n";
        welcome += "/orientation : Orientation\n";
        bot.sendMessage(chat_id, welcome, "Markdown");
      }
    }
  }
}