Leveling the RV/trailer in the parking lot

level' sensor works vice the second crew member while leveling the RV/trailer with wedges

Mobirise

Main components:
- Bluetooth 4.0 LE module,
- ADXL345 three-axis accelerometer,
- DC-DC 14-3.3V 0.5A converter,
- camper's single-board computer with a 4.0 Bluetooth USB dongle,
- the camper's router.

ADXL345 three-axis accelerometer was used for control the pitch and the roll of a camper (both motorhome or trailer). This sensor was connected to the Bluetooth controller that translates leveling data via the camper's single-board computer to any camper's crew gadget, for example, to a smartphone that can be placed face to driver while leveling.

Note: an accelerometer is embedded on a board in any modern smartphone. Many smartphone apps can show the pitch and the roll of an object where this smartphone places in. But while parking a camper on a wedge (wedges) in leveling order, it is not easy to use a smartphone's accelerometer as this smartphone must be placed horizontally, in the same time as the direction of driver's look must be normal as while driving. A smartphone's accelerometer is not easy to use in order to level a trailer, as this smartphone must be placed in the trailer, while the driver must be in a truck. For the same reasons, the use of a hydraulic "bubble" level is not always convenient.

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 the accelerometer 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 14V to 3.3V for both the Bluetooth Nordic nRF52832 4.0 LE module and ADXL345 sensor.

All settings were made via Windows PC (64 bit is preferred) with toolchain was installed on:

  • the MinGW was deployed in folder C:\MinGW. While installing under Basic Setup, were chosen packages mingw-developer-toolkit, mingw32-base, mingw32-gcc-g++, msys-base. Then Installation.Apply Changes.Apply was approved.
  • to the Windows PATH environment variable was added substring C:\MinGW\bin;C:\MinGW\msys\1.0\bin.
  • the SDK archive (version 15.2.0_9412b96) for nRF52832 was extracted in the workspace named C:\Users\%username%\Documents\nRF5 in folder nRF5SDK15209412b96.
  • the GNU-ARM-GCC package was deployed with the checked on "Add path to environment variable" while installing. In that time the 8.2.1 version was installed.
  • as known bug of v.8 GNU-ARM-GCC package, file arm-none-eabi-objcopy.exe from C:\Program Files (x86)\GNU Tools ARM Embedded\8 2018-q4-major\bin folder was replaced on this one from GNU-ARM-GCC package v.6.
  • the Geany text editor was used for editing the source code of the Bluetooth Nordic nRF52832 module firmware (only one string with the global UUID must be corrected). That editor can be deployed anyplace.

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.

Mobirise

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 pinnRF52832 BT module pin
TMS33 (SWDIO)
TCK32 (SWDCLK)
VCC 3.3V10 (VCC)
GND24 (GND)

Next steps were on the PC in order to flash Bluetooth Nordic nRF52832 module:

  • this main.c file was placed instead of the existing one in
    C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\examples\ble_peripheral\ble_app_uart 
  • this Makefile file was placed instead of the existing one in
    C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\examples\ble_peripheral\ble_app_uart\pca10040\s132\armgcc 
  • this sdk_config.h file was placed instead of the existing one in
    C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\examples\ble_peripheral\ble_app_uart\pca10040\s132\config
  • then on site https://www.uuidgenerator.net/ was generated a global unique identifier (UUID) for this one Bluetooth Nordic nRF52832 module exemplar. Then just generated UUID was converted on other one site to the byte-string (uuid_byte_array). This byte-string was rewrited with Geany text editor in file main.c placed in C:\Users\%username%\Documents\nRF5\nRF5SDK15209412b96\examples\ble_peripheral\ble_app_uart instead string "0x2a,0x7d,0xeb,0x03,0xe6,0x36,0x45,0x3e,0x9c,0x66,0xc9,0xf5,0xc1,0x3c,0x1b,0xdd". This UUID must be changed in order to not confluence will with some other camper assistants or other Bluetooth devices on a road or at a parking lot.
  • then file main.c was saved with no other modifications within.
