Testing 868MHz LoRa range, part 3: round trip

After determining that range of 868MHz LoRa wireless modules E45-TTL-100 have, at least, quite impressive range (5,7km and I was out of line-of-sight to test further) I’ve decided to test something else.

In the beginning I was planning to use those radio modules for telemetry only, but then another thought crossed my mind: why not to build DIY TBS Crossfire for the poor? After all, TBS Crossfire also uses 868MHz LoRa (SX1272 vs SX1276), so it should be possible to build DIY radio link for medium range (up to 5km) for RC planes, right?

First of all, I will need to know how fast data can be transferred and how much delay can I expect in real life. So I’ve modified Arduino code and E45-TTL-100 configuration:

  • UART speed bumped from 9600bps to 57600bps
  • air speed bumped from 2400bps to 19200bps
  • output power lowered from 100mW to 50mW (17dBm)
  • transmitter sends 5 bytes of data (current microseconds and prefix)
  • relay receives packet and resends it to transmitter
  • current received number is deducted from current microseconds and round trip time is showed on OLED display

LoRa E45-TTL-100 round trip test

Results:

  • Round trip time is 82ms on average and it does not changes with distance
  • at lower output power (50mW vs 100mW) reception at 2.8km is worse. 100% of packets are received only then antenna alignment is not worse than 45 degrees
  • with slightly bigger payload size (up to 7 bytes) it should be possible to archive at least 20Hz update rate

Read More

Project “Dropship glider” – introduction

When I saw this video from rctestflight I knew I will build something like that for myself. A voila, few months later it is done. Here is Dropship Glider.

Dropship glider - depron FPV delta glider

It is 29cm long with 20cm wingspan. Weights 97g AUW and has 21g/dm^2 wing loading. So, in theory, should glide. Somehow… If I got center of gravity right. And did not made ailerons too big. Or…

Dropship glider - depron FPV delta glider

Delta 6mm Depron "wing" is attached to 6mm carbon fiber rod and has some quite big dihedral: 15 degrees.

Dropship glider - depron FPV delta glider

The biggest problem was radio link and mixer for ailerons. I could not use my Taranis: I need that for a carrier and only radio control link I had was EM-16 with PPM output only and no way to setup any kind of mixer. The radio just has no "features" like that…

So, took one Arduino Pro Mini and wrote short program that acts as PPM decoder and mixer for ailerons.

Dropship glider - depron FPV delta glider Arduino

  • power is supplied by 1S LiPo taken from my Tiny Whoop
  • FPV AIO Eachine TX02 also taken from my Tine Whoop
  • 5V is supplied from cheap, regulated, step-up converter
  • 3rd servo is to release tether

First flight, or rather drop, tomorrow. There will be a video from the event of course…

Read More

How to read PPM signal with Arduino?

More than a year a published a post called Generate PPM signal with Arduino. Today it's time for part two: How to read PPM signal with Arduino?. Strange thing: internet does not gives very useful information on this topic. Strange, right? Some links to pages that does it either very very wrong or in not simple way.

There is a one almost good solution. It's an example code by Hasi123. Short, efficient and actaully works almost out of the box. But it has 2 problems:

  1. It is not a library. You have to copy paste code
  2. It alters Timer1 and that means, that many other things stops to work: PMW output, Servo library or anything else that uses Timer1. Crap…

So, I've invested some of my time and, based on that code, I've created Arduino library called PPMReader. Advantages?

  1. It is a library (!)
  2. It does not alters any timers (!)

Example code, that reads PPM signal connected to Pin 2 of Arduino Uno or Pro Mini (and other using ATmega328) and prints decoded channels over serial port would look like this:

#include "PPMReader.h"

// PPMReader(pin, interrupt)
PPMReader ppmReader(2, 0);

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  static int count;
  while (ppmReader.get(count) != 0) { //print out the servo values
      Serial.print(ppmReader.get(count));
      Serial.print("  ");
      count++;
  }
  count = 0;
  delay(500);
}

