It needs about three minutes
… to build BBMagic FLOOD sensor and… you will know when the water arrive. Feel save with BBMagic FLOOD.
What you need is:
- BBMagic FLOOD module
- CR2032 battery – 220mAh capacity
- CR2032 battery holder
- two wires for water detection
Lets build it:
- solder first wire to the 25 pad – green colour
- solder second wire to the ground – every blue pad is gnd
- solder battery holder to 21 (+) and 22 (-) pads
- install battery
- if pads 1 and 2 are connected LED blinks during Bluetooth radio transmission (it draw more power from the battery, of course)
You can power the module from 2xAA or 2xAAA battery pack to increase capacity even to 2500 mAh.
How to receive data from BBMagic FLOOD?
Raspberry Pi zero W and Raspberry Pi 3 can receive data from BBMagic modules using bbmagic_lib library. You can get it from Download section. Its very easy:
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_FLOOD)
{
if((bbm_buf[BBM_FLOOD_ALERT_FLAGS] & BBM_FLOOD_ALERT_MASK) == 0)
turn_off_pomp-its_done() ;
else
turn_on_pomp-save_me() ;
}
Library header file (bbmagic_lib.h) defines types of data sending by BBMagic FLOOD
bbm_buf[BBMAGIC_DEVICE_TYPE] | module type ; BBMAGIC_M_FLOOD in this particular case |
bbm_buf[BBM_FLOOD_ALERT_FLAGS] | flood detection flags ; if BBM_FLOOD_ALERT_MASK is set it means flood alert |
bbm_buf[BBM_FLOOD_V_SUP] | supply voltage ; divide this value by 71 (BBMAGIC_VCC_DIVIDER) to have power supply voltage in volts |
bbm_buf[BBM_FLOOD_ADV_TIME] | next message from BBMagic FLOOD will arrive after this period of time ; multiply it by two to get time in seconds |
bbm_buf[BBM_FLOOD_CHIP_TEMP] | BBMagic chip temperature in Celsius (U2 encoded) – can be interpreted as ambient temperature with low 3*C accuracy |
bbm_buf[BBM_FLOOD_WORKTIME_0] | amount of time from module power up – in seconds ; byte 0 – LSB |
bbm_buf[BBM_FLOOD_WORKTIME_1] | amount of time from module power up – in seconds ; byte 1 |
bbm_buf[BBM_FLOOD_WORKTIME_2] | amount of time from module power up – in seconds ; byte 2 |
bbm_buf[BBM_FLOOD_WORKTIME_3] | amount of time from module power up – in seconds ; byte 3 – MSB |
bbm_buf[BBM_FLOOD_FIRM_0] | module firmware version LSB |
bbm_buf[BBM_FLOOD_FIRM_1] | module firmware version MSB |
bbm_buf[BBMAGIC_DEVICE_ADDR_0] | module address byte 0 – LSB |
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 – MSB |
bbm_buf[BBMAGIC_DEVICE_RSSI] | radio signal strength indicator in dBm |
And it is done
If both electodes are in the water BBMagic FLOOD sends ALERT message every 6 seconds. If there is no water module sends ALIVE message. You can configure how often it happens.

BBMagic FLOOD modes of operation
BBMagic FLOOD can work in one of four modes.
Work mode | ALIVE message period | ALERT message period |
---|---|---|
1 | 30 seconds | 6 seconds |
2 | 60 seconds | 6 seconds |
3 | 3 minutes | 6 seconds |
4 | 5 minutes | 6 seconds |
To set BBMagic FLOOD working mode you need
- turn off power of the module
- push configuration button
- turn on power holding the button pressed
- hold the button pressed while LED flashing: 1 flash – work mode = 1, 2 flashes – work mode = 2, etc.
- release the button
- LED turns off for about 2 seconds and then flashes few times, depending on configured work mode: 1 flash – configured mode = 1, 2 flashes – configured mode = 2, etc.
Every time you turn BBMagic FLOOD power on onboard LED flashes:
- 1 time – the module works mode is 1 – ALIVE message period is 30 seconds
- 2 times – the module work mode is 2 – ALIVE message period is 1 minute
- 3 times – the module work mode is 3 – ALIVE message period is 3 minutes
- 4 times – the module work mode is 4 – ALIVE message period is 5 minutes
Additional BBMagic FLOOD functions
- Battery monitoring – continuous supply voltage measurement
- Chip temperature measurement – After callibration can be interpreted as low accuracy ambient temperature
- Data transfer LED indication – pin 2 configurable
Communication
- Bluetooth Smart also called as Bluetooth Low Energy
- Transferring data is encrypted and signed with AES-128
- Direct communication with Raspberry Pi Zero W and Raspberry Pi 3 (both 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