Main components:
- Bluetooth 4.0 LE module,
- a water pressure sensor 0 to 0.5 MPa, 5V,
- INA219 DC current sensor,
- DC-DC 14/24V-5V-3.3V 0.5A converter,
- camper's single-board computer with a 4.0 Bluetooth USB dongle,
- the camper's router;
- BMP280 barometric pressure sensor (optional).
This sensor was developed to monitor the fluid level in a fresh "white" water tank within a camper.
The measured fluid's level data advertises around via Bluetooth for any computer or camper's crew gadget within the camper's network.
It might be any shape of a water tank, but this sensor should be installed as close to the bottom of the tank as possible.
A power line (14/24V or 5V) should be prepared for this sensor near to the tank.
The usage of BMP280 barometric pressure sensor is optional, it need for a precision measurement in mountains, and will be published here later.
The Bluetooth Nordic nRF52832 4.0 LE module was used in this case (the version with no block for user firmware flashing). In one time this module controls a water pressure (that is equivalent to a water level) and broadcasts (advertise in terms of Bluetooth) measured parameters via Bluetooth. Looks like, but wasn't tested, the Bluetooth module with Nordic nRF52840 will work like described here too.
Any DC-DC 0.5A (or more) converter can step down power from 14/24V to 5V for the pressure sensor and to 3.3V for the Bluetooth Nordic nRF52832 4.0 LE module.
All settings were made via Windows PC (64 bit is preferred) with toolchain was installed on:
Then in to file C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\components\toolchain\gcc\Makefile.windows
being opened in a text editor were updated strings ("/" here is right):
GNU_INSTALL_ROOT := C:/Program Files (x86)/GNU Tools ARM Embedded/8 2018-q4-major/bin/
GNU_VERSION := 8.2.1
GNU_PREFIX := arm-none-eabi
Black Magic Probe (BMP) programmer was used for the software flashing of the Bluetooth Nordic nRF52832 module in this case, this one programmer can be used for the flashing any Bluetooth nRF controllers for the Camper assistant. BMP programmer was connected to the PC via USB. Then Device Manager was opened on the PC:
Win+R
devmgmt.msc, Enter
In Device Manager in "Ports (COM & LPT)" topic was found "Black Magic GDB Server" device (this name is in Windows 7, but in Windows 10 here will be two "USB Serial Device", between them the device with minor COM-port number is sought for), and it's COM-port number was noted.
The Black Magic Probe programmer was connected to Bluetooth Nordic nRF52832 module with Test Hooks Clips for Logic Analyzers as this wiring diagram with only four wires:
Black Magic Probe programmer pin | nRF52832 BT module pin |
---|---|
TMS | 33 (SWDIO) |
TCK | 32 (SWDCLK) |
VCC 3.3V | 10 (VCC) |
GND | 24 (GND) |
Next steps were on the PC in order to flash Bluetooth Nordic nRF52832 module:
Win+R
cmd, Enter
Then in the PC command-line terminal were entered one by one:
mkdir c:\Users\%username%\temp
cd C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\examples\ble_peripheral\ble_app_uart\pca10040\s132\armgcc
make
cd C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\examples\ble_peripheral\ble_app_uart\pca10040\s132\armgcc\_build
copy nrf52832_xxaa.hex C:\Users\%username%\temp
copy C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\components\softdevice\s132\hex\s132_nrf52_6.1.0_softdevice.hex C:\Users\%username%\temp
cd C:\Program Files (x86)\Nordic Semiconductor\nrf5x\bin\
mergehex -m c:\Users\%username%\temp\s132_nrf52_6.1.0_softdevice.hex c:\Users\%username%\temp\nrf52832_xxaa.hex -o c:\Users\%username%\temp\out.hex
cd C:/Users/%username%/temp
arm-none-eabi-gdb
(gdb) target extended-remote com4
Note: here com4 is the COM-port number of "Black Magic GDB Server" that was noted above. If the number of COM-port is more than 10, then \\.\COM1x is used instead of COMx.
(gdb) monitor swdp_scan
(gdb) attach 1
(gdb) file out.hex
(gdb) y
(gdb) load C:/Users/%username%/temp/out.hex
(gdb) quit
(gdb) y
From this point, the Bluetooth Nordic nRF52832 module was ready for work with the water pressure sensor via INA219 DC current sensor. The Black Magic Probe programmer was disconnected to Bluetooth Nordic nRF52832 module and to the PC.
The Bluetooth Nordic nRF52832 module was soldered to INA219 DC current sensor as this wiring diagram with only two wires:
nRF52832 BT module pin | INA219 pin |
---|---|
3 (P0.27) | Scl |
2 (P0.26) | Sda |
The water pressure sensor's data line (yellow wire) was connected to the INA219 Vin+ pin, and the water pressure sensor's GND line (black wire) was connected to the INA219 Gnd pin.
All components, exclude the water pressure sensor, were soldered together at the piece of prototype circuit panel having metalized holes.
The power for this sensor is served by the camper's onboard 12/24V line. To take this power, the 2-pole screw connector was placed on the circuit panel. One latching normally-open button was placed on the circuit panel to switch this sensor on/off.
The 14/24V-5V-3.3V DC-DC converter was connected as this wiring diagram:
the 14/24V-5V-3.3V DC-DC converter pin | other devices pins |
---|---|
14/24V DC IN + | Via power on/off button to pole "+" of the screw connector |
14/24V DC IN - | Pole "-" of the screw connector |
DC OUT 5V+ | The water pressure sensor's power line (red wire) |
DC OUT 5V- | The water pressure sensor's GND line (black wire) |
DC OUT 3.3V+ | Bluetooth Nordic nRF52832 module pin 10 (VCC),
INA219 pin Vcc |
DC OUT 3.3V- | Bluetooth Nordic nRF52832 module pin 24 (GND),
INA219 pin Gnd |
The assembled sensor was equipped with the suitable case and was installed in the camper.
The water pressure sensor was installed with a NPT tee to the water tank outlet.
The case of the sensor was with holes for mounting, for the power button and for free air convection.
The sensor was connected to the onboard 12/24V line.
Once powered this sensor, the data broadcasts the Bluetooth Nordic nRF52832 can be examined with application nRF Connect for Mobile (Android/iOS).
Displayed 9E00180030FF is the data of the water pressure sensor in hexadecimal RAW format at this moment. This data will change from time to time.
In order to convert RAW-data of the water pressure sensor to the level indicator, this set of files must be placed (being unzipped) on any computer in the camper's network, but where Node.js v14 was installed. Here was used the computer where MQTT broker and the 4.0 Bluetooth USB dongle was deployed. Need to note that this computer has static IP in the camper's network and configured to not sleep/hibernate.
The easy way to install the script is to use WinSCP on PC. In some cases will need to switch off the PC firewall while settings. In WinSCP, a connection was established to the single-board computer via SCP protocol by host name (IP), port 22, root username and password.
The set of files was copied via WinSCP to the /home/USERNAME/CA_WTCheck folder (not to root folder).
Then in the PC was established connection to the single-board computer via PuTTY by host name (IP 192.168.1.71), port 22, root username and password. Next commands were entered, where
- /home/USERNAME/CA_WTCheck is folder where the set of files was copied;
- d41babcdf5c9669c3e4536e603eb7d2a is UUID of Bluetooth Nordic nRF52832 module that was obtained as described above;
- 2.01 20.01 is the minimal water level and the maximum water level parameters;
- 3001 is the port number of http server where water level measured parameters will broadcasts:
cd /home/USERNAME/CA_WTCheck
sudo node tcheck.js d41babcdf5c9669c3e4536e603eb7d2a 2.01 20.01 3001
From this moment, on any computer (gadget) in the camper's network, within the browser by address 192.168.1.71:3001 will show the fluid level in a water tank.
The minimal water level and the maximum water level parameters must be passed in the script parameters. Bottom listed commands were entered, where
- /home/USERNAME/CA_WTCheck is folder where the set of files was copied;
- d41babcdf5c9669c3e4536e603eb7d2a is UUID of Bluetooth Nordic nRF52832 module that was obtained as described above;
- 2.01 20.01 is the minimal water level and the maximum water level parameters, was noted when the tank was empty and was full;
- 3001 is the port number of http server where water level parameters will broadcasts:
crontab -e
@reboot sleep 10; sudo modprobe -r btusb; sleep 10; sudo modprobe btusb
@reboot sleep 40; cd /home/USERNAME/CA_WTCheck; sudo node tcheck.js d41babcdf5c9669c3e4536e603eb7d2a 2.01 20.01 3001 >> /dev/null
# and at least one empty line should be at the end of the file!
Ctrl+O, Enter, Ctrl+X
reboot
Note: the string "@reboot sleep 10; sudo modprobe -r btusb; sleep 10; sudo modprobe btusb" in the crontab file is optional, is for use if a Bluetooth LE dongle, being extremely low power consumption, has no a stable start.
Note: If the Bluetooth 4.0 BLE module/dongle will reboot with OS commands, then this computer needs to reboot too.
That's all, once this computer has been rebooted, the water level indicator can be accessed from any gadget in the camper's network.
Note: a few first usage of this application must be with Internet connection for the computer where level indicator's scripts were deployed and for camper's crew gadgets in order for buffering Java libraries being used. In further the Internet connection is not necessarily.
The web page was created with Mobirise template