Error while compiling

#include <Arduino.h>
#include <ArduinoJson.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>
#include <UniversalTelegramBot.h>
#include <Arducam.h>
#include <Adafruit_GPS.h>
#include <IRremote.h>

const char* ssid = "your_wifi_ssid";
const char* password = "your_wifi_password";

#define BOT_TOKEN "your_bot_token"
#define CHAT_ID "your_chat_id"

WiFiClientSecure client;
HTTPClient http;
OV2640 cam;
Adafruit_I2S i2s;
Adafruit_GPS gps(&Serial1);

OV2640() {
  // Initialize the camera
}

#define IR_RECEIVER 18

#define TAKE_PHOTO 0x1FE807F
#define START_AUDIO 0x1FE40BF
#define STOP_AUDIO 0x1FE20DF
#define START_VIDEO 0x1FEC03F
#define STOP_VIDEO 0x1FE20DF
#define GET_LOCATION 0x1FEF807

#define GPS_RXD 16
#define GPS_TXD 17

void setup() {
  Serial.begin(115200);
  Serial1.begin(9600);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }

  Serial.println("Connected to WiFi");

  cam.init();
  cam.setFrameSize(FRAME_320X240);
  cam.setContrast(2);
  cam.setBrightness(0);
  cam.setSaturation(2);

  i2s.begin();
  i2s.setGain(0.5);
  i2s.setBufferSize(1024);

  Serial.println("Setup complete");
}

void loop() {
  if (Serial.available()) {
    char c = Serial.read();
    if (c == '\n') {
      processSerialCommand();
    }
  }

  if (Serial1.available()) {
    gps.read();
    if (gps.newNMEAreceived()) {
      if (!gps.parse(gps.lastNMEA())) {
        return;
      }
    }
  }
}

void processSerialCommand() {
  String command = Serial.readStringUntil('\n');
  command.trim();

  if (command.equals("take_photo")) {
    takePhoto();
  } else if (command.equals("start_audio")) {
    startAudioRecording();
  } else if (command.equals("stop_audio")) {
    stopAudioRecording();
  } else if (command.equals("start_video")) {
    startVideoRecording();
  } else if (command.equals("stop_video")) {
    stopVideoRecording();
  } else if (command.equals("get_location")) {
    sendLocation();
  }
}

void takePhoto() {
  Serial.println("Taking photo...");

  cam.startCapture();
  uint8_t* buffer = cam.captureFrame();
  cam.stopCapture();

  File photoFile = SD.open("/photo.jpg", FILE_WRITE);
  if (photoFile) {
    photoFile.write(buffer, cam.frameSize());
    photoFile.close();
    
    sendPhoto("/photo.jpg");
    Serial.println("Photo sent successfully");
  } else {
    Serial.println("Failed to open photo file");
  }
}

void startAudioRecording() {
  Serial.println("Starting audio recording...");

  i2s.start();
}

void stopAudioRecording() {
  Serial.println("Stopping audio recording...");

  i2s.stop();

  sendAudio("/audio.wav");
  Serial.println("Audio sent successfully");
}

void startVideoRecording() {
  Serial.println("Starting video recording...");

  cam.startCapture();

  // Code to start recording video with your specific video module
}

void stopVideoRecording() {
  Serial.println("Stopping video recording...");

  // Code to stop recording video with your specific video module

  cam.stopCapture();

  sendVideo("/video.mp4");
  Serial.println("Video sent successfully");
}

void sendLocation() {
  Serial.println("Getting GPS location...");

  if (gps.fix) {
    String latitudeStr = String(gps.latitude, 6);
    String longitudeStr = String(gps.longitude, 6);

    String url = "https://api.telegram.org/bot" + String(BOT_TOKEN) + "/sendLocation?chat_id=" + String(CHAT_ID) +
                 "&latitude=" + latitudeStr + "&longitude=" + longitudeStr;

    http.begin(client, url);
    int httpResponseCode = http.GET();

    if (httpResponseCode == 200) {
      Serial.println("Location sent successfully");
    } else {
      Serial.print("Failed to send location. Error code: ");
      Serial.println(httpResponseCode);
    }

    http.end();
  } else {
    Serial.println("Failed to get GPS location");
  }
}

