Introduction: RotorHazard FPV Timer - OTA Updater and Manager

If you are using RotorHazard FPV race-timer or Delta5 timer - this tutorial is for you.

It will bring new functionalities to your timer and you will have ability to update server
and nodes "Over The Air". Consider this as a combined improvements for software and hardware.
You can use both or utilize just one of those.

Time required: ~1 hour

Before you start:

  • Collect all required components.
  • Make sure that you have internet connection.
  • Read this instruction at least one time before performing the mod so you will know what to expect.
  • You can also read about history of this project later in the instructable.

Disclaimer/plans:
Obsolete: There is a good chance that in few weeks (Q1/2020) much simpler method of flashing will be provided. Feel free to use software right now, but if you are concerned about all wiring that is required right now - some people are - you may want to wait. Nevertheless - method existing right now is proven to be working so you can act right now :)
Edit (Q4/2020): This manual would work but there is much newer schematics and features now. Following newer schematis and using official RotorHazard PCB is adviced (but not necessary). :)

Supplies

  1. RotorHazard race timer (already made or just components of it)
  2. About 50 cm of thin wire + jumper wires or tool for attaching female gold-pins to the wire
  3. Soldering iron + solder
  4. 2 resistors: 5kOhm and 10 kOhm - or any other combination with 1/2 ratio in 5-20 kOhm range
    OR 3 resistors of the same value in 10-20kOhm
    OR logic level converter - but using resistors is easier
  5. Few male and female gold-pins - optional
  6. PC connected to the internet
  7. miniUSB to USB A cable - probably

Step 1: Prepare Your Arduinos

Make sure before any attempts of using this software and going further, that your Arduinos DOES NOT contain any programs utilizing serial connection. Basically "Serial.begin" cannot be implemented on them. Last official code from RotorHazard repository had that feature enabled so if you already used to use that firmware you have to wipe it out. Just flash Arduinos again using PC and USB cable before embedding nodes in the timer. You can flash anything on them, for example "Blink" sketch - from "Examples" menu.

If you have newly bought Arduinos - you are most likely safe and you can skip this step.

You would have to do it just once - before placing Arduinos in the timer.

It is explained in FAQ and "history" step why is it crucial

Link to Arduino IDE download page:
https://www.arduino.cc/en/main/software

Important: If you want to proceed with hardware-based steps for now and do this step later - it is ok. Just remember to do this before embedding Arduinos in the timer.

Step 2: Make Additional PCB Wiring - TX/RX Line

Connect all of the TX pins together and all of RX pins together - on Arduinos.
You can do it underneath the PCB so it will still look clean at the top.

Only the white and purple wires on the photo are UART lines. Rest of the cables are reset lines and can be connected from the other side. You can do it however you want.

If you have 2 PCBs connected together - connect all of the pins RX/TX pins from both PCBs.

I soldered two male gold-pins to one of the Arduinos so I have RX and TX line exposed near the Raspberry.

You can do it the same way.


If you are starting with your build from the skratch - assemble your PCB according to instructions from RotorHazard or Delta5 timer page, before adding mods mentioned above. Edit: In this case it is better to just use official RotorHazard 1.2 PCB with this feature built-in.

Step 3: Make Voltage Divider or Use Logic Level Converter

The common Arduinos RX line has to be connected to Raspberry’s TX pin (pin 8 - UART0 TX).
Arduinos TX pins have to be connected to Raspberry’s RX pin (pin 10 - UART0 RX) via voltage divider or with logic level converter. It is caused by the difference of voltage tolerance between the Arduino and the Raspberry. Arduino operates at 5V logic level and Raspberry at 3.3V. Converting the logic level is only required on the line where Ardunos TXes are connected to Raspberry's RX, cause Arduino transmits at 5V.

On the other line the Pi is transmitting at 3.3V and Arduinos are only receiving so it is save without voltage divider or level converter.

I placed small PCB with the voltage divider on RX and TX pins. You don't have to do it this way. I just didn't want to have more cables than needed in my timer.

You can just make "Y" shape divider as a part of the cable - photo attached.

You can make voltage divider in very smart way by utilizing 3 resistors of the same value. Two of them connected parallelly which effectively makes them combined resistance halved - see the photo.

IMPORTANT! Don't make mistake with TX/RX. 5V is too much for Raspberry's pins on UART line!

Small help with calculating resistor values:
http://www.ohmslawcalculator.com/voltage-divider-calculator

