When trying to send a get request with VL53L0X sensor HTTP GET error 702 (SIM800l) comes out but without it with dht11 sensor all works fine

** Good day I have an error when sending data from the laser rangefinder I tried to use the library Adafruit_VL53L0X.h but it seems that the library SIM800l and Adafruit_VL53L0X.h conflicts because of this I connected the sensor without the library but still comes out error 702 but if you remove the laser rangefinder everything works with dht11.
if you know how to solve the problem please help **

#include <Wire.h>
#include <SoftwareSerial.h>
#include "SIM800L.h"
#include <DHT.h>

#define SIM800_RX_PIN 8
#define SIM800_TX_PIN 9
#define SIM800_RST_PIN 4
#define DHT_PIN 3
#define DHT_TYPE DHT11

DHT dht(DHT_PIN, DHT_TYPE);
const char APN[] = "internet";
const char URL[] = "############";

SIM800L* sim800l;

#define VL53L0X_ADDRESS 0x29

void setup() {
  dht.begin();
  Serial.begin(115200);
  while (!Serial);

  Wire.begin(); // Initialize I²C
  Wire.setClock(400000); // Set I²C clock to 400kHz

  SoftwareSerial* serial = new SoftwareSerial(SIM800_RX_PIN, SIM800_TX_PIN);
  serial->begin(9600);
  delay(1000);

  sim800l = new SIM800L((Stream *)serial, SIM800_RST_PIN, 200, 512);
  setupModule();
}

void loop() {
  performHttpGetRequest();

  bool lowPowerMode = sim800l->setPowerMode(MINIMUM);
  if (lowPowerMode) {
    Serial.println(F("Module in low power mode"));
  } else {
    Serial.println(F("Failed to switch module to low power mode"));
  }

  delay(600000); // Delay for 10 minutes

  bool normalPowerMode = sim800l->setPowerMode(NORMAL);
  if (normalPowerMode) {
    Serial.println(F("Module in normal power mode"));
  } else {
    Serial.println(F("Failed to switch module to normal power mode"));
  }
}

void performHttpGetRequest() {
  bool connected = false;
  for (uint8_t i = 0; i < 100 && !connected; i++) {
    delay(3000);
    connected = sim800l->connectGPRS();
  }

  if (connected) {
    Serial.print(F("GPRS connected with IP "));
    Serial.println(sim800l->getIP());
    Serial.println(sim800l->getSignal());
  } else {
    Serial.println(F("GPRS not connected!"));
    Serial.println(F("Resetting the module."));
    sim800l->reset();
    setupModule();
    return;
  }

  Serial.println(F("Start HTTP GET..."));

  int dhtTemperature = dht.readTemperature();
  uint16_t vlDistance = readVL53L0X();
  String fullUrl = String(URL) + String(dhtTemperature) + String(vlDistance);

  Serial.print(F("Temperature: "));
  Serial.println(dhtTemperature);
  Serial.print(F("Distance: "));
  Serial.println(vlDistance);

  uint16_t rc = sim800l->doGet(fullUrl.c_str(), 18000);
  if (rc == 200) {
    Serial.print(F("HTTP GET successful ("));
    Serial.print(sim800l->getDataSizeReceived());
    Serial.println(F(" bytes)"));
    Serial.print(F("Received: "));
    Serial.println(sim800l->getDataReceived());
  } else {
    Serial.print(F("HTTP GET error "));
    Serial.println(rc);
  }

  delay(1000);

  bool disconnected = sim800l->disconnectGPRS();
  for (uint8_t i = 0; i < 5 && !disconnected; i++) {
    delay(1000);
    disconnected = sim800l->disconnectGPRS();
  }

  if (disconnected) {
    Serial.println(F("GPRS disconnected!"));
  } else {
    Serial.println(F("GPRS still connected!"));
  }
}

void setupModule() {
  while (!sim800l->isReady()) {
    Serial.println(F("Problem initializing AT command, retrying in 5 sec"));
    delay(5000);
  }
  Serial.println(F("Module is ready"));

  uint8_t signal = sim800l->getSignal();
  while (signal <= 0) {
    delay(1000);
    signal = sim800l->getSignal();
  }
  Serial.print(F("Signal OK (strength: "));
  Serial.print(signal);
  Serial.println(F(")"));
  delay(1000);

  NetworkRegistration network = sim800l->getRegistrationStatus();
  while (network != REGISTERED_HOME && network != REGISTERED_ROAMING) {
    delay(1000);
    network = sim800l->getRegistrationStatus();
  }
  Serial.println(F("Network registration OK"));
  delay(1000);

  bool success = sim800l->setupGPRS(APN);
  while (!success) {
    success = sim800l->setupGPRS(APN);
    delay(5000);
  }
  Serial.println(F("GPRS config OK"));
}

