I want to make a robotic vehicle that I can make roam over my property and be controlled over wifi. The problem I have is that my property has a large metal building in the center of it, which may block the coverage of a single wifi access point. So I’m thinking of putting an access point on each corner of the building to provide full 360 degree coverage around the building, to the perimeter of my property (roughly 400 ft radius from the center of the buildng). But that would necessitate automatic switching from one access point to another as the vehicle roams around. Is that possible to do? I want to be able to stream live video from the vehicle for surveillance.
Your thoughts?
I found an answer using Microsoft CoPilot AI which should get me started. This is what it responded with:
Question posed to CoPilot:
i want to create a node-red flow that will work with an esp32-cam board. I want the flow to stream video from the esp32-cam. I also want the flow to detect when the wifi rssi is getting weak, and to then switch to another wifi access point with a stronger rssi.
Answer:
1. Set Up ESP32-CAM for Video Streaming
Flash the ESP32-CAM:
Use the Arduino IDE to flash the ESP32-CAM with a sketch that sets up a web server for video streaming.
Arduino Sketch:
Use the following code snippet to set up the ESP32-CAM for video streaming
#include “esp_camera.h”
#include <WiFi.h>
const char* ssid = “your_SSID”;
const char* password = “your_PASSWORD”;
void startCameraServer();
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
startCameraServer();
}
void loop() {
delay(10000);
}
2. Create Node-RED Flow for Video Streaming
Install Required Nodes:
Ensure you have the node-red-dashboard and node-red-contrib-ui-webcam nodes installed. You can install them via the Node-RED palette manager.
Create the Flow:
Drag an http request node to fetch the video stream from the ESP32-CAM.
Connect it to a ui_template node to display the video stream on the dashboard.
Example Flow:
JSON
[
{
“id”: “http_request”,
“type”: “http request”,
“z”: “flow_id”,
“name”: “Fetch Video Stream”,
“method”: “GET”,
“ret”: “txt”,
“url”: “http://<ESP32-CAM-IP>/stream”,
“tls”: “”,
“x”: 300,
“y”: 200,
“wires”: [[“ui_template”]]
},
{
“id”: “ui_template”,
“type”: “ui_template”,
“z”: “flow_id”,
“group”: “group_id”,
“name”: “Video Stream”,
“order”: 1,
“width”: “6”,
“height”: “4”,
“format”: “<img src='{{msg.payload}}’/>”,
“x”: 500,
“y”: 200,
“wires”: []
}
]
3. Monitor Wi-Fi RSSI and Switch Access Points
ESP32-CAM Code for RSSI Monitoring:
Modify the ESP32-CAM code to periodically check the RSSI and send it to Node-RED via MQTT.
#include <WiFi.h>
#include <PubSubClient.h>
const char* mqtt_server = “your_MQTT_server”;
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
// Existing setup code
client.setServer(mqtt_server, 1883);
}
void loop() {
long rssi = WiFi.RSSI();
client.publish(“esp32/rssi”, String(rssi).c_str());
delay(10000);
}
2. Node-RED Flow for RSSI Monitoring:
Use an mqtt in node to receive the RSSI values.
Add a switch node to check if the RSSI is below a certain threshold.
Use an exec node to run a script that switches the Wi-Fi access point.
3.Example Flow:
[
{
“id”: “mqtt_in”,
“type”: “mqtt in”,
“z”: “flow_id”,
“name”: “RSSI Input”,
“topic”: “esp32/rssi”,
“qos”: “0”,
“broker”: “broker_id”,
“x”: 300,
“y”: 300,
“wires”: [[“switch”]]
},
{
“id”: “switch”,
“type”: “switch”,
“z”: “flow_id”,
“name”: “Check RSSI”,
“property”: “payload”,
“propertyType”: “msg”,
“rules”: [{“t”: “lt”, “v”: “-70”, “vt”: “num”}],
“checkall”: “true”,
“repair”: false,
“outputs”: 1,
“x”: 500,
“y”: 300,
“wires”: [[“exec”]]
},
{
“id”: “exec”,
“type”: “exec”,
“z”: “flow_id”,
“command”: “sh”,
“addpay”: true,
“append”: “”,
“useSpawn”: “false”,
“timer”: “”,
“oldrc”: false,
“name”: “Switch Wi-Fi”,
“x”: 700,
“y”: 300,
“wires”: [[], [], []]
}
]
Hi. I would recommend using WiFiMulti.
It can save multiple ssid and passwords and connect to the strongest one.
See tutorial here: https://randomnerdtutorials.com/esp32-wifimulti/
Regards
Sara