Devices & Components
Arduino® Nano ESP32
Software & Tools
Mirrorfly Video Call API
Arduino IDE
Project description
Code
ESP32 Trigger to MirrorFly Video Call
cpp
C++ (Since Arduino code is written in C/C++.)
1#include <WiFi.h> 2#include <HTTPClient.h> 3 4// Replace with your network credentials 5const char* ssid = "YourWiFiSSID"; 6const char* password = "YourWiFiPassword"; 7 8// Replace with your server URL that triggers MirrorFly API 9const char* serverURL = "https://your-server.com/api/start-call"; // MUST be HTTPS 10 11void setup() { 12 Serial.begin(115200); 13 14 // Connect to Wi-Fi 15 WiFi.begin(ssid, password); 16 Serial.print("Connecting to WiFi"); 17 while (WiFi.status() != WL_CONNECTED) { 18 delay(500); 19 Serial.print("."); 20 } 21 Serial.println("\nWiFi connected"); 22 23 // Make HTTP POST Request 24 if (WiFi.status() == WL_CONNECTED) { 25 HTTPClient http; 26 27 http.begin(serverURL); 28 http.addHeader("Content-Type", "application/json"); 29 30 // Prepare JSON data 31 String postData = "{\"caller_id\":\"esp32-device\",\"recipient_id\":\"user_123\"}"; 32 33 int httpResponseCode = http.POST(postData); 34 35 if (httpResponseCode > 0) { 36 String response = http.getString(); 37 Serial.println("Server Response:"); 38 Serial.println(response); 39 } else { 40 Serial.print("Error Code: "); 41 Serial.println(httpResponseCode); 42 } 43 44 http.end(); 45 } else { 46 Serial.println("WiFi not connected"); 47 } 48} 49 50void loop() { 51 // You can move the POST code here and trigger it on button press 52}
Documentation
MirrorFly API Docs
Find all the technical documentation for MirrorFly
https://www.mirrorfly.com/docs/
Comments
Only logged in users can leave comments