BBMagic BUTTON multifunction battery powered wireless


BBMagic BUTTON battery
BBMagic BUTTON

BBMagic BUTTON detects:

  • onboard tact switch single and double click
  • onboard tact switch holding
  • external button (connected to pads 24 and 25) single and double click
  • external button (connected to pads 24 and 25) holding

Writing app for BBMagic BUTTON

Raspberry Pi SBC with Bluetooth SMART chip onboard can receive data from BBMagic modules using bbmagic_lib library. You can get simple apps from Download section.
Programming is very easy (this code below is for bbmagic_lib_1.4)

Make some helpful variables and buffer for data

unsigned char bbm_buf[100] ;
int len, ret ;

Open communication

ret = bbm_bt_open(0) ;
    if(ret) exit(1) ;

Check if data has been received

len = bbm_bt_read(bbm_buf) ;

If so start processing

if(len > 0)
    if(bbm_buf[BBMAGIC_DEVICE_TYPE] == BBMAGIC_M_BUTTON)
    {
        if(bbm_buf[BBM_BUTTON_BUTTON_FUNCTION] == BBM_BUTTON_FN_SINGLE_CLICK)
            light_on() ;
        if(bbm_buf[BBM_BUTTON_BUTTON_FUNCTION] == BBM_BUTTON_FN_DOUBLE_CLICK)
            light_off() ;
        if(bbm_buf[BBM_BUTTON_BUTTON_FUNCTION] == BBM_BUTTON_FN_HOLDING)
            all_lights_off() ;
    }

Library header file (bbmagic_lib.h) defines types of data sending by BBMagic BUTTON

bbm_buf[BBMAGIC_DEVICE_TYPE] module type ; BBMAGIC_M_BUTTON in this particular case.
bbm_buf[BBM_BUTTON_BUTTON_FUNCTION] button function, can be: 1 – single push of onboard tact switch, 2 – double push of onboard tact switch, 3 – holding of onboard tact switch,
11 – single push of pads 24 and 25 external button, 12 – double push of pads 24 and 25 external button, 13 – holding of pads 24 and 25 external button.
bbm_buf[BBM_METEO_V_SUP] supply voltage ; divide this value by 71 (BBMAGIC_VCC_DIVIDER) to have power supply voltage in volts.
bbm_buf[BBM_BUTTON_INPUT_PINS] digital inputs state
bbm_buf[BBM_BUTTON_CHIP_TEMP] BBMagic chip temperature in Celsius (U2 encoded). After callibration can be interpreted as low accuracy ambient temperature.
bbm_buf[BBM_BUTTON_LIGHT] light level
bbm_buf[BBM_BUTTON_FIRM_0] module firmware version LSB
bbm_buf[BBM_BUTTON_FIRM_1] module firmware version MSB
bbm_buf[BBMAGIC_DEVICE_ADDR_0] module address byte 0
bbm_buf[BBMAGIC_DEVICE_ADDR_1] module address byte 1
bbm_buf[BBMAGIC_DEVICE_ADDR_2] module address byte 2
bbm_buf[BBMAGIC_DEVICE_ADDR_3] module address byte 3
bbm_buf[BBMAGIC_DEVICE_ADDR_4] module address byte 4
bbm_buf[BBMAGIC_DEVICE_ADDR_5] module address byte 5
bbm_buf[BBMAGIC_DEVICE_RSSI] radio signal strength indicator in dBm

Pinout

BBMagic BUTTON pinout

Pin number About pin
1,8,20,22,23,24 GND – power and signal ground
2 Connect to GND to turn on onboard red LED indication. Left unconnected: alternative LED_2 indication (external on pins 15 and 16)
3,4,5,6 GND active digital inputs sampled just after button action
7, 21 Supply voltage 1,8V – 3,6V
21, 22 Pads for CR2032 battery holder: 21 (+) i 22 (-)
7,8,9 Pads for voltage regulator if you decide to power BBMagic MAGNETO 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. Its identical like BBMagic METEO described here: Power it easy: BBMagic METEO Bluetooth Low Energy module
11, 12 10k photoresistor pads
13,14,17,18,19 not used
15, 16 Pads for alternative LED with series resistor. Pad 15 – LED anode with resistor, Pad 16 – LED cathode. If you want to use it left pin 2 unconnected
24, 25 Pads for external button connection

How BBMagic BUTTON works?

    It recognizes three button actions:

  • single and double click of onboard tact switch
  • one half second holding of onboard tact switch
  • single and double click of external button
  • one half second holding of external button

and sends appropriate messages through BBMagic over Bluetooth SMART radio link.

Additional BBMagic BUTTON functions

Light level measurement

  • 10k photoresistor
  • Value range: 0 to 255

Four digital inputs

  • GND-active
  • Sampled just after button action

Battery monitoring

  • Battery voltage is measured every button pressed

Chip temperature measurement

  • After callibration it can be interpreted as low accuracy ambient temperature

Wireless communication

  • BBMagic over Bluetooth SMART
  • Encrypted and signed AES-128
  • Direct communication with Raspberry Pi’s which have Bluetooth Low Energy onboard chip
  • Library for easy programming

Powering

  • 3V CR2032 battery – onboard pads for battery holder: 21 (+) and 22 (-)
  • 2 x 1,5V AA or AAA batteries – onboard pins for wires soldering: 7 (+) and 8 (-)
  • 2 x 1,2V NiCd or NiMH rechargeables – onboard pins for wires soldering: 7 (+) and 8 (-)
  • 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
Tagged , , . Bookmark the permalink.

Comments are closed.