C-Fly Faith/JJRC X12/EX4 Changing parameters and/or connecting Mission Planner, etc

The USB port on the EX4 is actually just that, a USB port so if you want to connect it to any other port then you’ll need to convert the signaling to whatever you are connecting to.

The RPi0 GPIOs usually connect via different protocol (I2C, SPI) so connecting directly there isn’t that feasible.

You could try connecting over the serial pins on the RPi though. It works fairly easy.


You mean like this? I tried, enabled serial connection on raspi-config, I am using /dev/serial0 but it still doesn’t work. there are 5v+, GND, TX, RX on raspberry pi, but on the drone there is D+ and D- connections, how should I know if D+ is TX or RX? I tried switching the Data wires but it didn’t really work, maybe I am doing it wrong?

The Rx and Tx on the RPi should be “crossed”, i.e. the Rx should go to the Tx on the Pixhawk. Now since the EX4 has only D+ and D-, those would not match directly to the Rx or Tx so you’ll need to switch them around, make sure though that the GND is correctly set on both. The GND is the one wire which provides “0V reference” for both the Rx and Tx which could go above or below 0V when sending data.

As to how exactly to wire them, I see you’re using the UART port which as far as I know isn’t an exact match for the RPi’s serial pins. You’d also need to match the baud rate and parity to actually get a working serial link between the RPi and the Pixhawk board.

Lastly I think you should first focus on getting the Pixhawk on the EX4 to talk via USB to your PC and when you have it working then try with the RPi’s GPIOs.

Sorry, I don’t have a pixhawk, I just found this photo online, instead of pixhawk I connected EX4 on the same gpio’s, I don’t have a lot of knowledge with these ports, but you are saying that EX4 should work if I connect it like this, I just need to switch around the D+/D- on RX TX of the raspberry pi? And also the baud rate?

But if I don’t succeed with this, I will just use a usb hat, and connect the EX4 to rpi’s usb port:
image

You may want to first connect your EX4 to a PC and make sure you can access it from QGroundControl. The steps are detailed by several folks up this very thread. You’ll also see how the wires need to be soldered on the connector and plugs. Once you have that USB cable and are able to see and communicate with the Pixhawk on the EX4, Eachine/JJRC actually confirmed they are using a customized version of the Pixhawk4 firmware, then you can think about hooking up a RPi, particularly if you don’t have sufficient experience with either PX4 and/or RPi.

It would be easier to start with smaller, simpler steps and navigate from there into more complex scenarios.

Also up the thread you’ll see a reference where someone used a RPi as an external computer connected via the USB plug, he used a microUSB plug on the outbound end and established a serial comm link between the RPi and the PX4 board inside the EX4.

I already connected EX4 to my computer several times, and used it with QGRoundControl/Mission Planner, I also connected raspberry pi to the EX4 via USB and connected to the QGRoundControl via mavproxy without any problems, but I want to connect EX4 to raspberry pi’s GPIO pins instead of USB. I could connect EX4 to raspberry pi zero micro usb port and use it like that, but I also want to add a 4G modem to the raspberry pi, but then I would need two USB ports, which raspberry pi zero doesn’t have. That is the reason why I want to connect the EX4 to the GPIO pins of the rpi0, so that I don’t have to buy a usb hub.

The PX4 on the EX4 as far as I know only allows to connect via the USB port it has on board. It may have a UART/Serial port which you could connect to the RPi’s GPIO serial comm pins but I am not familiar with the actual pins on the EX4 that you must use to connect to the RPI’s serial pins.

But rather than focusing on this connection issue, what exactly are you trying to achieve?

You mentioned a 4G modem, why would you need to connect that and where?
Either via the 5GHz WiFi on the EX4 or the EX4 Pro’s improved communications, your best option would still be to have the RPi connect via WiFi, you’d need the W version, to a WiFi based router on or close to your remote and get on to the internet that way. This would let you use the USB port on both the PX4 and RPi to enable serial comms between the two.

