How to send data over TELEM 1 from CubeOrange to ESP32?

Hardware

CubeOrange 00450025 30305114 35333339
ChibiOS: d4fce84e
ArduCopter V4.0.7 (0bb18a15)

ESP32

Issue

I receive nothing on RX pin on ESP from CubeOrange TELEM 1 TX.

How can I send Telemetry Data from CubeOrange to ESP32 using TELEM1 and UART in from ESP32 ?

MissionPlanner parameter list

SERIAL_PASS1,0
SERIAL_PASS2,-1
SERIAL_PASSTIMO,15
SERIAL0_BAUD,115
SERIAL0_PROTOCOL,2
SERIAL1_BAUD,115
SERIAL1_OPTIONS,0
SERIAL1_PROTOCOL,1
SERIAL2_BAUD,115
SERIAL2_OPTIONS,0
SERIAL2_PROTOCOL,13
SERIAL3_BAUD,38
SERIAL3_OPTIONS,0
SERIAL3_PROTOCOL,5
SERIAL4_BAUD,115
SERIAL4_OPTIONS,0
SERIAL4_PROTOCOL,9
SERIAL5_BAUD,57
SERIAL5_OPTIONS,0
SERIAL5_PROTOCOL,1
SERIAL6_BAUD,115200
SERIAL6_OPTIONS,0
SERIAL6_PROTOCOL,22

Code on ESP32

#include <Arduino.h>

#define RX2 16
#define TX2 17

void setup()
{
  Serial.begin(115200);
  Serial2.begin(115200, SERIAL_8N1, RX2, TX2);

  Serial.println("TX2: ");
  Serial.println(digitalRead(TX2));
  Serial.println("RX2: ");
  Serial.println(digitalRead(RX2));
}

void loop()
{
  delay(1000);
  Serial.println("TX2: ");
  Serial.println(digitalRead(TX2));
  Serial.println("RX2: ");
  Serial.println(digitalRead(RX2));
  Serial.println("");
  Serial.println("");

  // if (Serial2.available() > 0)
  // {
  //   incomingByte = Serial2.read();
  //   Serial.println(incomingByte, DEC);
  // }

  while(Serial2.available())
  {
    Serial.print(Serial2.read());
  }

Serial Monitor

TX2: 
1
RX2: 
1

Hi GeorgeFlorian.

You have to dig a little bit deeper:
mavlink via arduino

Hope this helps…

1 Like

I’m pretty sure the “digitalRead” statement will just tell you if the pin is high or low.

The link from @VRquaeler has a lot of great information.

I have a brand new Cube Orange myself and I’ve done a lot of programming on the ESP32. Is there a particular parameter you want to receive with the ESP32?

I’ll try to write a simple test program for the ESP32 in the next couple of days. Can you describe an example you think would be helpful? If so, I’ll give it a try myself.

Wow. That thread is a gold mine. Thank you so much. I couldn’t have found it without your help.

Thank you for your reply.

The code from my original post is a sample to see if I can receive literally anything on the Serial2.
I am using Serial.println(digitalRead(RX2)); just to get the state of the pins.

I then use

 while(Serial2.available())
  {
    Serial.print(Serial2.read());
  }

to try and get something coming from the CubeOrange. Unfortunately, I get nothing.

My ultimate goal is to use GitHub - DroneBridge/ESP32: DroneBridge for ESP32. A transparent short range wifi based telemetry (serial to WiFi) link. Support for MAVLink, MSP, LTM (iNAV) or any other protocol as a way to obtain telemetry data from the drone through the ESP and maybe even being able to send MavLink commands to the drone.

You clearly have something incorrect here. The parameters look correct, though I suggest using MAVLink v2 instead of v1.

Check the wiring and voltage (should be 3v3). Are you sure you’re sampling the TX pin on TELEM1? Are you using a common ground? I’ve found basic serial communication on Pixhawk based controllers to be very simple and intuitive. It’s a little more complex to parse the messages and/or send commands, but there are libraries for that.

It’s just as easy and probably more effective to set the correct baud rate on the microcontroller and read serial data instead of pin state.

Apparently GPIO16 is not the same as Pin16 on the ESP32-Wrover-B.

I’ve changed from Pin16 to Pin19, so from #define RX2 16 to #define RX2 19 and now I get somethings on the Serial monitor:

2549521100000238133169209

2541653111110000000089253116511000178126254954110000023813312544

254955110000023813315182

2549561100000238133115205

2549571100000238133153179

254958110000023813316748

25495911000002381337778

254960110000023813320262

25496111000002381333264

254962110000023813330195

2549631100000238133244189

25416641111100000000113982249130001052282549651100000238133253108

Next, I’ve tried using GitHub - DroneBridge/ESP32: DroneBridge for ESP32. A transparent short range wifi based telemetry (serial to WiFi) link. Support for MAVLink, MSP, LTM (iNAV) or any other protocol but I can’t connect to the ESP’s AP using this project.

Can you recommend me some libraries/projects that I can use to receive and send MavLinkV2 messages/commands ?

Thank you.

While I have used an Arduino compatible board to listen for MAVLink serial messages during testing, I never installed a library to parse the input, so my recommendations would be via the same Google search that you could do yourself. There are more than a few options out there.

I’m most familiar with the pymavlink Python library, but that is likely not suited to your use case.

Hi @GeorgeFlorian ,

Here are the libraries you are looking for:
mavlink.io

A really nice project using MAVlink with the Arduino IDE is done by @Eric_Stockenstrom on his great
mavlink-to-frsky-s-port-passthru-converter
This is a very well documented code with lots of debug options.

It helped me a lot to understand the MAVlink communication.

Good luck!!

1 Like

Has anybody tried https://github.com/DroneBridge/ESP32 ?
It seems like it’s what I am looking for but I can’t seem to make it work.

if you don’t mind to use esp-idf toolchain for programming esp32 then you might get some idea from here https://github.com/Notorious811/esp32-mavlink_example

Hello, I tested this morning and it works OK
What’s annoying -in my case- is the default IP address (192.168.2.1)that is the same as my router, so I had to turn it off in order to make connection to ESP 32 and tested with a PixHawk to TX1-RX1 (Pins 17-16)

Using the ESP-32 onboard antenna is a limiting factor as it can transmit to 100 Meter max.

Wow. Mine doesn’t work at all.

Can you please explain in more detail the steps you took in order to get that output on the QGroundControl ? Thank you.

I’ve changed the RX pin to uint8_t DB_UART_PIN_RX = 19; because 16 doesn’t work on my ESP32 board.

I’ve connected QGroundControl on Mobile to the ESP using TCP: I (537854) DB_CONTROL: TCP: New client connected: 192.168.2.2 but QGC still says Disconnected and there is nothing on the MAVLink Inspector.

I am positive the settings on the Drone are correct and the wiring is good because I’ve checked with a simpler code and it outputs something.
settings

I am stumped. I have no idea what is going wrong here or what I am doing wrong.

Actually, I just uploaded binaries with the python utility, connected Pixhawk and made sure serial2 (Telem2 used) was at 115200bps and started the ESP-32.
As I wrote, I hade to disable my router so I could login the ESP interface and launched QGroundControl , that has automatically recognized the bridge ( I haven’t looked but I guess it is UDP:14550)

I am using ESP-IDF extension on VSCode.
I have checked and 'idf.py monitor' baud rate is set to 115200 bps.
Also, there is #define CONFIG_CONSOLE_UART_BAUDRATE 115200 in sdkconfig.h.
Inside main.c I have uint32_t DB_UART_BAUD_RATE = 115200;
This is on the FlightController:
settings

The strange thing is that I get gibberish on the Serial Monitor:

I (1174) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (1284) wifi:mode : softAP (24:6f:28:de:4d:59)
I (1284) wifi:Total power save buffer number: 16
I (1284) wifi:Init max length of beacon: 752/752
I (1284) wifi:Init max length of beacon: 752/752
Am�#��j��ȭj�N[I+؟jz�M�
                     ��H֦!�MxJ�S[
�ֈH     J��
           ��HY�!>�L�
�KJ�gK�
J�wLh��
       J9LJ1�

            ���

               �ȭj*j    �

                         �H�jz�M��Z)�
                                     ��w+������ƺ�;N��
                                                   s���!���!)�
��;�XZ)�
�!)s���x�N���
ƺ�;N��
�!)s���XKt�;N��
��9{���X{i;�XZ)��Ⱦ�
                H��kʝ!��X�J��
                             @ހ�
��;���;N��


@�����혭gk      L�NNƺ�;N��J�

@����)�g�;��;I (897734) DB_CONTROL: TCP client disconnected
device reports readiness to read but returned no data (device disconnected or multiple access on port?)
Waiting for the device to reconnect.............................

As you can see some of it is good. But most of it is not.

Also, I’ve encountered a strange behavior. While using QGroundControl on Linux and I start a TCP connection I get:

device reports readiness to read but returned no data (device disconnected or multiple access on port?)
Waiting for the device to reconnect.............................

It basically disconnects the ESP from the Serial Monitor. Why ?

Also, other errors that QGC returns are:

Connection to speech-dispatcher failed
VehicleLog: _waitForMavlinkMessage: collision

Vehicle 1 did not respond to request for parameters. This will cause QGroundControl to be unable to display its full user interface.

I don’t know what I am doing wrong. But this project simply doesn’t work for me.

Have you tried with Mavlink1 protocol ?

I see you have same discussion with dronebridge

I’ve tried using this. I get nothing on the serial.
I was careful to change to to appropriate pins.
I’ve tried both MavLinkv1 and MavLinkv2.

Yes, I am trying to get help from everywhere.
I did try MavLink 1.

I also tried compiling with different versions of ESP-IDF.

I won’t get any parameters from the drone. It seems like it’s doomed.

I just don’t understand how it just perfectly worked for you and I have been debugging it for weeks now with 0 result.

I have no idea where to go from here.

Yep I know the feeling … I suggest you check Mavlink communication between Orange and GCS with a simple USB serial converter (FTDI), to make sure the basic connection @ 115200kbps works ok.

Did you tried with another ESP-32 ? I see you experienced problem with the serial port
And did you tried the obvious == Flashing with the prebuild binaries ?

I have actually implemented it last year, that’s why i posted the repository, it definitely works and almost the same setup just like with interfacing FC with Arduino, or any other microcontroller like STM32, sometimes there can be some conflicts with the UART on different microcontrollers

Sorry to bother you again.
I don’t currently have any other ESPs.
The prebuild binaries were the first I’ve tried and they are the worse because the ESPs versions differ a lot.
Can you tell me what ESP32 did you use and what pins did you use as RX and TX.

GPIO 16 and GPIO 17 on the Wrover-B are reserver for PSRAM and can’t be used, so I’ve moved to 18 and 19.
I am powering the ESP via the PC’s USB and the CubeOrange via it’s battery.
Whenever the Drone is powered up, the ESP can’t assign IP addresses to whatever device I am trying to connect with.