uint16_t readVL53L0X() {
  uint16_t distance = 0;

  Wire.beginTransmission(VL53L0X_ADDRESS);
  Wire.write(0x00); // Command register address
  Wire.write(0x01); // Command to start measurement (Single Ranging Mode)
  Wire.endTransmission();

  // Wait for measurement to complete
  delay(100); // Wait for data to become available
  Wire.requestFrom(VL53L0X_ADDRESS, 2); // Request 2 bytes of data
  if (Wire.available() >= 2) {
    byte lowByte = Wire.read();
    byte highByte = Wire.read();
    distance = (highByte << 8) | lowByte; // Convert to 16-bit value
  }

  return distance;
}

Output:

Module is ready
Signal OK (strength: 19)
Network registration OK
GPRS config OK
GPRS connected with IP 100.96.164.15
18
Start HTTP GET…
Temperature: 28
Distance: 59392
HTTP GET error 702
GPRS disconnected!
Module in low power mode

This code works and outputs a response

#include <SoftwareSerial.h>
#include "SIM800L.h"
#include <DHT.h> 

#define SIM800_RX_PIN 8
#define SIM800_TX_PIN 9
#define SIM800_RST_PIN 4

DHT dht(3, DHT11);
const char APN[] = "internet";
const char URL[] = "########";

SIM800L* sim800l;

void setup() {
  dht.begin();
  Serial.begin(115200);
  while (!Serial);
  SoftwareSerial* serial = new SoftwareSerial(SIM800_RX_PIN, SIM800_TX_PIN);
  serial->begin(9600);
  delay(1000);
  sim800l = new SIM800L((Stream *)serial, SIM800_RST_PIN, 200, 512);
  setupModule();
}

void loop() {
  // Perform the HTTP GET request process
  performHttpGetRequest();
  
  // Go into low power mode for 10 minutes
  bool lowPowerMode = sim800l->setPowerMode(MINIMUM);
  if (lowPowerMode) {
    Serial.println(F("Module in low power mode"));
  } else {
    Serial.println(F("Failed to switch module to low power mode"));
  }

  // Delay for 10 minutes (600 seconds)
  delay(600000);

  // Wake up from low power mode
  bool normalPowerMode = sim800l->setPowerMode(NORMAL);
  if (normalPowerMode) {
    Serial.println(F("Module in normal power mode"));
  } else {
    Serial.println(F("Failed to switch module to normal power mode"));
  }
}

void performHttpGetRequest() {
  // Establish GPRS connectivity (100 trials)
  bool connected = false;
  for (uint8_t i = 0; i < 100 && !connected; i++) {
    delay(1000);
    connected = sim800l->connectGPRS();
  }

  // Check if connected, if not reset the module and setup the config again
  if (connected) {
    Serial.print(F("GPRS connected with IP "));
    Serial.println(sim800l->getIP());
    Serial.println(sim800l->getSignal());
  } else {
    Serial.println(F("GPRS not connected!"));
    Serial.println(F("Resetting the module."));
    sim800l->reset();
    setupModule();
    return;
  }

  Serial.println(F("Start HTTP GET..."));
  
  int t = dht.readTemperature();
  String fullUrl = String(URL) + String(t);
  Serial.println(t);
  // HTTP GET communication with 10s for the timeout (read)
  uint16_t rc = sim800l->doGet(fullUrl.c_str(), 18000);
  if (rc == 200) {
    // Success, output the data received on the serial
    Serial.print(F("HTTP GET successful ("));
    Serial.print(sim800l->getDataSizeReceived());
    Serial.println(F(" bytes)"));
    Serial.print(F("Received: "));
    Serial.println(sim800l->getDataReceived());
  } else {
    // Failed...
    Serial.print(F("HTTP GET error "));
    Serial.println(rc);
  }

  delay(1000);

  // Close GPRS connectivity (5 trials)
  bool disconnected = sim800l->disconnectGPRS();
  for (uint8_t i = 0; i < 5 && !disconnected; i++) {
    delay(1000);
    disconnected = sim800l->disconnectGPRS();
  }

  if (disconnected) {
    Serial.println(F("GPRS disconnected!"));
  } else {
    Serial.println(F("GPRS still connected!"));
  }
}

void setupModule() {
  // Wait until the module is ready to accept AT commands
  while (!sim800l->isReady()) {
    Serial.println(F("Problem initializing AT command, retrying in 5 sec"));
    delay(5000);
  }
  Serial.println(F("Setup complete!"));

  // Wait for the GSM signal
  uint8_t signal = sim800l->getSignal();
  while (signal <= 0) {
    delay(1000);
    signal = sim800l->getSignal();
  }
  Serial.print(F("Signal OK (strength: "));
  Serial.print(signal);
  Serial.println(F(")"));
  delay(1000);

  // Wait for operator network registration (national or roaming network)
  NetworkRegistration network = sim800l->getRegistrationStatus();
  while (network != REGISTERED_HOME && network != REGISTERED_ROAMING) {
    delay(1000);
    network = sim800l->getRegistrationStatus();
  }
  Serial.println(F("Network registration OK"));
  delay(1000);

  // Setup APN for GPRS configuration
  bool success = sim800l->setupGPRS(APN);
  while (!success) {
    success = sim800l->setupGPRS(APN);
    delay(5000);
  }
  Serial.println(F("GPRS config OK"));
}

New contributor

Thensyst is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật