beep... beep... blink... blink...
 
Tuya WiFi-IR Remote Conversion to Open Source – Walkthrough

Tuya WiFi-IR Remote Conversion to Open Source – Walkthrough

In this article I show how to convert a Tuya WiFi-IR Remote to use open source software. The reasoning and the procedure is the same or very similar to what I described in my previous article. (If you want more WiFi-IR gateway goodness, here is one I made a couple of years ago.)

Here are the steps needed for the conversion that I will cover:

  1. Remove the casing to get access to the PCB and the microcontroller
  2. Attach (solder) cables to the microcontroller
  3. Connect the other end of the wires to the serial port on the PC
  4. Confirm the unit is working by looking at the bootlog
  5. Change the wires for the programming port
  6. Backup the original firmware
  7. Flash the new firmware
  8. Configure the device
  9. Remove the wires used for programming
  10. Re-build the casing

And here are the tools needed:

  • PC or laptop with a spare USB port
  • USB-UART adapter
  • 3 pieces of (thin) wires
  • Soldering iron and some solder
  • Serial terminal (Putty or similar) to verify the functioning of the device
  • BK7231 GUI Flash Tool – download it here

In this article I will only show the procedure with as many pictures as necessary for anyone to follow.

This is the official product image of the device – borrowed from the famous Chinese online marketplace

1. Opening the case

With a thin but strong prying tool gently detach the two parts of the shell. The line where they are connected can easily be seen. The two halves are held together by 3 flaps – be careful to not break them off. If you break them, don’t worry. You can use some hot glue to put the thing together at the end. No panic.

On this side of the PCB, we can see the 3 IR LEDs and the IR receiver. We also see 3 screws. We need to remove these screws to be able to remove the PCB from its housing.
MCU side of the PCB. There are no test points anywhere on the PCB, so we will need to solder the temporary wires to the MCU directly.

2-3. Attach wires to some of the MCUs pins

To program the MCU we need three wires: GND, Tx and Rx. The CB3S module uses a BK7231N chip. This uses 2 UARTS: one for monitoring the chip, one for programming it. We don’t need both at the same time. So let’s connect the GND, Tx according to the image below:

Programming: blue-Tx, green-Rx – Monitoring: white-Tx

Note that I did not solder any wire for GND. This is because my 5V supply shares the GND with my PC. If you have a different setup, you also need to connect a wire to the GND pin. It is located 2 pins down from the white wire in the bottom right corner of the MCU.

Connect the other end of the wires to the serial-UART adapter on your PC. Make sure that any Rx pin is connected to a Tx pin at the other end and vice versa.

4. Confirm the unit is working by looking at the bootlog

Start a serial terminal application (i.e. Putty) on your PC. Set it to the serial port you connected your device to, set its speed to 115200 bps, leave the rest of the settings at their defaults, then plug in the USB cable into the device to power it up. If everything is wired up correctly, you should get an output similar to this:

If you get something similar, you can move onto the next step. If you get garbage characters, check your communication settings in the terminal program. They should be like this: 115200kbs, 8N1. If you don’t see any output, check your wiring.

5. Change the wires for the programming port

To prepare for the actual programming of the MCU we need to use the other UART on the chip. You need to use the blue and green wires. Again, make sure that any Rx pin is connected to a Tx pin at the other end and vice versa.

6. Backup the original firmware

Fire up the BK7231 GUI Flash Tool and set it up like this:

You may need to change the UART port to match your own setup. If you have no firmware to select, click “Download latest from web” to get the latest firmware.

Finally click on Do firmware backup (read) only to create a backup of the original firmware. Once the connection is established with the MCU you will be prompted to power cycle the MCU. This is easily done by removing the USB power cable for a moment, then reconnecting it. Reading the content of the MCU will automatically start. This process should take a few seconds only. At the end you will be presented, in a new window, the configuration of the old firmware. We can use this later to configure the new firmware, so save it somewhere safe. My configuration was something like this:

7. Flash the new firmware

It is now time to flash the new firmware. The process is similar to the previous step with the difference that you need to click on “Do firmware write (no backup!)” to initiate the process. Once the flashing is done, a happy, green message is shown:

At this stage the device is ready to be configured.

8. Configure the device

First, power cycle the device. As it will have no knowledge of your WiFi network, it will enter Access Point mode. So use a mobile device, i.e. your phone, to connect to it (the SSID will be something like OpenBK7231N_XXXXXXXX). No password is required. Navigate to 192.168.4.1, then click Configure then Configure WiFi & Web, fill out the form, then click Submit to save the settings. After restarting, the device will connect your WiFi network and you can configure it further.

To configure the device there are several options. The easiest is to use the Web Application:

Navigate to the IP address of the freshly flashed device (get the address from your router), click Launch Web Application, finally click Import. Under Enter template here copy and paste this template:

Then click Clear OBK and apply new script from above to apply the changes.

Now go to the Filesystem tab of the web application and create a new file called autoexec.bat. Once created, click on it to edit it. Copy and paste the following into it:

This line is needed to start the IR module in the MCU every time it boots.

Finally click Save, then restart the device.

You can also several other aspects of the device, which is outside the scope of this article.

Here is a screenshot of some sample MQTT messages spat out by the device when “attacked” by a remote control:

9-10. Finishing up

Remove the temporary wires and reassemble the case to rep up the conversion.

Congratulations, you now have a fully working, privacy respecting WiFi-IR remote!

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.