Ok, so I will have to use the USB hub.
You are asking me why I want to use 4G modem, I want to view live telemetry via QGC/Mission planner of the drone, and I will also later be adding a raspberry pi camera and streaming it over internet. I set up a VPN client on the pi that connects to my home network, so I can access the drone from anywhere.
Of course, internet connection is not necessary for mission planning, but just for fun.

If by live telemetry you mean drone’s position and stas then you can do this by piggy-backing on the C-Fly application, I’ve actually got a somewhat similar setup working by running the C-Fly on a Android emulator on my PC and connected Mission Planner via the simulated android to the drone. There’s a tutorial up the page on how to connect to the drone using similar steps.

What I could not get to work was the camera, but there’s a real time streaming URL you can connect to and get the raw video stream sent by the drone. Again up the page or on this forum you should see how to connect your browser or VLC player to the streaming URL on the drone.

Hope this helps.

You mean by opening C-FLY/Enjoy-Fly app to open mavlink connection on android device so you can access the QGC/Mission Planner? I tried that and yeah it works, but for me I get a disconnect a bunch of times and the reconnect. I tested with raspberry pi mavproxy, and the connection is very consistent, I don’t get any disconnects, and I also want to do a one way mission, so set up a missions of 4-5 km, and in this range I won’t have a connection with controller, but with rpi and 4G internet, I will still have connection no matter where.

Another thing I want to do, is make raspberry pi connect to the drone’s wifi, then since raspberry pi is in drone’s network, relay the drone’s main camera feed and stream in to the internet, I am not sure how I will do that, but maybe I will try to figure it out.
EX4 Pro doesn’t have a separate WiFi just for the drone, so I will try to connect to drone’s FTP server and see if I can change the drone’s WiFi hotspot to not hidden.

Another thing that’s bugging me, is if let’s say I set up an autonomous mission on QGC, and after some time the drone loses the connection to the controller, will the drone still fly according to the mission, or will it initiate a RTH? Or will I need to edit the parameters so the RTH wouldn’t work, so it doesn’t interrupt the mission?
I never tried doing any of this, I only learned a little bit about ArduPilot since I found out this drone uses it, but I am pretty familiar with networking, Linux, etc.

I only have a regular EX4, not the Pro version so can’t really help you with the WiFi settings on the quad. If you’re able to login via SSH to the quad then you should be able to change how the hotspot is configured and behaves, I know I’ve done the RPi hotspot configuration and set it up in the way I wanted, connect to a known WiFi if in range if not then enable its own hotspot to allow clients to join. I also hooked a 4G dongle on a USB port so I have a “modem” connection available to get on to the internet, not tried yet to configure the fwl to allow natting, not a big deal as I don’t really want my robots to get on to the internet after they connect to the RPi’s hotspot - my main goal is to reach the RPi from the internet and allow secured access to a Node-Red dashboard.

But coming back to your case, you can control how the quad behaves in terms of RTH - you can configure the APM settings when it’s triggered. By default I remember that in Auto mode, that is when it executes a planned mission, it doesn’t require connection to the remote controller, BUT if your RTH includes loss of comm with the ground base station then to trigger RTH. You have to check these settings in the quad’s setup in Mission Planner - it’s much more friendly and more accurate in configuring all settings related to the APM side of things.

EX4 doesn’t have SSH access, I tried scanning all the open ports, none of them is for ssh, so only way to change something on the drone Linux OS is via FTP, on ftp, the ssh file/ssh configuration doesn’t exist, I think manufacturers removed it on purpose, but you can still edit the wireless configuration on ftp.

You can also use zerotier, or if you have a public IP address that doesn’t change frequently on your home, you can set up a Wireguard/OpenVPN server on your home, install vpn client on raspberry pi, this is what I did:
Installed pivpn Wireguard server on my home, then following this tutorial, I set up a VPN client on the raspberry pi.

Wireguard is way faster than OpenVPN, so I recommend using that.

I also found this in QGC safety tab:

I can change it from “Enabled always RTL”, to “Enabled Continue with Mission in Auto Mode”
After changing it, it shouldn’t return to me if I lose the connection with the controller in Mission?
But what about when I am flying it manually, will it return after losing connection?

