LORADUINO
The Arduino is widely used platform for lot of applications. Despite its all advantages in some cases it is not very convenient to use - for changing some parameters in the program it always requires direct cable connection with your PC. For example: If you have an Arduino controlling or monitoring system placed distantly from your house and you want to update the software, to upload the new sketch you have to go there where the Arduino board is suited, connect it throw USB cable to your PC and update the software. The distance to your Arduino system can be kilometers... and it can be placed in the mountings, in the forest and etc. This project solves the mentioned problem. You can upload your sketch in the Arduino board without leaving you home or office. As additional gain for free you receive also the possibility to monitor your sensor data or send commands to your board using the serial monitor or plotter.
The new proposed board is based on the Arduino Uno revision 3, in which the USB to serial converter chip is replaced by UART LORA module. To make the whole system work you need also an USB to serial to LORA converter. The design of these both devices is presented in this instructable.
Supplies
The LORA UART E220-900T22D Modules used I bought in Aliexpress. They are produced by Ebyte. On the market are available also other UART modules, which can be used for this project : This module is pin compatible with the module I used. It is also produced by Ebyte. The configuration software must be downloaded from their site. Additionally two LORA antennas are needed. Seeed studio also offer their UART LORA modules - so you have big choice. An USB to Serial converter module can be very useful. In the beginning of the project I used such module connected with wires to the LORA module
Hardware Design
As mentioned above the design of the LORADUINO is based on the Arduino Uno version 3. There I removed the ATMEGA16U2 chip and replaced it with the LORA module. The USB connector and the power monitoring circuitry become unnecessary. The schematic of both devices is presented in the attached pdf files. I will discuss in more detail the circuit in the next step.
USB TO LORA Converter
This board is optional. You can use standard CH340G, PL2303 or FTDI converter board and to connect it through wires to the LORA module. The wires can be soldered to a pin header where the LORA module is inserted. To make the life easier I added a small SPDT switch which is used to switch between the working and setup modes of the LORA module. This switch presents also on the designed by me USB to serial conversion board, where the LORA module is inserted. My conversion board is based on the CH340G chip bought also in Aliexpress. Here is the BOM of this board.
LORADUINO
The LORA modules have three communication pins : TX, RX and AUX. The AUX pin is used to wake up the microcontroller at the start of the communication. You can see its behavior on the attached pictures. It can be used to reset the Atmega328 chip of the LORADUINO when the sketch upload starts ( the third picture shows this process - standard Arduino sketch upload signal diagram - D2 signal is the reset ).Using these modules is quite tricky - they have limited size buffer. It can be set maximum to 400 bytes. After this buffer is emptied the AUX pin goes high and again low at the beginning of the next data packet. In this way it resets each time the microcontroller chip during the communication. To prevent this I added a retriggerable monovibrator based on the 555 timer chip. Its time delay I set to be around two seconds. It has an inverter on its output and keeps the level at the input plate of the reset capacitor always low, when the communication is in progress. I would suggest here to be used the LMC555MX version, which is the fastest one and allows supply voltages in very big range. On the pictures above you can see how the problem was sold with additional small board on which the monovibrator circuit was soldered. Because the LORA module has TTL digital input/output levels I added level shifters SN74LV1T34DBVR between the module and the ATMEGA328 chip. In the TX direction one can be omitted. There are also jumpers in the TX/RX path, which allow to configure the module using USB to UART board. The last remark - I reduced the RESET capacitor from 100nF to 10nF. It is done because the module starts the transmission around two milliseconds after the AUX pin goes low ( this resets the ATMEGA) and the RESET chain time constant must be smaller than usual to release the chip from reset state and make it ready for data reception. The BOM is attached as picture.
Project Assembling
The PCB's were produced in PCBway in a short time and in high quality. They can be ordered under the following links : LORADUINO , USB to LORA module . On the picture above is seen the soldered board of the LOARADUINO before attaching the LORA module and the both boards soldered and ready to use.
Downloads
Software
The main trick using LORA modules is that the transmission distance is inversely proportional to the transmission speed. To reach long distances you have to go to low transmission speeds. Because as mentioned before the LORA modules have only 400 bytes buffer and when it is full and the incoming data continues they stuck and the only way to wake them is to switch off the power supply and to power it up. For that reason I set the aerial data transmission higher than the UART speed. The modules can be configured by software tool, which can be downloaded from the Ebyte site under this link. The modules documentation can be found here. On the picture above can be seen the settings I gave. It is important that both modules are set identical. As you can see I set UART speed 9600 bps. To be able Atmega to communicate with the module its bootloader must be set to communicate with this speed. New bootloader must be burned in. I used the optiboot bootloader for that purpose. Under the link you can find all needed information how to compile it and how to upload it in the ATMEGA chip. I compiled it with the command : "make atmega328 BAUD_RATE=9600". How to burn it in ATMEGA328 chip you can find a lot of information - even in this site.
After burning the bootloader, you have to define a new board in the Arduino IDE. I called it Loraduino. You can also at first set the Arduino environment and after that using it to burn the bootloader inside the Atmega328 chip with the help of SPI programmer.
In the file : C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt you have to add new section:
##############################################################
loraduino.name=Loraduino
loraduino.vid.0=0x2341
loraduino.pid.0=0x0043
loraduino.vid.1=0x2341
loraduino.pid.1=0x0001
loraduino.vid.2=0x2A03
loraduino.pid.2=0x0043
loraduino.vid.3=0x2341
loraduino.pid.3=0x0243
loraduino.upload.tool=avrdude
loraduino.upload.protocol=arduino
loraduino.upload.maximum_size=32256
loraduino.upload.maximum_data_size=2048
loraduino.upload.speed=9600
loraduino.bootloader.tool=avrdude
loraduino.bootloader.low_fuses=0xFF
loraduino.bootloader.high_fuses=0xDE
loraduino.bootloader.extended_fuses=0x05
loraduino.bootloader.unlock_bits=0x3F
loraduino.bootloader.lock_bits=0x0F
loraduino.bootloader.file=loraduino/loraduino_atmega328.hex
loraduino.build.mcu=atmega328p
loraduino.build.f_cpu=16000000L
loraduino.build.board=AVR_UNO
loraduino.build.core=arduino
loraduino.build.variant=standard
##############################################################
this must be added also to the same file located in : C:\Users\YOUR user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
The new compiled bootloader with the name listed above "loraduino.bootloader.file=loraduino/loraduino_atmega328.hex"
must be placed in C:\Users\YOUR user\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\bootloaders\loraduino
and here:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\bootloaders\loraduino
If everything is set correct your board shall be accessible by Arduino IDE and you can burn the bootloader using it.
After burning the bootloader you can try different settings for your LORA modules. I would suggest when using the serial monitor to give relatively big delays between sending the data because if this datastream is very dense it could be difficult for Arduino IDE to interrupt it if you want to upload new sketch.
In the movie linked here you can see how the blink sketch was loaded in the LORADUINO during sending its sensor data through the serial monitor.
This design works relatively good. It was not tested at distances bigger than 10 meters, but theoretically it should work at distances up to 8km (for this LORA chip). In the next design I intend to add also hardware reset possibility for the LORA module. Now only the Atmega chip is reset by the button and in some cases this does not work correctly.
LORADUINO can be based also on other Arduino boards - Mega, Due, Nano and others.
All comments and questions about the projects are welcome. Improvement ideas also.