Friday, April 26, 2024

Caravan/motor-home leveler part 1 (hardware)

For an index to all my stories click this text

In a previous story on this weblog I showed how to get human readable x and y angle values from an MPU6050. You can read that story here:
http://lucstechblog.blogspot.com/2024/04/mpu6050-data-in-degrees-instead-of.html
And I build something really useful with this.



I made a project that helps with leveling your caravan or motorhome !!

The story.

Last summer we went on a holiday. And we always go camping. We camp with a tent. But on most camping sites nowadays lots of people have caravans or motorhomes.
The first thing you need to do with a caravan or motor-home is to set it level. If it is not things will roll from your table. Water will not go down the drain or you will tumble out of your bed. OK I know that last one is extreme.

I saw a lot of people that were struggling with getting their caravan/motorhome horizontal. They put a leveler in the doorway. Went to the blocks and adjusted them, then went back to the leveler to see if it was horizontal. Then they went back to the block, adjusted again and went back to look at the leveler etc.

Hey in a motorhome you can put the leveler on your dashboard and then just ride up the blocks till your horizontal?? No does not work that way because most dashboards are tilted.
Ok then put the leveler on a table. Well that does not work either as the table is behind the driver so he can't see if it's horizontal.

So then I got an idea.
Why not build an electronic device that you can put on your motorhome/caravan's table. And then that device sends it data to an app on your phone. Then you can go outside and look at your phone's screen while leveling your caravan/motorhome !!


The above picture shows a screendump of two versions of my caravan and motorhome leveling aid. The picture on the left shows a screendump from a JavaScript program which run's in your phone's browser. The picture on the right side shows the output from a dedicated app for your phone.

I made several versions of the software before I was satisfied and decided these were the final versions. Both will be published in the next story on this weblog so keep following. In this story I'll show you how to build the electronics.

And of course you can use this for many other things like DIY home improvement projects as this is not just a caravan leveler but a general remote leveling aid.


Here is a video that demonstrates how it functions. As you can see the device works on batteries and is wireless connected to a phone. There is a delay build in the app. Shortening the delay time will make the ball move smoother. That is expalined in the story about building the app.

What you'll need

To build this project you will need:
- A battery holder for 3 AA or 3 AAA batteries
- A small on-of switch
- A led (I used a clear red one)
- A 220 Ohm delimiting resistor
- Female headers for the MPU6050 and ESP8266
- A Wemos D1 Mini (ESP8266)
- An MPU6050
- An enclosure (I printed mine)

I used a clear red led as that gives  the best visibility in broad daylight.
The led and the switch were added because in de test phase I often forgot to switch set set off so the batteries got drained. The led reminds you that the power is still on.

Please be aware that you do need a microcontroller with Wifi. The controller will send it's data over Wifi to the mobile phone.

If you are very confident about soldering you can leave the female headers out, but I do not recommend that.

The program for the microcontroller is written in MicroPython.  This makes it easy to replace the Wemos D1 Mini by an ESP32 Dev board or a Raspberry Pi Pico W. You will just have to adjust the pin numbers in the program. And of course the enclosure I build will not fit as these controllers are larger.

The hardware setup

The first setup was made without the batteries. I tested everything while the Wemos was attached to my computer and powered over the USB connection.

This was the initial setup. This is the setup as described in the previous story. This was ok for testing while it was connected to my computer.


And this is the schematics for the setup with the battery.
For your convenience I give the connections verbally.

- The GND of a 3 pack AAA or AA batteries is connected to the GND of the ESP8266 and the GND of the MPU6050. Next to that it is connected to a 220 Ohm delimiting resistor that is connected to a led.

- The VCC (+) of the battery pack is connected to the common connection (middle) of an on-off switch.

- The ON pin of the on-of switch is connected to the led and to the 5V pin of the ESP8266

- The MPU6050 needs 3V3 and is powered from the 3V3 pin of the ESP8266

- The SCL pin of the MPU6050 is connected to D1 (pin 5) of the ESP8266

- The SDA pin of the MPU6050 is connected to D2 (pin 4) of the ESP8266

Be Carefull:
NEVER CONNECT THIS PROJECT TO YOUR COMPUTER WITH AN USB CONNECTION WHILE THERE ARE BATTERIES IN THE BATTERY HOLDER. YOU MIGHT DAMAGE YOUR WEMOS OR EVEN YOUR COMPUTER THAT WAY.

So for testing leave the batteries out and connect to the computer with USB. For real time use disconnect the computer and use the batteries.



And here is the stripboard setup.
Cut the stripboard so it is as large as actually needed otherwise it will not fit in the below presented enclosure. Even better (maybe): 3D print the enclosure and then make the stripboard fit before soldering the electronics to it. Or cut the stripboard to fit into your own enclosure.

Make sure the stripboard lines beneath the Wemos D1 Mini are cut as otherwise the upper and lower pins are connected and that is something you definitely don't want.

The enclosure

Like stated before I designed an enclosure for this project and 3D printed it.



This is how the complete setup looks. The left lid on the box is white and that is the battery compartment. The right side's lid is purple and that is where the electronics reside. Please note that this enclosure is not water tight so keep it away from rain and moisture.
When everything is build and tested you can glue the right-side lid on the enclosure. The left side needs to stay open, of course, to change the batteries.



This is a closeup on how I fitted the stripboard into the enclosure.




And this is how the complete setup looks.
I used hot glue to secure the switch and the led to the enclosures wall. And I used screw connectors for the connections of the switch and the led. That is not necessary but makes assembling and disassembling easier.

At the left side of the casing is a gap that makes the USB connector accessible.

Some notes:

- Make sure the headers for the MPU6050 are soldered completely vertical (90 degrees) to the stripboard. If they have an inclination that will influence your readings.
- I made some small strips of a few mm height and put these at the sides of the casing. The stripboard rests on these so the stripboard does not rest on the soldered spots which might incline the print and influence the readings.
- You could power the setup with a powerbank or from a computer with the usb connection on the Wemos. But an USB cable might put some tension on the Wemos and might give the stripboard an inclination and that influences the readings of the MCU6050.

Generally said: make sure that the stripboard is completely horizontal in the casing. And never power through the USB and with batteries at the same time.

The STL files.

There are 3 STL files. One for the box and 2 for the lids. Please be aware that the lid for the battery compartment is different from the lid for the electronics compartment. And yes, I forgot to make a hole for the led so I just drilled one.



Here is a link to the STL files so you can print your own casing.
You can however use any casing you like as long as the bottom is perfectly flat.

https://www.mediafire.com/folder/jpswchudmlwu5/Caravan-leveler

First test

You can use the program from the previous story to test if everything functions as it should. Here is the link to that program.

Next time: The software
For now you can build this, so you are well in time for the summer holliday.

So, that's it for now.
Have fun

Luc Volders