Step 4: Connect RST Pin of Every Arduino to the Raspberry's GPIO Header

Reset pin of every Arduino has to be connected to Raspberry's GPIO pins. It can be done according to default pins assignment - table on the attached photo. Make sure that you are using and reffering to "GPIO" pins numbering - white numbers on orange fields on the image.

If you want to use another pins - remember to use general purpose pins. Not reserved ones, gnd, 3.3V, 5V etc.

If you are using different pins than suggested ones, you will have to make changes in one of the files. It will be explained further in the instructables.

Important: If you haven't done Step 1 already - do it now.

Step 5: Login Into Raspberry Via SSH and Download the OTA Updater

Open the SSH connection with your Raspberry. Establish connection to the internet.

You can also hook up display to the Raspberry and login into Raspbian at the Raspberry itself.

After logging into Pi, download repository from GitHub page.

Use those commands:

cd ~

sudo apt install zip unzip --> if needed

wget https://codeload.github.com/szafranski/RH-ota/zip/stable -O tempota.zip

unzip tempota.zip

rm tempota.zip

mv RH-ota-* RH-ota

Step 6: Configure Downloaded Software

!!! OBSOLETE - read "NEW" below:

Now configure your software. Go inside downloaded folder:

cd RH-ota

Next:

cp distr-updater-config.json updater-config.json

and than

nano updater-config.json

!!! NEW:

Just skip to the next step. Configuration wizard will guide you.

You can choose what version of RotorHazard do you want to use. It is directly related to node firmware version that can be used so you can change those by changing "RH_version" in the file. You can also change user name if you are logged different, enter number of nodes that you are using or change country code if you are planning to use WiFi on your Raspberry.

Default version is always last stable release of the software - so it can be quite outdated.

Remember to always update server software if you have updated nodes firmware in the first place.

If you want to use another pins for reset purposes for some reason it has to be changed in the nodes_update.py file - see on attached photo.

nano nodes_update.py

Also change "pins_assignment" in updater-confg.json to "custom" in that case.

Step 7: Prepare Raspbian OS and UART

Now run software by typing:

cd ~/RH-ota

./ota.sh

If you get an error you probably have to install python3. Type: 'sudo update && sudo apt install python3'

If you are doing this for the first time you have to install software that connects with Arduino and has ability to program it. Do it by entering Additional Features menu and select point 1 - "Install avrdude".

Next you have to enable serial port on GPIO header (UART protocol) and prepare it to be connected with external device. It is utilized to be the console output by default so it is basically useless until you make some changes.

Enter Additional Features menu and go to point 2 - "Enable serial protocol".

Next you will be asked to reboot the Raspberry. Do it.

Step 8: Use Downloaded Software

After rebooting, open software again:

cd RH-ota

./ota.sh

What is in the MENU:

If you want to update or install (or possibly even downgrade) server software enter point 1.

If you want to flash firmware on Arduino-based enter point 2.

Follow the instructions on the screen.

It should works automagically :)

After updating either of components - nodes or server - remember to "disable" and re-enable all the channels on the server page, before using timer - or power-cycle whole system.

If you want to be absolutely sure that software and/or firmware updated correctly check out version number or API number during manual server opening. You can also flash the 'Blink' hex file, confirm that nodes are not being recognized and than flash new firmware - but it shouldn't be necessary.

Besides that there are interesting additions in 'Features menu'. You can use them. This part of the software will be developed even further.

