BBMagic PWM is a wireless PWM regulation module with Bluetooth Low Energy (BLE), Bluetooth Smart communication.
BBMagic PWM functions
- Three PWM channels with gamma correction ; suitable for LEDs driving
- gamma correction turning off ability (pin 14 (GAMMA CORR))) ; ideally for DC motor driving
- PWM phase configurable by pin 6 (INV_CONF). It can drive PNP and NPN transistors
- Automatic turn on for 15 minutes after modules power up ; pin 17 configurable
- Supply voltage monitoring
- Light level measurement ; pads for 10k photoresistor ; values range from 0 to 255
- ADC input with range from 0 to 1,8V ; 1mV resolution
- Chip temperature measurement
- LED radio transmission indication – pin 2 configurable
- Communication: encrypted and digital signed Bluetooth Smart messages
- Easy to use Raspberry Pi 3 or zero W programming interface – bbmagic_lib_2.0
Pinout
Pin number | Description |
---|---|
1,8,20,22,23,24 | GND – power and signal ground |
2 | Configuration of the radio transmission indication:
|
3-5 | Three PWM outputs. |
6 | Configuration input INV_CONF:
|
7,21 | Supply voltage from 1,8V to 3,6V |
7,8,9 | Pads for voltage regulator if you want to power BBMagic PWM this way. Its identical like BBMagic METEO described here: Power it easy: BBMagic METEO Bluetooth Low Energy module |
10 | Supply voltage input for voltage regulator (Reverse polarity protected). Its identical like BBMagic METEO described here: Power it easy: BBMagic METEO Bluetooth Low Energy module |
11,12 | 10k photoresistor pads |
13 | Input of analog to digital converter ADC_1. Available voltage range: 0V-1,8V ; Resolution: 1mV |
14 | Configuration input GAMMA CORR
|
15,16 | Pads for alternative LED with series resistor. Pad 15 – LED anode with resistor, Pad 16 – LED cathode |
17 | Configuration input START CONF
|
18,19 | Tx and Rx UART lines. Available voltage range: 0V-5V |
Working modes
BBMagic PWM working mode | Pin 6 (INV_CONF) state | Pin 14 (GAMMA CORR) state | |
---|---|---|---|
1 | PWM mode with gamma correction | not connected | not connected |
2 | PWM mode without gamma correction | not connected | connected to GND (20,22,23,24) |
3 | PWM_INVERT mode with gamma correction | connected to GND (20,22,23,24) | not connected |
4 | PWM_INVERT mode without gamma correction | connected to GND (20,22,23,24) | connected to GND (20,22,23,24) |

How BBMagic PWM works
After power up BBmagic PWM sends ‘ALIVE’ messages every 60 seconds.
When it receives demand message drives CHANNEL_0..CHANNEL_2 outputs and immediately sends ‘ALIVE’ message to confirm that job is done.
Whats in ‘ALIVE’ message?
Library header file bbmagic_lib.h (within bbmagic_lib_2.0) defines types of data sending by BBMagic PWM .
bbm_buf[BBMAGIC_DEVICE_TYPE] | module type ; there is BBMAGIC_M_PWM in this particular case |
bbm_buf[BBM_PWM_V_SUP] | modules supply voltage ; divide this value by 71 (BBMAGIC_VCC_DIVIDER) to have power supply in volts |
bbm_buf[BBMAGIC_PWM_ADV_TIME] | next ‘ALIVE’ message from BBMagic PWM will arrive after this period of time ; multiply it by two to get time in seconds |
bbm_buf[BBM_PWM_CHIP_TEMP] | modules chip temperature in Celsius (U2 encoded) – after callibration this measurement can be interpreted as low accuracy ambient temperature |
bbm_buf[BBM_PWM_LIGHT] | light level ; from 0 to 255 |
bbm_buf[BBM_PWM_CH0] | current CHANNEL_0 output setting ; range from 0 to 100 |
bbm_buf[BBM_PWM_CH1] | current CHANNEL_1 output setting ; range from 0 to 100 |
bbm_buf[BBM_PWM_CH2] | current CHANNEL_2 output setting ; range from 0 to 100 |
bbm_buf[BBM_PWM_ADC_1_MSB] i bbm_buf[BBM_PWM_ADC_1_LSB] | voltage level on ADC_1 input in mV |
bbm_buf[BBM_PWM_WORKTIME_0] | amount of time from modules power up – in seconds ; byte 0 – LSB |
bbm_buf[BBM_PWM_WORKTIME_1] | amount of time from modules power up – in seconds ; byte 1 |
bbm_buf[BBM_PWM_WORKTIME_2] | amount of time from modules power up – in seconds ; byte 2 |
bbm_buf[BBM_PWM_WORKTIME_3] | amount of time from modules power up – in seconds ; byte 3 – MSB |
bbm_buf[BBM_PWM_FIRM_0] | modules firmware version LSB |
bbm_buf[BBM_PWM_FIRM_1] | modules firmware version MSB |
bbm_buf[BBMAGIC_DEVICE_ADDR_0] | modules address byte 0 – LSB |
bbm_buf[BBMAGIC_DEVICE_ADDR_1] | modules address byte 1 |
bbm_buf[BBMAGIC_DEVICE_ADDR_2] | modules address byte 2 |
bbm_buf[BBMAGIC_DEVICE_ADDR_3] | modules address byte 3 |
bbm_buf[BBMAGIC_DEVICE_ADDR_4] | modules address byte 4 |
bbm_buf[BBMAGIC_DEVICE_ADDR_5] | modules address byte 5 – MSB |
bbm_buf[BBMAGIC_DEVICE_RSSI] | radio signal strength indicator (RSSI) in dBm |
Wireless communication
- Bluetooth Low Energy also called as Bluetooth Smart
- Transferring data is encrypted and signed with AES-128
- You can collect and process data with Raspberry Pi, Arduino, etc.
- Direct communication with Raspberry Pi Zero W and Raspberry Pi 3 (both have Bluetooth Low Energy onboard chip)
- Linux library for easy programming from version bbmagic_lib_2.0
Powering
BBMagic PWM needs about 12mA of current. You can power it:
- from any source you want within 1,8V to 3,6V – connect to pins 7 (+) and 8 (-)
- with voltage regulator – connect ‘+’ to 10, and ‘-‘ to 22, 23 or 24. Onboard pads 7,8,9 for TO-92 voltage regulator (ex. L78L33, TS2950CT-3.3, LP2950CZ-3.3RAG, MCP1702-3302E, LM2936Z-3.3, LT1121CZ-3.3). Learn more about voltage reg here: Power it easy: BBMagic METEO Bluetooth Low Energy module
To set BBMagic PWM
You only need to add your module to actors database:
bbm_pwm_add("my_pwm_dev", "CBFD786BAA68", "2DFDA5070CD284A107A24F7e53572A7B38") ;
…and use lib function ‘bbm_pwm_set’:
bbm_pwm_set("my_pwm_dev",10,20,50) ;
CHANNEL_0, CHANNEL_1 and CHANNEL_2 outputs are now driving 10%, 20% and 50% respectively.