ESP8266 Wifi Module code problem

Hello! I was hoping if I could get some help for this problem regarding the ESP8266 wifi module, its needed for our capstone project and none of us really know how to code.

Our project is basically a device that uses geo-fencing that will mainly be used as a way to track students when they leave the campus and sends a message to a device (like a phone) to notify that they've left the area of the campus.

So far, our geo-fencing code has worked but we're stuck on the message part and how to properly code the ESP8266 wifi module. We got our code from ChatGPT, would really appreciate it if we could receive some help for this

#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>

// WiFi credentials
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";

// Google Sheets API endpoint
const char* host = "script.google.com";
const int httpsPort = 443;

// Google Sheets script path
const String scriptPath = "/macros/s/YOUR_SCRIPT_ID/exec";

// Function prototypes
void sendToGoogleSheets(String data);

void setup() {
  Serial.begin(9600);
  // Initialize WiFi connection
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");

  // Initialize GPS module
  // Configure GPS module
}

void loop() {
  // Read GPS data
  // Determine geofence status
  // Log data to Google Sheets if geofence status changes
}

void sendToGoogleSheets(String data) {
  // Create HTTP client
  WiFiClientSecure client;
  if (!client.connect(host, httpsPort)) {
    Serial.println("Connection failed");
    return;
  }

  // Create request URL
  String url = "GET " + scriptPath + "?data=" + data;
  client.print(url);
  client.println(" HTTP/1.1");
  client.print("Host: ");
  client.println(host);
  client.println("Connection: close");
  client.println();

  // Read response
  while (client.connected()) {
    String line = client.readStringUntil('\n');
    if (line == "\r") {
      break;
    }
  }

  // Disconnect
  client.stop();
}

and what is the problem?

Hello! Im not the coder so I dont really know how to best explain it, but our coder said that they couldnt see the ESP8266 on the board, something to do with a "esp8266 by esp8266 community" package? They said they tried a generic esp8266 but it didnt work. We got all this info from chatgpt so we dont really know what to do

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