Since you change the behavior when losing connection with the ground station then if you fly it manually and you turn off the controller or it loses connection it won’t come back. You’d need some other way to trigger the RTH like low battery or hitting the geofence limit as computed from the take off point.

My home public IP address is dynamic so theoretically it changes whenever the DHCP expires but since my modem is almost always on I seldom see it change. But I’d rather not rely on IPs instead use FQDN but that would require even more configuration on my end.

I’m also thinking about getting something in a cloud somewhere, a server/router and a couple of public IPs to setup a globally accessible resource which would reduce my dependency on my home network. Granted it would cost me a monthly penny that I’d have to pay just to have at my disposal and since I’d be doing this purely as a hobby it’s hard to justify, yet, making that kind of subscription to a cloud service somewhere.
I’m into IoT as well so it could come in very handy, got lots of ESP8266s and ESP32s that I would just love to make IP-independent. But anyways, I’m still considering options at the moment so will see.

I have a VPS server, I pay 5$ monthly for it, I have set up OpenVPN server and some other stuff on here.

Can someone who has Eachine EX4 (not pro) post what this file contains for you in drone’s FTP server: /netPrivate/hostapd.conf

I want to make my Eachine EX4 Pro to have it’s own WiFi AP.

I have another question, let’s say a drone is flying it’s misssion, can I interrupt it by manually controlling the drone with controller if it’s close to an object? Or will the controls won’t work, would pausing the mission (if it’s possible) would let me controll the drone manually?

And which raspberry pi are you using? If your’e using rpi zero, how did you connect the 4g modem via usb and the drone’s usb connection as well if rpi zero only has one port?
I tried fitting rasperry pi 1 on the drone’s top but it’s way too big and the proppelers hit it, so the only solution is to mount it on the bottom which is not a permanent solution, because I would have to remove the rpi if I wanted to remove the battery.

For the behavior of Pixhawk during Auto missions you should check the ArduPilot or Pixhawk documentation. I know PX4 has a somewhat different way of handling MAVLink commands. If you can connect the EX4 to Mission Planner you could try to fly a simulated mission using the quad but without its propellers attached so it won’t actually take off and smash into walls/children/old folks. I did that when I was testing my IoT setup so I could control the drone from a web page hosted on the IoT platform.

I’ve been using Raspberry Pi Zero W and a RPi 4B with 8GB of RAM and quad processors in my projects. As you mentioned the lack of USB ports on the Pi zero has to be compensated so instead of going for the GPIO pins, I used a USB Hub. I did make use of the serial comm port pins on the Pi Zero to hook a Melexis MLX90640 32x24 thermal camera/sensor and since I had the free USB port I also attached a webcam that I tweaked a bit so it can see in the dark (i.e. removed the IR filter and added an IR 12V projector) The whole setup is powered by a 3S 1Ah LiPo pack which is pretty much the size of the RPi zero W. I also made some modifications to a Python script I found on the net from a guy for converting the thermal pixels into usable images. Now I have a “poor man’s” FLIR camera with pseudo-MSX features. It’s amazing how much stuff is available in the OpenCV library, even for low power platforms like the Raspberry Pis.

Thanks for answering. I will try simulating the mission without props.
Can you post a picture of how you mounted the raspberry pi zero on EX4?
And with raspberry pi zero usb hub hat, is there space to connect raspberry pi camera under the hat?

hostapd.conf.txt (2.8 KB)
Hi Arminas, voilà!
I have (unfortunately) an EX4 1 km drone; this is what you were looking for.
(Pls remove the .TXT extension)

1 Like

Okay, so what I’ve done here is really stupid, I was comparing the hostapd file that you sent me with the original file in the drone and somehow accidentally saved it and now the drone doesn’t connect to the controller, tried scanning for wifi’s in controller’s ssh, it doesn’t show up. I lost access to the drone’s linux system. Will I need to replace this board? Or can I somehow reflash it/reset it?
And the drone’s power button doesn’t work, I can’t turn it on/off unless I connect it to usb, the lights also doesn’t blink on the button.