Hello everyone, I have problem - get or resive any data by Lua script by serial port from Matek 405 wing V2.
Hardware part : for resiver I use arduino nano. For transmission I use matek 405 wing , with ardupilot v4.5.7
FC connect to arduino nano by GDN to GDN, TX4 → D2, RX4 ->D3 on arduino and use Software Serial port by UART D2 as RX,D3 as TX port.
Software part: In Ardupilot for Serial4 protocol 28. For send I use Lua script with simple code from example - “serial_test” :
local port = serial:find_serial(0)
port:begin(9600)
port:set_flow_control(0)
function update ()
if port:available() > 0 then
read = port:read()
gcs:send_text(0, read .. " = " .. step)
end
if step > 122 then
step = 65
else
step = step + 1
end
gcs:send_text(0, tostring(step))
local m = port:write(step)
gcs:send_text(0, tostring(m))
return update, 1000
end
return update()
On message I see then m = port:write(step) always return 1 , but I don't see any information on my arduino.
For arduino I use next code :
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
}
void loop() {
if (mySerial.available()) {
Serial.println(mySerial.read());
}
delay(1000);
}
I try connect FC to UART serial port : GDN to GND, TX4 to RX, RX4 to TX on UART serial port - and I don’t see any information on serial monitor.
Can please help me , don’t understand what I do incorrect? Thank you.