Crossbow LRS, I’m still doing this wrong…

Only two weeks ago I thought I solved all my major problems with DIY LoRa RC link. I was wrong. I was able to solve one problem (link unstable due to rouge packets messing up with protocol decoding), but an old problem came up again: PPM input from Taranis is no longer stable. At least I know why since this is a second time this is happening.

Current code read bytes from SX1276 buffer inside interrupt callback procedure (ISR). PPM decoding is also done in ISR. How many threads ATmega has? What happens when one ISR is triggered while second is still executed? Problems. The solution is to keep ISRs as simple and fast as possible. My code was not simple and fast enough.

On top of that, it turned out that Arduino LoRa library I’m using is not efficient. It performs 2 SPI transactions to read one byte from SX1276 FIFO buffer. So, 12 bytes of typical data packet equals 24 SPI transaction… Looks like I will have to do some low-level coding I wanted to avoid in the beginning… Oh well…

Read More

Arduino hygrometer with DHT11 and SSD1306 OLED display

One of the things I like about Arduino ecosystem is that you can prototype pretty decent device in very short time. It might not be pretty, but will work. Just like my DIY hygrometer built with DHT11 and SS1306 OLED display I've built few weeks ago:

Simple, efficient and runs on 4 AA batteries. The best part is that it can be powered all the time. Arduino does humidity measurement, display the result and then powers itself down to conserve power. Cool, right?

Arduino DHT11 hygrometer with OLED SSD1306 display

Code is available in GitHub repository.

Read More

Visual Studio Code as Arduino IDE replacement

I can say a lot of good things about Arduino ecosystem. List will quite long, trust me on that. But Arduino ecosystem has one thing that sucks a lot: Arduino IDE. Programming environment for Arduino is crap. Period. I would not call it the worse development environment ever, but it's pretty close to that title. C'mon, Turbo Pascal from the early nineties of previous century was a better IDE!

There were few project to fix that problem. Somehow none of those really worked until Microsoft did not decided to do something about it and created

Visual Studio Code extension for Arduino

Arduino for Visual Studio Code
Continue reading “Visual Studio Code as Arduino IDE replacement” »

Read More

Arduino, ESP32 and 3 hardware serial ports

When working with ESP32 WiFi/Bluetooth MCU under Arduino SDK for ESP32, you will notice that Serial work just fine. But Serial1 and Serial2 do not. ESP32 has 3 hardware UARTs that can be mapped to almost any pin. But, Serial1 and Serial2 will not work. In case of ESP32 this just has to be done in a slightly different way:

The trick is to use HardwareSerial library to access UART 1 and 2 instead of Serial1 and Serial2

  • Class HardwareSerial accepts one parameter in constructor, it is a number of UART. Values from 0 (UART 1) to 2 (UART 3)
  • HardwareSerial(0) is the same as Serial so be aware
  • begin method accepts 4 parameters
    • baud speed
    • UART mode
    • RX pin
    • TX pin

The real beauty of this solution is that almost any pin can be used as TX or RX pin for any UART. Most ESP32 dev boards have labels like TX2 or RX2, but you really do not have to exactly those pins. Every other GPIO pin can act as Serial RX, but only the ones between GPIO0 and GPIO31 can be used as TX. Still, that gives plenty of pins to choose from…

Read More

Crossbow LRS, hardware

Weather outside is bitchy. Period. It rains, then it's windy and then maybe there is some direct sunlight for 15 minutes. No way to fly or test my DIY RC radio link.

Weather is bitchy

But, there is some progress after all. My latest changes seems to be working just fine. On a bench link was stable for almost 3 hours. Later I too it for a standard range test: 2.8km LOS. It also worked, I still had around 5dB of link budget left on a ground level.

Back to the topic. Crossbow LRS is open source and open hardware. Maybe open hardware is too much, since there is almost no hardware to build. After all, first iteration is based on LoRa32u4 II development boards and running good old Arduino.

RX module requires no additional hardware:

Crossbow LRS receiver module

TX module is slightly more complex. It required voltage stabilizer and inverter/level shifter made with single 2N7000 FET transistor. I2C OLED display is an option:

Crossbow LRS transmitter module

Read More

A proper way of doing read callback receive with Arduino LoRa

Arduino LoRa is a great library that brings LoRa support (SX1276/SX1277/SX1278/SX1279) to Arduino world. I'm using it in my Crossbow LRS project (still not stable enough for flight, work in progress). Until now, the biggest problem with this library I've found is that examples suggests that heavy protocol processing inside interrupt callback is fine.

Unfortunately, it is not. It can lead to unexpected processing delays, create conflicts with other interrupts, bus clashes and other hard to debug things. This is why, the better way is to do packet reading (and processing) inside main loop and use read callback only to set a flag. Like this:

