Copy this code into your Arduino IDE. This creates a simple driver to control the board.
#include <SoftwareSerial.h>
// Define RX/TX pins for the BP1048B2
// Arduino RX (Pin 2) <-> BP1048 TX
// Arduino TX (Pin 3) <-> BP1048 RX
SoftwareSerial bpSerial(2, 3);
void setup()
// Initialize debug serial (to PC)
Serial.begin(9600);
// Initialize BP1048B2 serial
bpSerial.begin(9600);
delay(500); // Wait for boot
Serial.println("BP1048B2 Controller Ready");
// Example: Set volume to 15
setVolume(15);
delay(100);
// Example: Play the first track
playTrack(1);
void loop()
// You can add button logic here
// --- HELPER FUNCTIONS ---
void sendCommand(byte command, byte paramHigh, byte paramLow)
// Construct the command packet
// Structure: 7E FF 06 CMD 00 ParamHigh ParamLow Checksum EF
byte commandLine[10] = 0x7E, 0xFF, 0x06, command, 0x00, paramHigh, paramLow, 0x00, 0x00, 0xEF;
// Calculate Checksum
// Checksum = (Sum of bytes from index 1 to 6) & 0xFF
unsigned int sum = 0xFF + 0x06 + command + 0x00 + paramHigh + paramLow;
commandLine[7] = (-(sum)) & 0xFF; // Two's complement checksum
// Send to BP1048B2
for (int i = 0; i < 10; i++)
bpSerial.write(commandLine[i]);
void playTrack(int trackNumber)
// Track number is usually 2 bytes (High/Low)
byte high = trackNumber >> 8;
byte low = trackNumber & 0xFF;
sendCommand(0x03, high, low);
Serial.print("Playing track: "); Serial.println(trackNumber);
void setVolume(int vol)
// Volume range is usually 0-30
if (vol > 30) vol = 30;
sendCommand(0x06, 0x00, vol);
Serial.print("Volume set to: "); Serial.println(vol);
void play()
sendCommand(0x0D, 0x00, 0x00);
void pause()
sendCommand(0x0E, 0x00, 0x00);
Suggested energy-saving setpoints:
Best Template:
static volatile uint8_t bt_data_ready = 0;void BT_ISR_HANDLER(void) bt_data_ready = 1; // Just set a flag – 1 cycle bp1048b2 programming best
void main_loop(void) if (bt_data_ready) bt_data_ready = 0; decode_bluetooth_packet(); // Do the heavy work hereCopy this code into your Arduino IDE
001.mp3, 002.mp3, etc., inside a folder named mp3. This is the standard for these chips.