The only required configuration is a decission of a pin and interrupt. Not all pins have hardware interrupts, so on many boards this is limited to:

  • Arduino Uno, Pro Mini and other based on ATmega328: pin 2 / interrupt 0 or pin 3 / interrupt 1
  • Arduino Pro Micro and other based on ATmega32u4: pin 3 / interrupt 0, pin 2 / interrupt 1, pin 0 / interrupt 1, pin 1 / interrupt 3, pin 7 / interrupt 4

PPMReader Arduino library can be downloaded from GitHub.

Read More

FS1000A and XY-MK-5V, Arduino and VirtualWire

While FS1000A and XY-MK-5V 433MHz radio modules might not be the best choice in terms of quality, or reliability or distance (although few hundred meters in open space are doable), they have one very important trait: they are extremely easy to use. No complicated wiring, no advanced programming. If you want to send some data, just connect data lines, supply voltage and write few lines of code. Super simple!

In example below, we will be sending a single 8bit number over FS1000A->XY-MK-5V line with a help of VirtualWire library.

Please remember, without antennas and in radio-noise rich environment, range might be limited. Very, very limited. Even to just a few centimeters. So keep that in mind!

Transmitter

FS1000A transmitter Arduino

Receiver

XY-MK-5V receiver Arduino

Read More

FS1000A and XY-MK-5V 433MHz RF modules: overview

One of the cheapest (but not the best) solutions for DIY wireless data transmission between different devices (Arduino and other microcontrollers) is a pair of 433MHz modules: FS1000A and XY-MK-5V. A set of them (you will need one transmitter and one receiver) costs about $1. Pretty cheap, right?

FS1000A and XY-MK-5V

Of course, there is a price to pay. Those modules are as simple as possible. They do not offer anything like error correction, RSSI, frequency hopping, or even two directional transmission. They offer only basic functionality: receiver reports digital ONE when transmitter detects ONE on the input (if in range, of course). Everything above that has to be done in the software. Continue reading “FS1000A and XY-MK-5V 433MHz RF modules: overview” »

Read More

Programming ESP8266 with Arduino IDE

One of the best things about ESP8266 ESP-01 WiFi modules is that they can be programmed
using popular and well known Arduino IDE and act as stand alone board with WiFi
capabilities. Thanks to ESP8266 group process of integrating ESP8266 and Arduino IDE
is pretty simple.

First step is to add http://arduino.esp8266.com/stable/package_esp8266com_index.json to Additional Boards Manager URLs in Configuration in Arduino IDE.

Continue reading “Programming ESP8266 with Arduino IDE” »

Read More

Generate PPM signal with Arduino

In the beginning of this year I’ve written a short tutorial how to read PWM signals from RC radio with Arduino. While it is can be useful when building own RC equipment, it does not help much when one has to deal with PPM (CPPM) signal. Let’s be honest, PPM is much more useful than PWM: all RC channels are sent over single wire. On one side, it simplifies electrical design. On the other, it makes software part more “complicated”, since there is a need to encode multiple PWM channels into single PPM line in transmitter, and then decode PPM signal into multiple PWMs in receiver. And there are very little “ready and working out of the box” solutions in Arduino world.

In this short article I will show how to generate PPM (CPPM) signal using solution prepared few years ago by David Hasko. Originally it was posted of Google Code. But Google Code is not closed and who knows for how long it still will be available. So, let’s not let the knowledge got lost.

Code is relatively simple, and almost all work is done inside ISR(TIMER1_COMPA_vect) that is executed in the background by timer . Everything user has to do, is to put desired values to ppm array inside loop function. This code can generate both positive and negative signal. It can be easily ported to almost any project, as long as TIME1 is free to use.

Slightly more advanced example is available on GitHub.

Read More

How to measure battery capacity with Arduino

