DIY Telemetry and Control

Inq

Elite member
I want to start a thread on exploring the use of microcontrollers onboard RC airplanes. This will likely be a long term project and I won't really get into it until after FTFC23 is over. I know several other forum members have experience in this area. Maybe we can trade notes and all learn something. Anyone's ideas, suggestions or experience in this area is welcome. I'm not wanting turnkey solutions that tend to cost north of $20 US. I prefer to get my hands dirty to keep learning. I'm talking about home-brewing a whole system for about $10 US. I would like to get real-time data for gauges and such as well as data collection for black-box post mortem analysis :rolleyes:. A little soldering, a little programming and Voilà! I want start with just the readings side and include:
  1. LiPo voltage so I can more intelligently know when its time to land. From EDF jets that guzzle energy to sailplanes that sip it. Using a timer is just not cutting it.
  2. Current draw
  3. Motor temperature - I've burned one up trying to fly upwind back to the landing site - https://forum.flitetest.com/index.php?threads/inqd-turbo-storch.71382/page-4#post-738136
  4. ESC temperature - Ditto - https://forum.flitetest.com/index.php?threads/what-did-you-crash-today.23426/page-85#post-739293
  5. Altitude
  6. Air speed
  7. Propeller rpm
I'll be using the WeMos D1 Mini that can be had for around $3 to $4 US depending on how many you purchase. I'll be using a host of sensors and I'll be using and the Arduino IDE to do the software on the microcontroller.
1676809554144.png
 
Last edited:

Inq

Elite member
LiPo Voltage
This first item as you all already know determines how long you can fly your airplane. All the guys at my field simply set some timer on their transmitter and it talks to them when its time to come down. I'm assuming they've over time gotten a feel for it. However, I may fly hard and fast one flight or settle for a laid-back cruise. One lasts a lot longer than the other.

Measuring the receiver voltage doesn't really accomplish this. It's connected to your BEC regulator in your ESC (typically). So, it should be delivering ~5V no matter what your battery is delivering.

Fortunately, it is the easiest and cheapest to gather this data. All you need is a resistor dependent on the number of cells you're using. Below are the resistor values you'd need. Most resistors don't come in the exact value we need. You can combine them in series and sum the values or just use the next highest one. In example... using a 3S battery, the exact resistance needed is 940KΩ. I'd just use the next closest one at 1MΩ. We'll make adjustments in the software to account for the differences (Just not in this post).
1676830510774.png


Using a breadboard, the resistor is hooked to the A0 pin on the Wemos board. This goes to the positive lead of your LiPo battery. I'll probably just make a pass through plug that connects between the battery and the ESC so I can move it from plane to plane. The leads to the 5V and G pins come from your BEC. I'll use a wire connector from a destroyed servo and just hook it into the receiver.
1676830338562.png
 

Inq

Elite member
Exploring Pressure Sensor
A pressure sensor can allow us to do altitude calculations and with a pitot tube configuration, we can get airspeed. I'm using a BMP280. Depending on quantity, you can get these for about $1 a piece in quantiles of 10. I'm usually buying for myself and for students. You'd need two to get altitude and airspeed. These are absolute pressure sensors (not differential sensors).
1676844596201.png

@telnar1236,
Here is some raw pressure data. This is collecting data at about 27 Hz.
1676845454729.png
Here is a sample set of raw data for altitude where I moved the sensor from the floor to my arm reach (~7 feet) and back to the floor.
1676845731419.png
 

Inq

Elite member
... more pressure sensor data.

Interesting that they had defaults of 16x oversampling, but had the IIR filter off. I turned it to its maximum and it cleans up the data immensely. Same test... sensor on floor raised 7 feet and then lowered back to floor.

1676848077105.png
 

CapnBry

Elite member
Something you might also consider is using an ExpressLRS receiver as your controller (replace the existing firmware). They use the same ESP8266 chips (with onboard flash so they are called ESP8285s) and have an onboard LoRa modem which can work at 100km on 2.4GHz. The onboard wifi antenna is just as terrible as the Wemos D1 Minis so you won't get much range from them, but it might be interesting to try some sort of hybrid using the two different types of transmitters.

It would be easiest to interface with one of the PWM receivers which has 5 or 6 of the pins broken out to the PWM header, which you can use to connect to whatever you like, such as a pressure sensor. Some even have a pin wired up to the ADC with a divider for a VBAT sensor. The programming is the same as you've been doing already too since it is the same MCU! You will definitely want to get an FTDI cable to flash though because there is no onboard TTL to UART converter, and you will eventually upload something bad over wifi (trust me).

To be clear I am not saying "just use ExpressLRS". Just that some of their hardware hits your price point in a convenient (and tiny) package which makes it easy to get things working without having a mess of wires on breadboards and then you can go from there adding on. Also, keep up the good work! Always exciting to see new people building and trying new things.
 
  • Like
Reactions: Inq

Inq

