logo elektroda
logo elektroda
X
logo elektroda

How to access hardware SPI port on CB2S? P16 (MOSI) GPIO breakout method

p.kaczmarek2 
Close-up of a CB2S module PCB with a thin wire soldered to a QFN pin.
Here I will show you how to access the hardware MOSI pin, P16, on a common Tuya CB2S BK7231N module. The MOSI pin can be used for hardware SPI communication and also for driving individually addressable LEDs like WS2812 or SM16703, but it's not available on CB2S pads. We will have to solder a wire to one the QFN pads and then break it out.


Step 0: Considerations
Let's consider the CB2S module:
Image of a Tuya CB2S BK7231N module on a wooden surface. Tuya CB2S BK7231N module with visible pins and QR code. Close-up of a Tuya CB2S module with exposed shielding and visible soldering pads.
Most commonly used GPIOs are routed to the pads, there are also some debug GPIO pads at the bottom of the module, but P16 is nowhere to be found. Still, we can check the pinout of the QFN BK7231 IC itself, to find that it should be available, at least on the QFN pad:
Pin configuration diagram of BK7231T chip
This means that the designer of CB2S module must have skipped this pin. We are going to fix that now.

Step 1: Removing CB2S shielding
Shield can be easily removed with hot air, large nozzle, and some extra flux to loosen the solder connection:
Photo of a Tuya CB2S module with a visible BK7231N chip on a wooden background. Close-up of Tuya CB2S BK7231N module with QFN chip. Close-up of the CB2S BK7231N module with visible pads and microchip. Tuya CB2S module with BK7231N chip and pad markings on the board.
On the pictures, I have also accidentally desoldered the 100nF power supply decoupling capacitor. This needs to be fixed before using module again:
Sharp tip of a soldering tool on a wooden background

Step 2: Choosing where to route
The best option is to reuse one of the existing pads, for example CEN. I chosen to use CEN because I don't use it for flashing, I just do a power off/power on cycle and it works reliably. So, I had to cut the CEN trace:
Close-up of CB2S module with visible soldering points.
Close-up of a PCB showing traces and pads.
That way CEN is now disconnected from the pad and pad can be reused for our purposes.

Step 3: Preparing the wire
Get a thin wire, roughly of the size of the QFN pad. Strip the enamel from it. Tin the tip of the wire for easier soldering. You can use old broken transformer or a coil as a source of such wires.

Step 4: Soldering the wire
Once the wire is prepared, it's time to solder it to the correct pad of QFN case. Make sure that you have identifier the first pad directly - it's marked with a dot. You can use the crystal pads for orientation, just to check if you've correctly determined the orientation.
I have used a thin soldering tip for the soldering process, first I added flux and some Pb solder and then I finally made the connection:
Close-up of a CB2S module PCB with a thin wire soldered to a QFN pin.
Close-up of a soldered wire on an integrated circuit on a blue PCB.
Remember to clean the PCB with IPA before going to next step.

Step 5: Adding UV-curable solder mask
Now you can secure the connection with UV-curable solder mask. Otherwise the wire may get loose during module usage or storage. Apply solder mask and use UV to cure it:
CB2S BK7231N with MOSI wire highlighted under UV light Close-up of a Tuya CB2S module with a thin wire soldered to a QFN pad.

Step 6: Second solder joint
Finally it's time to solder the second end of the wire to the pad. Of course, it also have to be stripped from enamel. Then you can also solder futher wires to connect the module to the breadboard:
CB2S module with soldered wires on a breadboard Close-up of a Tuya CB2S module with wires soldered to the QFN pad.


Summary
That way you can break out the P16 (MOSI) on the common CB2S module. The same method can also work for similiar modules like CB3S, etc. Alternatively you can look for module that has P16 already available on pads like CBU module:
Technical drawing of the CB2S module with dimension and pin markings.
Spoiler:
Pin numberSymbolI/O typeFunction
1P14I/OCommon GPIO, which can be reused as SPI_SCK (Correspond to Pin 11 of the IC)
2P16I/OCommon GPIO, which can be reused as SPI_MOSI (Correspond to Pin 12 of the IC)
3P20I/OCommon GPIO (Correspond to Pin 20 of the IC)
4P22I/OCommon GPIO (Correspond to Pin 18 of the IC)
5ADCI/OADC, which corresponds to P23 on the internal IC (Correspond to Pin 17 of the IC)
6RX2I/OUART_RX2, which corresponds to P1 on the internal IC. (Correspond to Pin 28 of the IC)
7TX2I/OUART_TX2, which is used for outputting logs and corresponds to P0 of the internal IC (Correspond to Pin 29 of the IC)
8P8I/OSupport hardware PWM (Correspond to Pin 24 of the IC)
9P7I/OSupport hardware PWM (Correspond to Pin 23 of the IC)
10P6I/OSupport hardware PWM (Correspond to Pin 22 of the IC)
11P26I/OSupport hardware PWM (Correspond to Pin 15 of the IC)
12P24I/OSupport hardware PWM (Correspond to Pin 16 of the IC)
13GNDPPower supply reference ground
143V3PPower supply 3V3
15TX1I/OUART_TX1, which is used for transmitting user data and corresponds to Pin 27 of the IC. For the MCU solution, please refer to CBx Module.
16RX1I/OUART_RX1, which is used for receiving user data and corresponds to Pin 26 of the IC. For the MCU solution, please refer to CBx Module.
17P28I/OCommon GPIO (Correspond to Pin 10 of the IC)
18CENI/OReset pin, low active (internally pulled high), compatible with other modules (Correspond to Pin 21 of the IC)
19P9I/OCommon GPIO (Correspond to Pin 25 of the IC)
20P17I/OCommon GPIO, which can be reused as SPI_MISO (Correspond to Pin 14 of the IC)
21P15I/OCommon GPIO, which can be reused as SPI_CS (Correspond to Pin 13 of the IC)
Test pointCSNI/OMode selection pin. If it is connected to the ground before being powered on, enter the firmware test mode. If it is not connected or connected to VCC before being powered on, enter the firmware application mode. Correspond to Pin 19 on the internal IC.

But CBU module seems to be less popular and less accessible than the CB2S/CB3S so the presented method can be useful is some cases.
The routed out P16 can be used for example for individually adressable LEDs control via hardware SPI of BK7231, which is available in OpenBeken firmware. We are currently supporting SM16703 and WS2812 also works, but WS requires some final fixes before it's fully release-ready. Let us know if you want to driver some LEDs with OBK!

About Author
p.kaczmarek2
p.kaczmarek2 wrote 11822 posts with rating 9927 , helped 564 times. Been with us since 2014 year.

Comments

Add a comment
DeDaMrAz 29 Oct 2023 17:36

Here is how you can mode CB3S module. I've cut P14 pad from the via and connected P16 to that via so I can have easier access to P16 for testing. Everything is reversable if need be. https://obrazki.elektroda.pl/3216382700_1698597352_thumb.jpg... [Read more]