void sendPhoto(const String& filePath) {
 File photoFile = SD.open(filePath, FILE_READ);

if (photoFile) {
  WiFiClient client;
  if (client.connect("api.telegram.org", 443)) {
    String head = "--BOUNDARY123\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n" + String(CHAT_ID) + "\r\n";
    String body = "--BOUNDARY123\r\nContent-Disposition: form-data; name=\"photo\"; filename=\"photo.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n";
    String tail = "\r\n--BOUNDARY123--\r\n";

    client.println("POST /bot" + String(BOT_TOKEN) + "/sendPhoto HTTP/1.1");
    client.println("Host: api.telegram.org");
    client.println("Content-Length: " + String(head.length() + body.length() + photoFile.size() + tail.length()));
    client.println("Content-Type: multipart/form-data; boundary=BOUNDARY123");
    client.println();
    client.print(head);
    client.print(body);

    uint8_t buffer[1024];
    int bytesRead;
    while ((bytesRead = photoFile.read(buffer, sizeof(buffer))) > 0) {
      client.write(buffer, bytesRead);
    }

    photoFile.close();

    client.print(tail);

    String response = client.readString();
    Serial.println(response);
  } else {
    Serial.println("Failed to connect to Telegram server");
  }
} else {
  Serial.println("Failed to open photo file");
}

  if (photoFile) {
    WiFiClient client;
    if (client.connect("api.telegram.org", 443)) {
      String head = "--BOUNDARY123\r\nContent-Disposition: form-data; name=\"chat_id\"\r\n\r\n" + String(CHAT_ID) + "\r\n";
      String body = "--BOUNDARY123\r\nContent-Disposition: form-data; name=\"photo\"; filename=\"photo.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n";
      String tail = "\r\n--BOUNDARY123--\r\n";

      client.println("POST /bot" + String(BOT_TOKEN) + "/sendPhoto HTTP/1.1");
      client.println("Host: api.telegram.org");
      client.println("Content-Length: " + String(head.length() + body.length() + photoFile.size() + tail.length()));
      client.println("Content-Type: multipart/form-data; boundary=BOUNDARY123");
      client.println();
      client.print(head);
      client.print(body);

      uint8_t buffer[1024];
      int bytesRead;
      while ((bytesRead = photoFile.read(buffer, sizeof(buffer))) > 0) {
        client.write(buffer, bytesRead);
      }

      photoFile.close();

      client.print(tail);

      String response = client.readString();
      Serial.println(response);
    } else {
      Serial.println("Failed to connect to Telegram server");
    }
  } else {
    Serial.println("Failed to open photo file");
  }
}

void sendAudio(const String& filePath) {
  File audioFile = SD.open(filePath, FILE_READ);

  if (audioFile) {
    WiFiClient client;
    if (client.connect("api.telegram.org", 443)) {
      String head = "--BOUNDARY123\r\nContent-Disposition: form-data; name=\"audio\"; filename=\"audio.wav\"\r\nContent-Type: audio/wav\r\n\r\n";
      String tail = "\r\n--BOUNDARY123--\r\n";

      client.println("POST /bot" + String(BOT_TOKEN) + "/sendAudio HTTP/1.1");
      client.println("Host: api.telegram.org");
      client.println("Content-Length: " + String(head.length() + audioFile.size() + tail.length()));
      client.println("Content-Type: multipart/form-data; boundary=BOUNDARY123");
      client.println();
      client.print(head);

      uint8_t buffer[1024];
      int bytesRead;
      while ((bytesRead = audioFile.read(buffer, sizeof(buffer))) > 0) {
        client.write(buffer, bytesRead);
      }

      audioFile.close();

      client.print(tail);

      String response = client.readString();
      Serial.println(response);
    } else {
      Serial.println("Failed to connect to Telegram server");
    }
  } else {
    Serial.println("Failed to open audio file");
  }
}

void sendVideo(const String& filePath) {
  File videoFile = SD.open(filePath, FILE_READ);

  if (videoFile) {
    WiFiClient client;
    if (client.connect("api.telegram.org", 443)) {
      String head = "--BOUNDARY123\r\nContent-Disposition: form-data; name=\"video\"; filename=\"video.mp4\"\r\nContent-Type: video/mp4\r\n\r\n";
      String tail = "\r\n--BOUNDARY123--\r\n";

      client.println("POST /bot" + String(BOT_TOKEN) + "/sendVideo HTTP/1.1");
      client.println("Host: api.telegram.org");
      client.println("Content-Length: " + String(head.length() + videoFile.size() + tail.length()));
      client.println("Content-Type: multipart/form-data; boundary=BOUNDARY123");
      client.println();
      client.print(head);

      uint8_t buffer[1024];
      int bytesRead;
      while ((bytesRead = videoFile.read(buffer, sizeof(buffer))) > 0) {
        client.write(buffer, bytesRead);
      }

      videoFile.close();

      client.print(tail);

      String response = client.readString();
      Serial.println(response);
    } else {
      Serial.println("Failed to connect to Telegram server");
    }
  } else {
    Serial.println("Failed to open video file");
  }
  }

void sendLocation() {
  Serial.println("Getting GPS location...");

  if (gps.fix) {
    String latitudeStr = String(gps.latitude, 6);
    String longitudeStr = String(gps.longitude, 6);

    String url = "https://api.telegram.org/bot" + String(BOT_TOKEN) + "/sendLocation?chat_id=" + String(CHAT_ID) +
                 "&latitude=" + latitudeStr + "&longitude=" + longitudeStr;

    http.begin(client, url);
    int httpResponseCode = http.GET();

    if (httpResponseCode == 200) {
      Serial.println("Location sent successfully");
    } else {
      Serial.print("Failed to send location. Error code: ");
      Serial.println(httpResponseCode);
    }

    http.end();
  } else {
    Serial.println("Failed to get GPS location");
  }
} 

This message appears to me
/storage/emulated/0/ArduinoDroid/userlibraries/ArduCAM/src/Arducam.h:411:21: error: expected unqualified-id before numeric constant

What should I do in this case, knowing that I use Arduino Droid

Please post the full error message (using code tags) copied from the IDE using the convenient button

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.