Build a RFLink Wi-Fi Gateway (Radio Frequency Link Board) using "Nodo Shop RFLink (433 Mhz) board" and "RobotDyn MEGA+WiFi R3 ATmega2560+ESP8266"
![BuyMeCoffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge)
The project can help you to build a RFLink Gateway useful to integrate RF devices in your preferred home automation system.
The project core component is the firmware by Stuntteam that allows sniffing and sending 433 MHz radio frequencies frames. The frames are organized according to specific IOT protocols. The RFLink firmware is developed to run on the Arduino Mega board and it uses the USB port to communicate, no other communication interface is available.
To expose the RFLink Gateway (Arduino board) through Wi-Fi rather than USB, we can use an ESP8266-01 module. It is equipped with a customized firmware based on the ESPurna that is adapted to interface the RFLink Gateway. To simplify this integration we will use a customized board containing both Arduino Mega and ESP8266. This board is produced by RobotDyn.com.
The customized firmware, based on ESPurna, will be used to expose the RFLink data through a web service.
In the following, the use hardware and software are shown, as well as the steps to assemble the gateway.
Hardware
The project is realized using the following hardware:
Software
InstructionsThe following instruction explain how build your personal rflink Wi-Fi Gateway.
-
Download the rflink firmware
-
Unpack the zip file and get ready to burn it
-
Set the MEGA+WiFi R3 ATmega2560+ESP8266 board dip switch to sketch upload mode. For details see the full dip switch modes.
| Mode | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | RXD/TXD |
|-------------------------------------|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:-----:|:-------:|
| USB <-> ATmega2560 (upload sketch) | --- | --- | ON | ON | --- | --- | --- | NoUSE | 0 |
-
Upload the rflink Gateway firmware using
```
avrdude -v -p atmega2560 -c stk500 -P /dev/cu.usbmodem411 -b 115200 -D -U flash:w:RFLink.cpp.hex:i -C avrdude.conf
```
On OSX with Arduino
```
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -v -p atmega2560 -c stk500 -P /dev/cu.usbmodem411 -b 115200 -D -U flash:w:RFLink.cpp.hex:i -C /Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf
```
NB If necessary, replace /dev/cu.usbmodem411 with the USB port used to connect your device.
-
Clone ESPurna repository using
```
git clone --branch 1.13.5 https://github.com/xoseperez/espurna.git
```
NB In this project I use ESPurna firmware 1.13.5
-
Customize the ESPurna firmware using the code located in the folder espurna_firmware_custom_code
* copy **custom.h** into the folder **code/espurna/config/**
* copy **robotdyn_atmega2560_esp8266.h** into the folder **code/espurna/libs/**
* copy **robotdyn_atmega2560_esp8266.ino** into the folder **code/espurna/**
* in the folder **code/** open the file **platformio.ini**, so put the following text under *GENERIC OTA ENVIRONMENTS* session
```
[env:generic-robotdyn-atmega2560-esp8266]
platform = ${common.platform}
framework = ${common.framework}
board = ${common.board_1m}
board_build.flash_mode = ${common.flash_mode}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m0m} -DUSE_CUSTOM_H
monitor_speed = ${common.monitor_speed}
extra_scripts = ${common.extra_scripts}
```
* in the file **platformio.ini**, find ```lib_deps =``` so replace
```ArduinoJson```
with
```https://github.com/bblanchon/ArduinoJson#v5.13.5```
-
Go to in the folder **code/** and build the firmware using the command
```
./build.sh generic-robotdyn-atmega2560-esp8266
```
NB Depending on your environment, the build process may be interrupted due to errors. In this cases,it is necessary to satisfy the missing dependencies and rerun the build.
After the successful build, you can found the customized firmware in the folder **firmware/espurna-1.13.5/**
-
Set the MEGA+WiFi R3 ATmega2560+ESP8266 board dip switch to sketch upload mode
| Mode | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | RXD/TXD |
|-------------------------------------|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:-----:|:-------:|
| USB <-> ESP8266 (upload sketch) | --- | --- | --- | --- | ON | ON | ON | NoUSE | 0 |
-
Upload the ESPurna custom firmware using
```
esptool.py --port /dev/cu.wchusbserial1410 write_flash --flash_size 1MB --flash_mode dout 0x00000 espurna-1.13.6-dev-generic-robotdyn-atmega2560-esp8266.bin
```
-
Set the MEGA+WiFi R3 ATmega2560+ESP8266 board dip switch to cooperation mode
| Mode | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | RXD/TXD |
|-------------------------------------|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:-----:|:-------:|
| USB <-> Mega2560 <-> ESP8266 (COM3) | ON | ON | ON | ON | --- | --- | --- | NoUSE | 0 |
Change of connecting port between ATmega2560 and ESP8266 setting the switch to RXD0 <-> TXD0
-
Connect the power adapter and configure the rflink gateway using the web interface; for more details see the ESPurna wiki page.
Home Assistant integration (Optional, linux systems only)
Home Assistant is an open source home automation platform. If you use this platform and you want to interface the RFLink Wi-Fi Gateway then you must follow some simple steps.
-
Copy the folder home_assistant_rflink_nodejs_bridge into your Home Assistant system
-
Add the following line:
```sh
@reboot Githubissues.
- Githubissues is a development platform for aggregating issues.