Battery capacity measurement can be useful in many situations. And it is not hard, only requires enough time to discharge battery completely with know resistance and a way to measure voltage in the circuit. Ohm’s law will to the rest: I = U / R

Let’s say, we want to measure standard AA 1.5V alkaline battery capacity. Why 1.5V? They are common, made by many manufacturers and sold for different prices. And not always more expensive is better. To do this, we will need:

  • AA 1.5V battery
  • resistor to discharge it. We need high current to discharge battery in reasonable time, so low resistance is suggested. On the other hand, high current means o lot of heat, so we need a resistor that can survive this. I suggest using 2.2Ohm 5W ceramic resistors.
  • Arduino to measure voltage in circuit. Any Arduino or plain ATmega or ATtiny with A/D converter will do.

So, first a simple electrical circuit:

how to measure battery capacity with arduino

And some code that will be run every second:

voltage = 5.0 * ((float) analogRead(V_METER)) / 1024.0;

float current = voltage / R_LOAD;
joules += voltage * current;
float wattHours = (joules / 3600.0) * 1000.0;

And here how it work:

  1. We need to measure voltage in circuit. This is why, in first step, we read 10bit A/D converter and scale output to 5V. Why 5V? Arduino Uno works on 5V, and it is the reference voltage here,
  2. Next, lets compute current using Ohm’s law I = U/R,
  3. With know current current we can compute work using P = U * I and store it in joules variable,
  4. Last step is to change joules to Watt hours.

If instead of Watt hours we want Ampere hours, there is no need to count joules. Instead of that, sum current and final value divide by 3600 (there are 3600 seconds in one hour). Like this:

voltage = 5.0 * ((float) analogRead(V_METER)) / 1024.0;

float current = voltage / R_LOAD;
ampereSeconds += current;
float ampereHours = ampereSeconds / 3600.0;

Full code is available here

Notes

  • this circuit allows to measure batteries with voltage up to 5V. Anything above it will damage A/D converter
  • to measure higher voltages, voltage divider will be required
  • with higher voltage, power loss on resistor will increase. It will get very hot and might burn

Read More

VirtualWire support for Raspberry Pi

FS1000A and XY-MK-5V 433MHz RF modules are very often first choice for cheap and dirty Do It Yourself wireless communication. Pair of those , allowing one way radio communication, const less than 3 dollars or euros. So they are really cheap. Limited range and transmission speed limits their real life usage, but simple assembly and extremely easy programming are additional advantage over more complex solutions. Specially in Arduino world, with VirtualWire library. I will not write about it right now, there is enough on the internet already.

FS1000A and XY-MK-5V 433MHz RF modules for Raspberry Pi

Continue reading “VirtualWire support for Raspberry Pi” »

Read More

Programming ATtiny85 and ATtiny45 with Arduino IDE

What is ATtiny

ATtiny is a fimily of microcontrollers by Atmel, the same company that provides ATmega series used widely in “real” Arduinos. Comparing to ATmega, ATtinys are much simpler, smaller (usually), with less features. But also cheaper, easier to connect, using less energy, and trust me, in many many cases you do not need 32kB of flash memory. If, for example, you want to build a device that will beep every 10 minutes which microcontroller would you use: huge DIP-28 ATmega328P from Arduino UNO R3 or small DIP-8 ATtiny25 that ususes way less power and costs around 1EUR? I would use ATtiny.

ATtiny85 as light sensor with I2C bus

There are many microcontrollers in ATtiny family. In this tutorial and all future in this series I will concentrate on ATtiny85 with 8kB of flash memory. There are 2 simpler versions of it: ATtiny25 and ATtiny45 with respectively 2kB and 4kB of flash, but price difference between them is so small, that I see no point of trying to use them. When buoght from China, it might be even possible to buy ATtiny85 cheaper than its smaller brothers. Continue reading “Programming ATtiny85 and ATtiny45 with Arduino IDE” »

Read More