Only please remember to set all variables modified in ISR routine as volatile.

Read More

Hands on: LoRa32u4 II 868MHz LoRa development board

Idea for Crossbow, DIY LRS system did not appearned in my mind out of nowhere. All my previous LoRa attempts were aimed at telemetry purposes only. E45-TTL-100 are cool, but bulky. If I would want to use them, I would either have to attach Arduino to it or hack it open and reprogram onboard CPU (like Qczek LRS does). Somehow it was not something what suited me very much.

But then I came across Adafruit Feather LoRa32u4 RFM95. Awesome idea. ATmega32u4 and HopeRF RFM95 LoRa module on one PCB, Arduino compatible, reasonably small and light. As a bonus, can be LiPo battery operated and has own 1S LiPo chanrger. The only thing I did not liked (OK, not the only one, but that was the biggest one) was price tag: $34.95 is somehow slightly more than I'm willing to pay for ATmega32u4. Even with radio module. So, after some digging on eBay I've found something that looked like a clone of Adafruit Feather LoRa32u4 RFM95: BSFrance LoRa32u4 II.

LoRa32u4 II 868MHz LoRa development board

BSFrance LoRa32u4 II 868MHz LoRa development board

Continue reading “Hands on: LoRa32u4 II 868MHz LoRa development board” »

Read More

QuadMeUp Crossbow LRS: introduction

Few days ago I mentioned that I'm working on my own DIY long range radio system (LRS) that I named QuadMeUp Crossbow LRS. Today I will share some more details about it.

First of all, I'm not creating anything new or "amazing". There are plenty of "DIY" or OpenSource LRS systems. OpenLRS for example. Or QCZEK LRS that is made from almost nothing at all. And amazing commercial systems like TBS Crossfire.

Is there a place for something else? I think there is. For example, I was so pissed of by complexity of OpenLRS. So many options, so hard to understand. Or do you know how much micro RX for Crossfire costs? And that you do not need 2W of power to fly up to 5km? And most of pilots owning Crossfire never flied > 2km?

This is why, my idea for DIY LRS is:

Continue reading “QuadMeUp Crossbow LRS: introduction” »

Read More

Generate S.Bus with Arduino in a simple way

Did you noticed that lately I write about radios quite often? Well, I do and it's not a coincidence. Proper introduction for what I'm working on will happen in a next few days, but now I will only write that this will be a mid-range, cheap, DIY radio link for UAVs. By mid-range I mean up to 5km. So, it will be positioned somewhere between 2.4GHz systems and full sale LRSes like DragonLink or TBS Crossfire.

Back to business. I've discovered, that there is very little in The Internet how to generate S.Bus with Arduino. OK, there are few libraries for reading Futaba S.Bus protocol like mikeshub/FUTABA_SBUS or zendes/SBUS but the only library made simple I've found is bolderflight/SBUS. Too bad it works only with Teensy devices. So, after a few hours of hard work, reading code of OpenTX, MultiWii, INAV, reading RcGroups and final help of Konstantin Sharlaimov (Digital Entity of INAV), I give you:

Generate S.Bus packets with Arduino in a simple way

But first, few simple facts:

Continue reading “Generate S.Bus with Arduino in a simple way” »

Read More

E45-TTL-100 not transmitting when connected to Arduino

While working on one of my project involving Arduino and E45-TTL-100 LoRa 868MHz radio modules, I've discovered that it is not working exactly like expected. Documentation states:

(…) When the data inputted by user is up to 58 byte, the module will start wireless transmission (…)
(…) When the required transmission bytes is less than 58 byte, the module will wait 3-byte time and treat it as data termination (…)

If I understand this correctly, E45-TTL-100 should begin radio transmission when:

  • 58 bytes were sent via serial port
  • serial transmission stopped for 3 bytes. So, at 9600bps, 3ms pause whould trigger transmission
void loop() {
    Serial.print("Test");
    delay(100);
}

In theory, code from the able should send string "Test" every 100ms. Unfortunately, it was not happening. Second E45-TTL-100 was not receiving anything. Also SDR dongle was not catching any transmissions. Something was wrong. I even contacted CD Ebyte, but they were unable to help me and The Internet was equally useless. What was wrong? No idea… looks like some kind of E45-TTL-100 MCU bug…

The solution

The solution is, hmmm, surprisingly simple. You not only have to stop transmitting, but also end serial port (Serial.end()) and open it again (Serial.begin()) after short period of time. In my experiments I've determined that 20-30ms of closed port selves the problem. So, code from above should be replaced with following:

void loop() {
    Serial.print("Test");
    Serial.end();
    delay(30);
    Serial.begin(9600);
    delay(70); //The rest of requested delay. So 100 - 30 = 70
}

It might not be the prettiest solution ever, but it works.

Read More