site design templates

Leveling the motorhome/trailer camper in the parking lot

level' sensor works vice the second crew member while leveling 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 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 not easy to use a smartphone's accelerometer as this smartphone must to be placed horizontally, in same time as direction of driver's look must be normal as while any driving. A smartphone's accelerometer not easy to use in order for leveling a trailer, as this smartphone must be placed in the trailer, while driver must be in a truck.

The Bluetooth Nordic nRF52832 4.0 LE module was used in this case. In one time this module controls the accelerometer and broadcast (advertise in therms of Bluetooth) measured parameters via Bluetooth. Looks like, but wasn't tested, the Bluetooth module with Nordic nRF52840 will works like here described too.

Any DC-DC 0.5A (or more) converter can steps 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, was choosed packages mingw-developer-toolkit, mingw32-base, mingw32-gcc-g++, msys-base. Then Installation.Apply Changes.Apply was approved.
  • for 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 process. In that time was installed 8.2.1 version.
  • 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 edit the source code of the Bluetooth Nordic nRF52832 module firmware (only one string with the global UUID need to edit). 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 was updates 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 on the PC was opened Device Manager:

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 his 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 was 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 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 reason to not confluence will with some other camper assistants or other Bluetooth devices on a road or on a parking lot.
  • then file main.c was saved and no other modification need to make within.
On the PC was opened the command-line terminal:

Win+R

cmd, Enter

Then in the PC command-line terminal was 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 COM-port number of "Black Magic GDB Server" that was noted above. If number of COM-port 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 been flashed for works with 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. Here was used version 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 was soldered together at the piece of Prototype Paper Printed Circuit Panel.

The power for this sensor served by the camper's onboard 12V line. For 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 for 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

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 time to time.

In order to convert RAW-data of ADXL345 sensor to the attitude 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 have static IP in the camper's network and tuned for not sleep, not hibernate.

Mobirise

The easy way to install the script is to use WinSCP on PC. In some cases will need 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 browser by address 192.168.1.71:3000 will shows the attitude indicator.

Instant digits of the roll and of the pitch are displays on the page colored as background color in order for 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 need to press Ctrl+A any moment while the browser shows attitude 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. 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 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

Thats all, once this computer been rebooted, the attitude indicator broadcasts to any gadget in the camper's network.

Note: few first usage of this application must be with Internet connection 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 your data will be collected with a software you can load from this site.

 

Get updates