arduinoMavlink with ESP8266

Hi.
My name is Nimrod and I am quite new to programing.
I used this library: GitHub - shashikg/PixhawkArduinoMAVLink: Arduino Library to receive Pixhawk sensor's data. to communicate with a flight computer and log some data.
I run it on an Arduino mega 2560 because of memory limitations.
I want it to be smaller so I found the ESP8266 chip which is said to be able to run with the IDE enviroment.
However I am not able to make the library work, I am using the offical ESP8266 library (from what I could figure I think it is the NodeMCU 1.
I am new here so please tell me what do I need to send to help diagnose this problem.
thank you

have you set up the ESP8266 environment for the Arduino - see getting-started-with-esp8266-wifi-transceiver-review
if so can you compile and upload a simple program such as File>Examples>Basics>Blink ?

Hi @horace
I did not use the example but wrote a sample myself.
worked just fine. I was able to blink leds and put them in FOR loops.

furthermore, I was able to compile the code using the MavLink library.
It looks like the ESP cant figure out the way to interpret the data.
I just get garbage and here and there readable data

sounds like you may be receiving data faster than printing it?
increase the serial monitor baudrate to 115200baud?

can you post your code (using code tags </>)?
also post the serial monitor output as text
post a schematic of the wiring?

#include <PixhawkArduinoMAVLink.h>
#include <HardwareSerial.h>
#include <SPI.h>
#include <SD.h>

File myFile;

HardwareSerial &hs = Serial;
PixhawkArduinoMAVLink mav(hs);
float roll, pitch, yaw, lat, lon, chan5_raw, usec;
const byte interruptPin = 2;

uint8_t led_red = D0;
uint8_t led_green = D1;
uint8_t pinCS = D8;

void setup() {
  pinMode(led_red, OUTPUT); //set pin D0 as an output
  pinMode(led_green, OUTPUT); //set pin D1 as an output
digitalWrite(led_red, HIGH); //set to indicate inisilazing 
digitalWrite(led_green, HIGH); //set to indicate inisilazing 

  // Open serial communications and wait for port to open:
  Serial1.begin(57600);

while(!mav.begin()){
   Serial1.println("Not Connected!");
    delay(1000);
   }
   mav.Stream();
  delay(2000);



  for(int i = 0; i < 50; i++){
  mav.ReadAttitude(&roll, &pitch, &yaw);
  Serial1.println("roll: "); Serial1.print(roll);
  Serial1.println("pitch: "); Serial1.print(pitch);
  Serial1.println("yaw: "); Serial1.print(yaw);
   }

}

void trigger(){
//myFile.println("trigger");
//Serial.println("trigger");
}


void loop() {
  // nothing happens after setup
}

A few points.
1: I tried the baud you said and higher (I also edited it also in the SRC of the library and made it the same in the flight computer config)
2: do you want to run this code?

I have change the library SRC a bit since there was some problems in the Arduino function definition. edit - this is the changes I made to the Mavlink library: Communication between Matek H743 Wing and Arduino - #5 by igrislavee - ArduPlane - ArduPilot Discourse

3: in terms of schematics, I don't really know how to show it.
I connected the flight computer to the TX RX on the ESP (it should be serial0)

4: I have a few stuff in the code for when it ran on the Arduino mega (it was also a little more useful then :sweat_smile:)

5: here is the Serial output -
�[I� ��3k61>�����{IN9�?�
�!����"�4�t��#����$�G%�%��.gׯ={�<@j�<3[�2&W�[�B��e��)'��P_������������������c!��( +%/g�B�)+;
� � 
i��*�\��i�#��=�
�:O�����:z�X�i(�e+!�\

Œ�,�a�A �P_ c���-}1#�a.���x�;�� />�B�N�0%�1J
�#<�I�� 2$,�i3�Lao4�
3A�\����\��4e��iy�I��
���5t�\��U�� _�6�"H{D` ���7�����$�
8�\�#�9��3k61>������O>9�?=,�:��~�;�4�
Q�<�R)�=�

at first glance the serial output looks like a baudrate error
you are outputting results using Serial1 at 57600baud - what is Serial 1 connected too?
are you sure the receiver baudrate, data bits, parity, etc are correct
even if your float values are corrupt you should still see text such as pitch, roll, etc
what version of hardwareserial are you using?
the ESP8266 has very limited hardware serial ports
I tend to use espsoftwareserial

Edit: I would move to a device with multiple hardware serial ports, e.g. an ESP32

Hi.
Sorry for the late replay.
I have decided to switch to the Arduino Nano Every which has enough memory for now.
its not working very good yet but at least it does communicate properly.
thank you for you help until now.

best regards.
Nimrod Lavee

if you search for Arduino Nano Every serial you will get links discussing how to use the hardware serial ports

Thank you.
It was partly a problem about the Serial.
There was a slight problem with one of the loops of the Mavlink library that for some reason did not work with the every. A slight change fixed it (adding a "break;".
Thank you again

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.