This project uses the PB-03F Kit to remotely control home appliances such as fans, lights, and power sockets. By connecting a PC-based control panel, users can view device status in real time and operate them remotely.
Project SpecsThe development board used is the PB-03F Kit, based on the PB-03F module from Ai-Thinker. This module features:
- 64KB SRAM, 256KB Flash, 96KB ROM
- 256-bit eFuse
- M0-core processor, fully reprogrammable via Keil IDE
- Bluetooth Protocol: Bluetooth 5.2
- TX Power: 10 dBm
- RX Current: 9.4 mA
- TX Current: 11.5 mA
- Receiver Sensitivity: –93 dBm
- Hardware AES encryption accelerator
- Supported Rates: 125 Kbps, 500 Kbps, 1 Mbps, 2 Mbps
Below is the schematic of the relay module used in the project.
We built on the official Keil project bleUart_AT. After debugging, we found that the function BUP_data_BLE_to_uart_send() handles incoming Bluetooth data. To enable control and status response, we added a custom handler function rec_pro() to parse incoming commands from the PC.
int BUP_data_BLE_to_uart_send(void)
{
BUP_ctx_t* pctx = &mBUP_Ctx;
if(pctx->tx_state != BUP_TX_ST_IDLE && pctx->tx_size)
{
// run at cmd.
if((pctx->tx_size) == 2 && \
(pctx->tx_buf[0] == 'a') && \
(pctx->tx_buf[1] == 't'))
{
at_at(0,NULL);
pctx->tx_state = BUP_TX_ST_IDLE;
pctx->tx_size = 0;
return PPlus_SUCCESS;
}
// run at+reset cmd.
else if(pctx->tx_size == 8)
{
bool flag = true;
for(int i=0; i<8; i++)
{
if(pctx->tx_buf[i] != ptcmd[i])
{
flag = false;
break;
}
else
continue;
}
if(flag)
at_reset(0,NULL);
}
//AT_LOG("buf:%s",pctx->tx_buf);
//AT_LOG("size:%s",pctx->tx_size);
//FF 00 00 00 00 00 01 FF
rec_pro(pctx->tx_bu);
hal_uart_send_buff((UART_INDEX_e)g_uart_idx, pctx->tx_buf, pctx->tx_size);
pctx->tx_size = 0;
pctx->tx_state = BUP_TX_ST_SENDING;
return PPlus_SUCCESS;
}
LOG("BUP_data_BLE_to_uart_send: incorrect state\n");
return PPlus_ERR_INVALID_STATE;
}
Hardware TestingWe first tested the setup using 3.3V to drive the light safely. The light turned on/off as expected.
To integrate into the ceiling, we removed a non-functional embedded LED fixture to investigate its internals. It’s labeled 170–240V, 50/60Hz, indicating AC drive. But it also has a small PCB using a SOP-8 high-precision PSR LED constant current driver chip.
Surprisingly, powering the fixture with 12V DC worked fine. We didn’t try 220V AC to avoid fireworks. Most likely, the issue lies in the internal AC-DC converter module.
Eventually, we replaced it with a new 220V AC lamp, and controlled it via PB-03F + relay. However, another wiring challenge came up — this fixture was in the middle of a chain, and used non-standard cable routing. Using jumper wires felt unsafe, so we decided to power the lamp separately.
Demo Setup
You can place multiple PB-03F modules in different devices. With that, you've got yourself a simple but powerful Bluetooth smart home system!
Comments