Callmebot doesnt works

Hi,

i tried to build a device who is measuring a battery of a camping vehicle and send a whatsapp message if the battery is undervolting. The measuring is still working and the case of transmitting status is given but no message is sended. I dont know why...

What is my Goal:

I build a sketch who measure a voltage on PIN 0 who comes from a voltage divider. if it less then 3V the a whatsapp go sending. In the case that the device not still working or have an issue once a week an another message will be send with a lifesign. so far so good but it doesnt works.

Here is the Sketch:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

// WiFi-Einstellungen
const char* ssid = "this is my SSID";
const char* password = "my Pssword";

// CallMeBot-API-Einstellungen
const char* callMeBotNumber = "4912345678";
const char* callMeBotToken = "12345678";


// ADC-Pin-Einstellungen
const int adcPin = A0;
const float vref = 3.3;
const float voltageDividerRatio = 2.0;

// Statusüberprüfung
const unsigned long checkInterval = 86400000; // 1 Tag in Millisekunden
unsigned long lastCheckTime = 0;

// Spannungsüberprüfung
const float voltageThreshold = 3.0;
bool voltageAlertSent = false;

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

  // WiFi-Verbindung herstellen
  WiFi.begin(ssid, password);
  Serial.print("Verbindung zum WiFi-Netzwerk wird hergestellt");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi-Verbindung hergestellt");

  lastCheckTime = millis();
}

void loop() {
  // Spannung messen
  int adcValue = analogRead(adcPin);
  float voltage = (adcValue * vref / 1024.0) / voltageDividerRatio;
  Serial.print("Gemessene Spannung: ");
  Serial.print(voltage);
  Serial.println("V");

  // Messwerte an CallMeBot-API senden
  if (voltage < voltageThreshold && !voltageAlertSent) {
    WiFiClient client;
    HTTPClient http;
    Serial.println("Sende Spannung");
    String url = "https://api.callmebot.com/whatsapp.php?phone=" + String(callMeBotNumber) + "&text=Batterie%20leer&apikey=" + String(callMeBotToken);
    http.begin(client, url);
    int httpResponseCode = http.GET();
    http.end();
    Serial.println("Spannung gesendet");
    Serial.println (url);
    voltageAlertSent = true;
  }

  // Statusüberprüfung durchführen
  if (millis() - lastCheckTime > checkInterval) {
    Serial.println("System läuft noch");
    WiFiClient client;
    HTTPClient http;
    String url = "https://api.callmebot.com/whatsapp.php?phone=" + String(callMeBotNumber) + "&text=System%20läuft%20noch&apikey=" + String(callMeBotToken);
    http.begin(client, url);
    int httpResponseCode = http.GET();
    http.end();

    lastCheckTime = millis();
    voltageAlertSent = false;
  }

  delay(1000);
}

Can someone help my ?

Do you see this output in the serial monitor?

Yes, i can see it on the Monitor.

And yes: WiFi connection is establlished!

And if i copy the string from the Monitor and put it into a browser it still works.

So it's not a board issue necessarily.

Do you have any sort of verbatim output in the API client? Can you Wireshark to see what comes over the line? Maybe redirect the string to your local system IP and capture the traffic to see if it's malformed?

Do you have stand alone code that test just the http portion?

I never used wireshark before but i think i can try it...

You won't see everything unless you have a hub or do port mirroring. If you change your url String to your local IP where you're running wireshark, it will come to you then.

I dont know how to use wireshark. if i watch out my LAN i see many traffic but nothings from the ip from the ESP. If i host a hotspot for the ESP with my PC it is connected but i see nothing on wireshark.

I think that the Internet Connection is not working but the ESP is connected to my Network, i can see it in the Router Table.

I haven't worked on getting a board to talk to a website so hopefully someone can help you more there.

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