On the PC was opened the command-line terminal:

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 ADXL345 sensor. The Black Magic Probe programmer was disconnected to Bluetooth Nordic nRF52832 module and to the PC.

Note: not only one version of a sensor with ADXL345 chip on market. The version was used here with pull-up resistors installed.

Mobirise


The Bluetooth Nordic nRF52832 module was soldered to ADXL345 sensor as this wiring diagram with only two wires:

nRF52832 BT module pinADXL345 pin
3 (P0.27)SCL
2 (P0.26)SDA

All components 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 12V 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-3.3V DC-DC converter was connected as this wiring diagram:

the 14-3.3V DC-DC converter pinother devices pins
DC IN +Via power on/off button to pole "+" of the screw connector
DC IN -Pole "-" of the screw connector
DC OUT +Bluetooth Nordic nRF52832 module pin 10 (VCC),
ADXL345 pin 3V3
DC OUT -Bluetooth Nordic nRF52832 module pin 24 (GND),
ADXL345 pin GND
Mobirise

The assembled sensor was equipped with the suitable case and was installed in the camper. No need to align exactly the sensor in horizont, the error of alignment can be passed in script parameters as described bottom here.

The case of this sensor was with holes for mounting, for the power button and for free air convection.

The sensor was connected to the onboard 12V line.

Mobirise

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 ADXL345 sensor in hexadecimal RAW format at this moment. This data will change from time to time.

In order to convert RAW-data of ADXL345 sensor to the altitude indicator for leveling process, this set of files must be placed (being unzipped) on any computer in the camper's network, but where Node.js 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.

Mobirise

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.

Mobirise

The set of files was copied via WinSCP to the /home/USERNAME/CA_Leveling 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_Leveling is folder where the set of files was copied;

- dd1babcdf5c9669c3e4536e603eb7d2a is UUID of Bluetooth Nordic nRF52832 module that was obtained as described above;

- 0.0 0.0 is the Roll and the Pitch correction, here mean no correction set;

- 3000 is the port number of http server where ADXL345 measured parameters will broadcasts:

cd /home/USERNAME/CA_Leveling

sudo node leveling.js dd1babcdf5c9669c3e4536e603eb7d2a 0.0 0.0 3000

Mobirise

From this moment, on any computer (gadget) in the camper's network, within the browser by address 192.168.1.71:3000 will show the altitude indicator.

Instant digits of the roll and of the pitch are displayed on the page colored as background color in order to not to distract the driver, but this data can be used for stocktaking the inaccurate position of the leveling sensor.

Mobirise

For collecting this data in Windows buffer is only needed to press Ctrl+A any moment while the browser shows the altitude indicator, and then press Ctrl+C. At this time the sensor must be installed in the camper and the camper must be leveled horizontally.

The parameters of the roll and of the pitch been achieved in horizontally leveled camper, can be passed in script parameters (in order to take into account the inaccuracy of the sensor installation, if this happens). Bottom listed commands were entered, where

- /home/USERNAME/CA_Leveling is folder where the set of files was copied;

- dd1babcdf5c9669c3e4536e603eb7d2a is UUID of Bluetooth Nordic nRF52832 module that was obtained as described above;

- 5.55 0.16 is the Roll and the Pitch correction that was obtained as described above;

- 3000 is the port number of http server where ADXL345 measured parameters will broadcasts:

crontab -e

@reboot sleep 10; sudo modprobe -r btusb; sleep 10; sudo modprobe btusb

@reboot sleep 40; cd /home/USERNAME/CA_Leveling; sudo node leveling.js dd1babcdf5c9669c3e4536e603eb7d2a 5.55 0.16 3000 >> /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 altitude 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 altitude 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.

A software you can load from this site is free for a non-commercial use except for components for which their owners declared their own rights. Can be limited by local laws. No of your data will be collected with a software you can load from this site.

Subscribe for updates.

This site was designed with Mobirise website themes