Step 9: Things Worth Mentioning / Trouble-shooting Guide / FAQ

  • Arduinos can't be flashed - check the wiring. 3 times. Remember that EVERY Arduino has to be connected via reset pin and UART (RX/TX pins).Updating script doesn't want to open - check if python is installed and install it by using command'sudo apt install python'
  • "It just doesn't work" - it is
  • If something is wrong your first troubleshooting steps should be:
    • check if there is a continuity between all RX pin of Arduinos
    • same for TX pins
    • check if there is a continuity between Arduinos RX "line" and Raspberry's TX
    • same for Arduinos TX and Raspberry's RX (it wont be continuity due to voltage divider, but check if resistance if right ("1R" value)
    • check if there aren't any shorts between RX and TX "lines" or between RX line and GND or TX line and GND or RX line and VCC or TX line and GND
    • check voltage divider "set-up" (resistors with proper values in given places)

    • if above steps didn't help check the software - if serial is enabled AND console login output DISABLED (in 'sudo raspi-config')

  • What about additional libraries for LEDs etc - if you install RotorHazard from skratch using this software they will be added. If you don't have them already updating process won't add them to your existing installation.
  • Software works but in some cases it crashed or exits to system - make sure that your username in both files (update.py and rpi_soft.py) matches your system username.Updating server software takes long time - when server is being updated, the Raspberry itself is being updated as well. If you haven't updated Raspbian (Raspberry's OS) for some time it can take up to 20 minutes. It you get only errors - check internet connection.
  • Few nodes updated with no problem but few of them were being flashed very slowly and I can't see them after opening the server - use option "Flash each node individually" and flash problematic nodes this way.
  • "I tried few times and I really think that my Raspberry's UART isn't working properly" - open configuration assistant on your Pi by typing 'sudo raspi-config' -> Interfacing options -> Serial and after hitting enter choose "no" for first question and "yes" to second one. Reboot if asked. You can also type 'cd /dev' and than 'ls -l' and look for 'serial0 -> ttyS0'. It should look as on attached image. If it is, it definitively means that your UART is working.
  • Command 'dmesg' would give you nice indication what devices are connected - with a port names
  • There are few font colors used in the software. If you feel like you can't see something - just change console window background color in settings or use another for SSH or terminal usage.
  • After enabling Serial on the Raspberry and rebooting I can't connect to Raspberry via SSH - probably some communication is being performed on UART line and prevents Raspberry from booting. Unplug those wires for a moment and reboot the Pi. Check if serial connection is working properly according to previous point, plug wires again and check if Raspberry boots normally.
  • You want to know what you are doing and automatic processes aren't your thing - software written for this project is as combination and compilation of about 100 hours of thinking, learning, wiring, troubleshooting and researching. If you want to know more what is actually done open 'py' files in some text editor and you can figure out what's going on after some time.
  • After opening the program or entering 'Aliases' menu I can see random character all over the place - resize your terminal window. And possibly scroll up a bit."
  • I want to flash my own 'hex' files. How to create them and what to do next?" - you have to use Arduino IDE. Install it - preferably on the PC and after creating/opening ino file compile it and find created hex file. More instructions about doing that can be found here: https://www.instructables.com/id/HOW-TO-GET-HEX-F... After that copy hex files to the Raspberry using scp or upload them on GitHub and download on the Pi. If you are using Desktop version of Raspbian you can just use standard ways if downloading the files or even create hex files using Arduino IDE on Raspberry itself. Just remember to don't use serial communication in your sketch. It is explained in next step why it is so important.
  • "My grandma has better programming skills than you" - maybe, but my used to make better pancakes
  • I want to skip some process or abort immediately - press Ctrl+C.
  • "How can I get new nodes firmware in the future?" - I will do my best to maintain the repository up-to-date. You could also make your own 'hex' files in process described above. "Self updater" should arrive at some point as well. EDIT: Just use "self updater" in Features menu. Nodes firmware version that updater containes always corresponds with Updater version number. For example. Updater version "2.2.1" has nodes firmware with "API level 22" etc.

Step 10: Things I Had to Gone Through / History of Development

At first I was trying to utilize the SPI protocol. I have connected spi1 (second SPI bus of the Raspberry Pi - first is occupied by LEDs) to Arduinos. After some hustle I was able to program the nodes but it was risky cause SPI protocol has ability to erase whole chip - bootloader included. So if something went wrong Arduino became useless. I had to pull it out and program with external programmer. Besides that 2 of 5 Arduinos used during testing are completely bricked now cause SPI protocol can change "fuses" of the chip. It is very low level programming stuff and can't be restored easily. The worst thing was that if SPI bus was connected to the Raspberry it couldn't be used to changing the channels of the 5808 receivers. I tried to use SoftwareSPI on Arduinos but it required changing pins assignment, more wiring etc. It was messy and unelegant. Besides, Arduinos had to be flashed with 'hex' files without the bootloader, files had to have additional delay during boot etc. Moreover special version of avrdude - program used for programming the Arduino - had to be used with special programmer compiled... Bad things. For me it was still worthy but I was worried that no one would want to do it too and that someone could brick Arduinos before race or something.

