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.
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.
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.
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.
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.
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:
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.
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.