Odpiąłem te dwa piny i w grałem szkic odziwo cos działa ale jeszcze dużo roboty.
Tak
Apm wysyła do nano na piny seriall1
Nano wysyła po seriall do pc
A softserial ibus do aparatury
Ciekawe czemu nie działa na nano bez pc według to jest to samo
A da sie zrobic most miedzy serial a serial1 bo pod seriall bym podpiol bt
taki miks wyszedł. na pc
serial.bmp (Rozmiar: 3 MB / Pobrań: 3)
i na aparaturze
Zastanawiam sie czy moge rozdzielic kablem Y
O takim mysle
https://www.google.com/search?q=apm+bt+Y...QtNSsgwp5M
Tak
Apm wysyła do nano na piny seriall1
Nano wysyła po seriall do pc
A softserial ibus do aparatury
Ciekawe czemu nie działa na nano bez pc według to jest to samo
A da sie zrobic most miedzy serial a serial1 bo pod seriall bym podpiol bt
Kod:
#include <mavlink.h>
#include <iBUSTelemetry.h>
#define UPDATE_INTERVAL 500
iBUSTelemetry telemetry(8);
uint32_t prevMillis = 0;
int FM;
int SAT;
int VOLT;
int AMPER;
void setup() {
Serial.begin(57600);
Serial1.begin(57600);
request_datastream();
telemetry.begin();
telemetry.addSensor(IBUS_MEAS_TYPE_FLIGHT_MODE);
telemetry.addSensor(IBUS_MEAS_TYPE_GPS_STATUS);
telemetry.addSensor(IBUS_MEAS_TYPE_EXTV);
telemetry.addSensor(IBUS_MEAS_TYPE_BAT_CURR);
}
void loop() {
MavLink_receive();
updateValues();
telemetry.run();
}
//////////////////////////////////////////////////ODBIERA BICIE SERCA I GPS////////////////////////////////////////////////
void MavLink_receive()
{
mavlink_message_t msg;
mavlink_status_t status;
while(Serial1.available())
{
uint8_t c= Serial1.read();
//Get new message
if(mavlink_parse_char(MAVLINK_COMM_0, c, &msg, &status))
{
//Handle new message from autopilot
switch(msg.msgid)
{
case MAVLINK_MSG_ID_GPS_RAW_INT:
{
mavlink_gps_raw_int_t packet;
mavlink_msg_gps_raw_int_decode(&msg, &packet);
Serial.print("GPS Fix: ");Serial.println(packet.fix_type);
SAT = packet.fix_type;
Serial.print("GPS Latitude: ");Serial.println(packet.lat);
Serial.print("GPS Longitude: ");Serial.println(packet.lon);
Serial.print("Sats Visible: ");Serial.println(packet.satellites_visible);
}
break;
case MAVLINK_MSG_ID_HEARTBEAT:
{
mavlink_heartbeat_t hb;
mavlink_msg_heartbeat_decode(&msg,&hb);
Serial.print("Flight Mode:");Serial.println(hb.custom_mode);
FM = hb.custom_mode;
}
break;
case MAVLINK_MSG_ID_SYS_STATUS: // #1: SYS_STATUS
{
mavlink_sys_status_t sys_status;
mavlink_msg_sys_status_decode(&msg, &sys_status);
// #ifdef SOFT_SERIAL_DEBUGGING
Serial.print("V");
Serial.println(sys_status.voltage_battery);
VOLT = sys_status.voltage_battery;
Serial.print("A");
Serial.println(sys_status.current_battery);
AMPER = sys_status.current_battery;
// #endif
}
break;
}
}
}
}
/////////////////////////////////////////////////TU COS WYSYLA MAWLINK///////////////////////////////////////////////////////////////////
void request_datastream() {
//Request Data from Pixhawk
uint8_t _system_id = 255; // id of computer which is sending the command (ground control software has id of 255)
uint8_t _component_id = 2; // seems like it can be any # except the number of what Pixhawk sys_id is
uint8_t _target_system = 1; // Id # of Pixhawk (should be 1)
uint8_t _target_component = 0; // Target component, 0 = all (seems to work with 0 or 1
uint8_t _req_stream_id = MAV_DATA_STREAM_ALL;
uint16_t _req_message_rate = 0x01; //number of times per second to request the data in hex
uint8_t _start_stop = 1; //1 = start, 0 = stop
mavlink_message_t msg;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
// Pack the message
mavlink_msg_request_data_stream_pack(_system_id, _component_id, &msg, _target_system, _target_component, _req_stream_id, _req_message_rate, _start_stop);
uint16_t len = mavlink_msg_to_send_buffer(buf, &msg); // Send the message (.write sends as bytes)
Serial1.write(buf, len);//Write data to serial port
}
////////////////////////////////////////////////////////////////IBUS////////////////////////////////////////////////////////////////////////////////
void updateValues()
{
uint32_t currMillis = millis();
if (currMillis - prevMillis >= UPDATE_INTERVAL) { // Code in the middle of these brackets will be performed every 500ms.
prevMillis = currMillis;
telemetry.setSensorValue(1, FM);
telemetry.setSensorValue(2, telemetry.gpsStateValues(3, SAT)); // As GPS status consists of two values,
// use gpsStateValues(firstVal, secondVal) to set it properly.
telemetry.setSensorValueFP(3, VOLT);
telemetry.setSensorValueFP(4, AMPER);
}
}
serial.bmp (Rozmiar: 3 MB / Pobrań: 3)
i na aparaturze
Zastanawiam sie czy moge rozdzielic kablem Y
O takim mysle
https://www.google.com/search?q=apm+bt+Y...QtNSsgwp5M