mirror of
https://github.com/okalachev/flix.git
synced 2026-06-28 05:56:44 +00:00
Add docs for espnow
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
* Dedicated for education and research.
|
* Dedicated for education and research.
|
||||||
* Made from general-purpose components.
|
* Made from general-purpose components.
|
||||||
* Simple and clean source code in Arduino (<2k lines firmware).
|
* Simple and clean source code in Arduino (<2k lines firmware).
|
||||||
* Connectivity using Wi-Fi and MAVLink protocol.
|
* Communication with MAVLink protocol using Wi-Fi or ESP-NOW.
|
||||||
* Control using USB gamepad, remote control or smartphone.
|
* Control using USB gamepad, remote control or smartphone.
|
||||||
* Wireless command line interface and analyzing.
|
* Wireless command line interface and analyzing.
|
||||||
* Precise simulation with Gazebo.
|
* Precise simulation with Gazebo.
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
+33
-5
@@ -290,11 +290,8 @@ The Wi-Fi mode is chosen using `WIFI_MODE` parameter in QGroundControl or in the
|
|||||||
|
|
||||||
* `0` — Wi-Fi is disabled.
|
* `0` — Wi-Fi is disabled.
|
||||||
* `1` — Access Point mode *(AP)* — the drone creates a Wi-Fi network.
|
* `1` — Access Point mode *(AP)* — the drone creates a Wi-Fi network.
|
||||||
* `2` — Client mode *(STA)* — the drone connects to an existing Wi-Fi network.
|
* `2` — Client mode *(STA)* — the drone connects to an existing Wi-Fi network (may cause additional delays, so generally not recommended).
|
||||||
* `3` — *ESP-NOW (not implemented yet)*.
|
* `3` — ESP-NOW mode — the drone uses ESP-NOW protocol for communication.
|
||||||
|
|
||||||
> [!WARNING]
|
|
||||||
> Tests showed that Client mode may cause **additional delays** in remote control (due to retranslations), so it's generally not recommended.
|
|
||||||
|
|
||||||
The SSID and password are configured using the `ap` and `sta` console commands:
|
The SSID and password are configured using the `ap` and `sta` console commands:
|
||||||
|
|
||||||
@@ -316,6 +313,37 @@ Disabling Wi-Fi:
|
|||||||
p WIFI_MODE 0
|
p WIFI_MODE 0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using ESP-NOW
|
||||||
|
|
||||||
|
[ESP-NOW](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/network/esp_now.html) is a low level wireless communication protocol. It can provide lower latency, better reliability, and longer range than Wi-Fi. However, it requires a second ESP32 board to be used as a proxy for the computer.
|
||||||
|
|
||||||
|
<img src="img/espnow-connection.jpg" width="600">
|
||||||
|
|
||||||
|
To setup ESP-NOW communication:
|
||||||
|
|
||||||
|
1. Flash the second ESP32 board with ESP-NOW proxy sketch: [`tools/espnow-proxy/espnow-proxy.ino`](../tools/espnow-proxy/espnow-proxy.ino). Use Arduino IDE or command line: `make upload_proxy`.
|
||||||
|
|
||||||
|
2. Open Serial Monitor or use `make monitor` command. The ESP32 will print its MAC address and generated encryption key, for example:
|
||||||
|
|
||||||
|
```
|
||||||
|
espnow 7a:c8:e3:eb:bf:e9 &PiuSysxP9+$L&5E
|
||||||
|
```
|
||||||
|
|
||||||
|
Run this line as a console command on each drone you want to bind to this proxy board.
|
||||||
|
|
||||||
|
3. Set the `WIFI_MODE` parameter to `3` on the drone:
|
||||||
|
|
||||||
|
```
|
||||||
|
p WIFI_MODE 3
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Go to the QGroundControl menu ⇒ *Application Settings* ⇒ *Comm Links*, add new link with the following settings:
|
||||||
|
* Name: ESP32.
|
||||||
|
* Type: Serial.
|
||||||
|
* Serial Port: choose the port of the proxy ESP32 board, e. g. `/dev/cu.usbserial-0001`.
|
||||||
|
* Baud Rate: 115200.
|
||||||
|
5. Click *Save*. QGroundControl should connect to the drone using ESP-NOW and begin showing the telemetry.
|
||||||
|
|
||||||
## Flight log
|
## Flight log
|
||||||
|
|
||||||
After the flight, you can download the flight log for analysis wirelessly. Use the following command on your computer for that:
|
After the flight, you can download the flight log for analysis wirelessly. Use the following command on your computer for that:
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
// Proxy for ESP-NOW connection
|
// Proxy for ESP-NOW connection
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <ESP32_NOW_Serial.h>
|
#include <ESP32_NOW_Serial.h>
|
||||||
#include <MacAddress.h>
|
#include <MacAddress.h>
|
||||||
#include <MAVLink.h>
|
#include <MAVLink.h>
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
#include "../../flix/util.h"
|
#include "../../flix/util.h"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
const int CHANNEL = 6;
|
const int CHANNEL = 6;
|
||||||
char key[ESP_NOW_KEY_LEN + 1] = {0}; // with trailing null
|
char key[ESP_NOW_KEY_LEN + 1] = {0}; // with trailing null
|
||||||
@@ -61,7 +61,7 @@ void generateRandomKey() {
|
|||||||
void loop() {
|
void loop() {
|
||||||
uint8_t buf[5000];
|
uint8_t buf[5000];
|
||||||
|
|
||||||
// Send from serial to ESP-NOW
|
// Send from Serial to ESP-NOW
|
||||||
while (Serial.available() > 0) {
|
while (Serial.available() > 0) {
|
||||||
int b = Serial.read();
|
int b = Serial.read();
|
||||||
if (b < 0) {
|
if (b < 0) {
|
||||||
@@ -78,7 +78,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send from ESP-NOW to serial
|
// Send from ESP-NOW to Serial
|
||||||
for (ESPNOWSerial *link : peers) {
|
for (ESPNOWSerial *link : peers) {
|
||||||
int len = link->read(buf, sizeof(buf));
|
int len = link->read(buf, sizeof(buf));
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user