I than realized that Raspberry has an UART line and that Arduino normally can be very easily programmed with this protocol. Basically every time Arduino is connected via USB it uses UART - and USB to serial converter (this small chip at the bottom of the Nano. I have connected the dots and after some troubleshooting process - enabling the UART on the Pi is not that obvious - I successfully connected Raspberry's UART to PC's COM port. At that point I was sure that Arduino can be programmed this way. Luckily programming via UART is a standard way of flashing so normal version of avrdude can be used. Even the software programmer is called "arduino". Only thing left was to make a way to establish connection with each Arduino before programming so it can be ready to be flashed. Right now resetting the nodes is done "manually" in python script which is easy to control and doesn't require changes in avrdude config files etc. Last important discovery was that serial connection has to be disabled in node code. It was caused because of the way how Raspberry GPIO operates and hot it handles resetting Arduinos right now. The Serial communication is awesome feature of those nodes but in that case it shouldn't change anything - explained in third dot - below.

The biggest advantages of the way that this program operates right now are:

  • bootloader stays on it's place, Arduinos can't be broken (or odds are as small as with programming with the PC)
  • even if power outage occures during flashing it shouldn't cause any issues
  • code on the nodes is exactly the same as standard code from RotorHazard - just with serial communication disabled - it isn't crucial unless you want to connect the nodes directly to the PC (but you probably wont if they are embedded in lap timer already

At the end I combined two separate programs so now you can update both - Raspberry's server and Arduino-based nodes using same program. Some additional features like making Raspberry as standalone Access Point automatically will come later.

And one more thing - I had absolutely zero knowledge or idea how programming in python works. I even didn't know what "indents" are - took me 1 hour to figure it out. I had some background with C language and Arduino IDE, but never did anything in python - so I learned the basics so this project can be developed :)

And I didn't know how GitHub works from creators point of view as well - so I've learned how to use desktop version - it really helps a lot.

Rodrigo Cardenas was a first reader of the instructables and beta tester for the first semi-official version of the software. He found many issues and helped me in process of debugging the code. We spent weekend on conversations and testing. It was worthy. Software looks awesome now and steps that have to be taken hardware-wise are well known - after about 50-70 hours of tinkering and testing.

And the story of this very instructables is quite funny. At first I was thinking about making some quick video or explain just a few steps. But someone mentioned that full written document would be preferable. And he got more than 20 likes on the Facebook group. So I had no choice :)

Step 11: ​Afterthought - Added After First User Confirmed That It All Works:

Quick anecdote: My friend asked me yesterday if I did this project for free or will it be paid by anyone. I was surprised, but he told me that I put a lot of effort and time into it. I thought about it. So... If you feel this way you can make a donation. I have a PayPal account.

Link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xcli...

[ https://www.paypal.com/cgi-bin/webscr?cmd=_s-xcli... ]

If you want to test this solution first and than consider any donation - that's cool too.

Remember that I am and will be happy to do my best to help you anyway. It is not conditional.

Also remember that I am not a part of an official RotorHazard developers team.


If right now you realized “Hmmm, RotorHazard itself also deserves some support” - here is the link the the Patreon page:
https://www.patreon.com/rotorhazard

Do what you feel - or don’t :)

Cheers!

Step 12: Thanks + Disclaimer

Thanks for all the people from the RotorHazard Facebook group and developers and contributors (of Delta5 timer as well). This is my small contribution to the project but without you this awesome timer couldn't exist. Thanks for all advices to the people on the Group. You are awesome. Especially thanks for people that were willing to test this software and this mod and people who responded to my questions on Facebook and gave me some ideas (even random and general ones) and for the feedback or just a kind word and a little bit of enthusiasm.

BIG thanks for Rodrigo Cardenas for additional testing and being first user. And also for much better photos than mine :) Clayton Harp, Michael FPV, Mark, Aaron and few other people from the Group helped me as well. Thank you!

Disclaimer: I've done my best to make this instruction as clear as possible. I am also sure that this procedure can't broke your electronics or software. I did lots of testing. Also one of the timers after this mod has proven to be working on some big race event, right after using both - server and firmware - obtained with usage of this software and this mod. From the other hand I don't have control over your soldering skills or special situations with software like unusual Raspberry's configuration etc. You perform this mod at you own responsibility - but you can look for help on the Facebook Group if you need some. Speaking software-wise - of course if any bugs occur, I will attempt to fix them.

Feel free to give me the feedback and comment if you wish. Also you can make commits on GitHub page if you have some programming background. This project can be developed further and further! Even this instructable probably will be improved and few dozens additional insights has been added since first publication.

You can contact me here, using Facebook group or on GitHub platform.

Pawel F.

GitHub page of RotorHazard project: https://github.com/RotorHazard/RotorHazard

GitHub page of this project: https://github.com/szafranski/RH-ota