Elite member
Something you might also consider is using an ExpressLRS receiver as your controller (replace the existing firmware). They use the same ESP8266 chips (with onboard flash so they are called ESP8285s) and have an onboard LoRa modem which can work at 100km on 2.4GHz. The onboard wifi antenna is just as terrible as the Wemos D1 Minis so you won't get much range from them, but it might be interesting to try some sort of hybrid using the two different types of transmitters.

It would be easiest to interface with one of the PWM receivers which has 5 or 6 of the pins broken out to the PWM header, which you can use to connect to whatever you like, such as a pressure sensor. Some even have a pin wired up to the ADC with a divider for a VBAT sensor. The programming is the same as you've been doing already too since it is the same MCU! You will definitely want to get an FTDI cable to flash though because there is no onboard TTL to UART converter, and you will eventually upload something bad over wifi (trust me).

To be clear I am not saying "just use ExpressLRS". Just that some of their hardware hits your price point in a convenient (and tiny) package which makes it easy to get things working without having a mess of wires on breadboards and then you can go from there adding on. Also, keep up the good work! Always exciting to see new people building and trying new things.

I'll definitely look into this. I haven't done the actual hookup from FlySky receiver to Arudino (ESP8266 actually) via the iBus. From what I gather the transmitter is very limited in how much of the data I can present (to me). In this situation, the ESP8266 is only being used for its processing/sensor interaction. It is not using its WiFi. I want to experiment with using its WiFi in addition to the RC transmissions. I would like to see if I can WiFi to my phone, tablet, laptop etc and present a whole dashboard of data.

One article said they would interfere with each other and crash your plane. Other's say... nah, they won't. I also have the external antennas that have been tested out to multiple miles using plain old WiFi and not resorting to LoRa. I've never explored LoRa, and always had the impression it had very limited data rates, but I'll definitely check this out! Thanks.
 

Inq

Elite member
i still haven't tried mine but these little raspery pi picos can do wifi. https://www.amazon.com/dp/B092S2KCV2/?tag=lstir-20

They're very popular on the robotics forum I haunt. I really haven't looked into them. I looked at the spec's and it seems to be about the same capabilities as an ESP8266... some things better, some worse, but way shy of an ESP32. But, the main reason... I built a library years ago that puts a full functioning webserver on an ESP8266. https://inqonthat.com/inqportal-the-three-line-promise/ I've never ported it to the Pico.

It allows me to many things very easily. Like this... real-time histogram of the pressure sensor is only about 3 lines of additional code to get this on my desktop, tablet, phone. I'll be able to make full cockpit of dials, again that will be visible in any browser... on cay my phone while I'm flying (if WiFi can reach that is ;)). Probably could even find JavaScript gauges that look like they belong in a cockpit.
1676994323778.png
 

CapnBry

Elite member
i still haven't tried mine but these little raspery pi picos can do wifi. https://www.amazon.com/dp/B092S2KCV2/?tag=lstir-20
Those actually can not. The RP2040 does not have integrated wifi, it relies on an external wifi chip which are not present on those boards.

There's plenty of CPU time available on the ESP8266 to do both wifi and run a control link and sensors, but it does have limited I/O capabilities (at most 6 pins, some of which are shared with bootstrapping functions). There's also the ESP32-PICO-D4 which is the dual core wifi ESP that also includes a lot more GPIO to mess with, there are some ExpressLRS receivers with these as well and virtually all ELRS transmitters use ESP32s in one form or another, but just for experimenting and prototyping the wemos D1 mini (ESP8266) or ESP32 dev boards work great, I have multiple within reach on my desk.

I've also used bluetooth and wifi right next to the receiver and it works fine with LoRa on the control link, but Flysky uses FSK which maybe won't do as well. Either way it's worth a try and I think it will work just fine. You're right about LoRa having limited bandwidth, it is about 50kbit for 2.4GHz ELRS-- less than a modem in 2000 would have but hey, we used to get the entire internet through that so how hard could it be to just send some control and telemetry? :-D
 
  • Like
Reactions: Inq

Inq

Elite member
I've also used bluetooth and wifi right next to the receiver and it works fine with LoRa on the control link, but Flysky uses FSK which maybe won't do as well.

Cool... I hope it'll be able to run parallel.
 

Inq

Elite member
Did a run from the house, down to the main road and back to get a little more RC plane altitude variability.
alt.png
 

Inq

Elite member
Dynamic Pressure Reading

This is simply reading the pressure of a sensor inside a chamber with one opening facing forward. In this first experiment, the testbed above is simply using a coffee stir straw as a pitot tube sticking out the nose of a representative nose cone of a model plane. On the other end of the tube, we need to place the sensor in a sealed chamber. Here, we have the BMP280 sensor and a 3D printed chamber to try out.
Parts.jpg


In this image, we have the sensor placed away from the incoming port. I'm just guessing it might be a good idea not to have the sensor hole directly under the port hole.
Placed.jpg


Here it is all sealed up and ready for a test run... I've sealed it up using acetone thinned ABS plastic to cover the porosity that 3D printing can have as well as the wires exiting the chamber and the tube exiting the port.
Sealed.jpg


Here, it is hooked up to the breadboard along with the static sensor. A little coding to plot the data and it should be ready to test tomorrow.
Breadboard.jpg