Help with ESP32 Sending WhatsApp Messages via CallMeBot – Any WhatsApp Groups for Troubleshooting?
Posted: Tue May 20, 2025 10:17 pm
Hi all! I’m working on a project where an ESP32 sends WhatsApp messages when a PIR sensor detects motion. I’m using the CallMeBot API with the following Arduino code:
```cpp
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "yourSSID";
const char* password = "yourPassword";
String phoneNumber = "yourPhoneNumber";
String apiKey = "yourApiKey";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected!");
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
String url = "https://api.callmebot.com/whatsapp.php?phone=" + phoneNumber + "&text=Motion+Detected!&apikey=" + apiKey;
http.begin(url);
int httpCode = http.GET();
if (httpCode == 200) {
Serial.println("Message sent!");
} else {
Serial.println("Error: " + String(httpCode));
}
http.end();
}
delay(60000); // Check every minute
}
The code works, but sometimes I get HTTP 503 errors, and I’m not sure if it’s a CallMeBot limit or my ESP32’s connection. Has anyone faced this? Also, are there any WhatsApp groups (in Portuguese or English) where I can discuss ESP32 projects like this? I’m based in Brazil and would love to connect with other IoT devs. Thanks!
```cpp
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "yourSSID";
const char* password = "yourPassword";
String phoneNumber = "yourPhoneNumber";
String apiKey = "yourApiKey";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected!");
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
String url = "https://api.callmebot.com/whatsapp.php?phone=" + phoneNumber + "&text=Motion+Detected!&apikey=" + apiKey;
http.begin(url);
int httpCode = http.GET();
if (httpCode == 200) {
Serial.println("Message sent!");
} else {
Serial.println("Error: " + String(httpCode));
}
http.end();
}
delay(60000); // Check every minute
}
The code works, but sometimes I get HTTP 503 errors, and I’m not sure if it’s a CallMeBot limit or my ESP32’s connection. Has anyone faced this? Also, are there any WhatsApp groups (in Portuguese or English) where I can discuss ESP32 projects like this? I’m based in Brazil and would love to connect with other IoT devs. Thanks!