The Joy Robot
Home | Content | Services | About
Search Eng Dark

Jonathan Pablo Toledo Guides, Microcontrollers, UART 2021-02-10

Change the firmware of the Sonoff RF Bridge to Tasmota with Portisch and handle raw RF signals (Raw)

Due to the limitations and how closed the original firmware was, I decided to change the software of my Sonoff RF Bridge device to ESPurna, a firmware that I used for quite some time (about a year). However, I started experiencing some complications that led me to look for other alternatives for this device.

The main problems I encountered were the following:



  • Limitation of 16 stored codes.
  • Despite having omitted the use of the EFM8BB1 microcontroller, it was not possible to increase the amount of stored code. This meant that the hardware modifications made did not justify the result.
  • When you tried to create codes manually, they became corrupted and their operation was unpredictable. Sometimes they worked correctly, but other times they stopped and the device needed to be restarted.

Looking for alternatives, I found that Tasmota firmware was the ideal candidate for what I needed, as it allows you to capture and output raw codes.

What does this mean? That it is not necessary to store the codes on the device. In this way, we can transform the Sonoff RF Bridge into a true radio frequency bridge: our server sends the signal digitally and the device takes care of transmitting it.



1. Preparing the device

First I had to remove the bridges that I had added when installing ESPurna to perform the EFM8BB1 bypass (you can find more details in the corresponding article). I also had to restore the track that I had cut during that procedure.



2. Connect the device using a serial bridge

To transfer the binary firmware to the microcontroller's memory, we will use a serial adapter. It is necessary to connect the communication pins as shown in the image.



Connecting the serial adapter may seem like a complex task, but it's actually quite simple. In my case, I opted to perform the soldering on the back of the board, as it was much more comfortable for me.



Since the chip requires a voltage of 3.3 V and my adapter works with 5 V TTL signals, it is necessary to use the voltage regulator output located on the back of the adapter.



3. Overwrite the microcontroller memory ESP8285 (Flickering)

For this procedure I am using a Mac computer with OS X High Sierra. In my case, I have a USB to serial adapter based on the FT232RL chip.

As it is a serial interface that has been widely used for many years, there are different alternatives to transfer the firmware to the board. For this example I will use the most "complex" method: doing it directly from the terminal. If you prefer a simpler procedure, you can look for a guide to update the firmware using the Arduino IDE.



3.1. Download the firmware

Download the binary file from the Tasmota releases section . The file we need is called tasmota.bin



We must also download the source code of Tasmota from GitHub and unzip it, since later we will use one of the files included in the project.



3.2. Verify that the USB serial adapter has been detected by the computer

To continue, we must check that our computer has correctly recognized the USB serial adapter.

I recommend first reviewing the following guide, which explains the basics of working with microcontrollers. There you will find instructions for installing the drivers, tools such as Homebrew, Python and their respective dependencies, as well as performing a connection test:



https://thejoyrobot.com/blog/prepare-equipment-for-working-with-UART-interfaces

To list USB-Serial devices, we'll use the following command:



Terminal
$ ls -l /dev/cu.*

This command will display all the serial interfaces available on our computer.



In my case, the adapter was detected as /dev/cu.usbserial-A9KFZXD5. However, the port name may vary depending on the USB-to-serial adapter you are using. Of course, you should use the name that appears on your own computer.

To continue, we need to have esptool.pyinstalled. If you don't have it yet, you can follow the guide mentioned above.



3.3. Connect to the ESP8285 chip

To establish the connection, we must press and hold the button on the Sonoff RF Bridge, connect the serial adapter to a USB port, and release the button after a couple of seconds.

The Sonoff device should not light up any LEDs during this procedure.

We run the following command to verify that there is communication with the microcontroller:



Terminal
$ esptool.py flash_id

esptool.py It will display the information received from the microcontroller.



3.4. Clear the memory

To clear the microcontroller's memory, we run the following command:



Terminal
$ esptool.py --port /dev/cu.usbserial-A9KFZXD5 erase_flash

3.5. Writing the image of Tasmota



Once the memory is cleared, we must disconnect the USB serial adapter and reconnect it by holding down the button on the Sonoff RF Bridge.

After performing this procedure, we run the following command:



Terminal
$ esptool.py --port /dev/cu.usbserial-A9KFZXD5 write_flash 0x00000 ./Documents/tasmota.bin

3.6. Finish the installation

We disconnect the USB serial adapter from the computer and connect the Sonoff RF Bridge to the power supply.

If everything went well, the Wi-Fi LED on the device should start flashing. Also, a new Wi-Fi hotspot should appear.



The guide continues at this link:


The Joy Robot