Be the Best Sensors’ Manufacturer and One Stop Solution Service

kaijite3@kjtsensor.com

pi based parking assist system

by:KJTDQ     2020-06-04
Hey there!
This is a cool little project you can do in an afternoon and then use it every day.
It is based on Raspberry Pi Zero W and will help you to park your car perfectly every time.
Here is the complete list of the parts you need: you have no doubt heard of Raspberry Pi, but what exactly is pi \"Zero w?
Raspberry Pi Zero and Zero W are the newest members of the Pi family, which means more for IoT and other low cost embedded applications.
They are a streamlined version of the original pi board, but are still equipped with a powerful 1 GHz processor.
This is a good comparison of all models.
The advantage of choosing Pi Zero W here compared to other controller boards is that we can easily use higher level Python while still using fast C/c led panel drivers
The price is also very attractive, only $10.
Keep in mind that since this board is a streamlined version of the full pi
Some things have changed.
In particular, the Ethernet jack was eliminated, the HDMI connector was changed to a mini size, and the four USB ports were reduced to only one micro USB type.
There is also a micro USB connector on board, but it only supplies power to the motherboard.
Eliminating some complexity from all full-size USB connectors.
That is, how do you connect the keyboard and mouse?
Standard USB connectors and hubs use A-type connectors instead of micro-connectors.
What can we do?
We can go headless!
No, we don\'t want to go crazy, we want to use an alternative to normal direct wired setup.
Headless means remote \"tunnel\" into pi using containment (SSH)
Network connection.
For this project, we will use headless method via WiFi.
Therefore, the reason why we chose the W version of pi zero instead of the lower cost pi zero.
Note that there is also another way to run pi in headless mode using something called VNC.
It needs special VNC software running on your computer because it provides a complete virtual graphics desktop on your computer.
We don\'t need (
I really don\'t want it.
The desktop of our project, so we will stick to the simpler SSH method.
The 32x32 LED matrix panel itself can withstand the current of several amps. No kidding!
That\'s why most of these panels include some power cord that looks big to power it.
Fortunately for us, although we don\'t need to get a lot of power supply for this project.
We can only power the entire system with a spare 5 v/2amp mini phone charger.
The reason for the low current is because we use relatively simple graphics, so most LEDs are not turned on.
If you want to animate or use video/bright graphics, then you should definitely consider powering the panel with a separate power supply.
Did you notice that we used two tinyLiDARs instead of one in this system?
As shown in the garage setup diagram, one is placed in front of the car and the other on one side of the car.
When you park, the side sensor will detect if you are off the center, and of course the sensor in front will tell you when to stop.
The 32x32 LED display will help you by showing the arrows moving forward, left or right and the countdown display with colored corners to indicate how far you still need to drive.
Take a look at all our short videos showing the status.
In short, we are using the hzeller C library that has been popular with LED drivers for all time, the control code is in Python, and the sensor uses the pipgpio C library for proper I2C control.
Python is a very simple high-level language that you can easily edit on any text editor.
We usually use SublimeText, and for this project we also use a very useful FTP plugin that allows us to edit script files directly on pi.
This is an optional step because it is only needed if you want to edit the code.
More details can be found at the end of this article.
As you may know, I2C clock stretch is not supported on all rpi boards themselves.
So we used the pigpio library again in this project to control the tinyLiDAR sensor, but this time it\'s a little bit distorted. . .
When you buy tinyLiDAR, it is always set to the default from address 0x10.
This is fine when you use one sensor, but if you have more than one sensor on your bus, if you write a command to 0x10 and all the sensors reply, this!
So we have 3 options here: first, we can use (tinyLiDAR)
The \"R\" command writes a new slave address to a sensor connected to the I2C bus.
This is then repeated for each sensor.
Each sensor is physically connected, written, and separated for this process.
TinyLiDAR will store a given address in its onboard AfricaUnstable memory
Even after the power cycle, the address persists until you clear it by issuing a reset command.
The second option is to use the convenient automatic allocation function we created in the IGG activity as a stretch target.
This involves sending the \"AR\" command and then pointing the finger to each sensor separately to automatically assign the sequential I2C address similar to the first option for each sensor, but this can be done without physically disconnecting each sensor.
The third option is the one we use in this project, which is possible thanks to the pigpio Library.
The I2C standard is properly implemented, and the GPIO of pigpio bitbangs.
Therefore, because of this, we can easily create a separate I2C bus on almost any pair of spare GPIO pins.
Therefore, there is no need to re-
Program slave addresses for multiple LiDAR sensors.
We can use a separate bus for each car :)
Note that the I2C bus running at 100 Kbps is actually very robust.
We use the normal old CAT5 Ethernet cable to run the I2C bus to the tinyLiDAR sensor side at a distance of 25 feet without any active repeater components!
The sensor wiring details are shown above.
OK, that\'s enough for jibber jabber. let\'s start downloading the code!
Note: pi uses a Linux file system, so it is better to perform the following steps on a Linux-based system.
If you do this on Windows, you may reformat the SD card.
We used Ubuntu 18 for free.
04 desktop running in virtual environment on Windows 10 PC, but you can try something like that.
You need to download the OS from raspberrypi first.
Then burn it to a microSD card.
Follow these steps:1)
In Ubuntu, come here to get the Raspbian Lite image.
Save to your download folder. (2)
Next download the Etcher SD Card Write utility. FYI -
The official Etcher download link for the Linux version on their home page doesn\'t work for us, so we used the method described here: in short, the steps described in the link are: add the etching machine debian Library: trust Bintray.
GPG key for Com: update and install: you can start Etcher from Ubuntu desktop when you are done.
It will ask you for the source file (
You put it in the download folder).
The next step for Etcher is to select the right target.
Etcher does a great job of detecting your micro SD card, but you should be paranoid here.
To verify that it found the correct destination
Try to pop up the microSD card by clicking pop up in the Ubuntu file explorer window and verify that it disappears as a target option inside the Etcher.
Then bounce it back and move on to the last step, which is to write the file to this microSD card.
Wait for a while until it\'s done and move on.
OK, it\'s time to enter your WiFi details.
When Etcher writes to the micro SD card, two drives will appear, as shown above.
We need to go into the boot folder using the file manager and make a file called wpa_supply. conf.
To perform this step, you can click boot on the left side of the screen, then right-click on white background on the right side of the screen, and select open in terminal \".
This will pop up and open the terminal window (
Similar to CMD in Windows)
You can type the following in it: then, the above Command will start the \"nano\" text editor, where you can enter the following information: Note: remember to replace WiFi_SSID and WiFi_Password with your own WiFi network name and password.
Once you\'re done, just click Ctrl X to exit and then answer yes when you exit to write to the file.
Our next step is to create an empty file called ssh.
To do this, we just type the following in the terminal window: Now we need to give our pi a static IP address so we know where it is every time we want to connect to it
Type the following in the terminal window: This should open the Nano text editor again and we can add this text to the bottom of the file: Note: This assumes that your network prefix is 192. 168. 0.
If you have 192168.
Then use your network.
Domain Name Server 8. 8. 8.
8 is Google and its optional.
Type \"exit\" in the terminal to close it.
Then right-click the startup name on the left side of the file manager window and select pop-up \".
Now you can plug this microSD card into the pi and plug in the microousb power cord to power the pi.
The green LED flashes for a while if everything goes well, just like it is accessing the hard drive, it will let you log in to the WiFi network.
Give it about a minute to settle down and wait for the LED to turn green.
To verify if all this works, we can try to ping it.
So just type the line below and check if there is a response.
In Ubuntu, you should get something like this: please note that the ping will continue to run until you press Ctrl C to exit.
In Windows, you should get something like this: all good? Onwards. . .
Now that we are connected to the pi, we want to send the command. But how? Putty, of course!
After downloading the PuTTY software, you can download the PuTTY from hereSetting up PuTTY and make a profile for your pi with the following information: host name (or IP address): 192. 168. 0.
200 connection type: SSHGive gives this profile a name under the saved session and then clicks save.
You can log in with any name you like, such as \"rpiz200 200\", just select it from the list and click load.
Then press Open.
Enter your username and password to log in: when you log in, here is a sample session that is shown in PuTTY: the first time you log in, it warns you that you have not changed your password yet.
You should change it to some strong and simple memory, so keep changing it by typing passwd and following the prompts.
We should next update the software on the pi by typing the following: this will download any updates it needs from your internet connection.
If the prompt allows to continue, answer yes and then give it some time to update.
At this point, we should probably also turn off the sound on the pi as it has some bad juju with the LED drive Library.
Copy, paste the following line at a time, press enter after each line: the output will be like this: then we have to restart the pi for the change to take effect, so type the following: the connection will of course be disconnected when the pi restarts so you can turn PuTTY off.
Try logging in again in a minute.
Now it\'s time to get a graphical FTP file manager called WinSCP.
You can download WinSCP from hereWinSCP, which is much like the file management program on Windows and Ubuntu.
It allows us to easily drag and drop files into the pi and create the director with just a right click.
After downloading, you need to set up the profile for the pi.
Log in to WinSCP settings in the pop-up and select a new site.
The session uses the following settings: File protocol: SFTP host name: 192. 168. 0.
200 user name: pi password :{
In the PuTTY step above, you change the default password to any password}
In advanced Site Settings, go to environment | Directory, enter/home/pi for the remote directory, and enter whatever you like for the local directory settings.
In advanced Site Settings, go to environment | Shell and select sudo su-
In The Shell drop-down list. Then hit Save.
Keep WinSCP and PuTTY open when you perform the following steps.
Enter the PuTTY terminal and enter the following: this will get us to the home directory inside the pi.
We can now get the LED driver library from github.
We need to pull the repo to use the latest code, so we need to install the git utility.
Enter this in PuTTY: Answer Y to continue, it takes a few seconds to install git for us from the Internet.
The output should be like this: go back to WinSCP now and navigate to the/home/pi folder.
Then on the right side of this WinScp window, right-click and select create a new directory in the PuTTY screen called Parking, you can type ls to confirm that you just create a new folder in the pi.
Then enter this: press enter to enter this directory.
Now we can get the driver file by entering the following in PuTTY: Now, by going into this new \"rpi-rgb-led-
Matri\' directory and type the make command: Our next step will be to bind the RGB matrix library to Python.
We used the default Python 2 in this project.
So to do this binding, we enter the following line at once as before: Note: you can safely ignore about \'-Wstrict-
The prototype displayed when running these two make statements.
The Make command takes a few minutes to run and they don\'t say anything when they are busy. So fear not -
Your pi should be back soon. )
Here is the partial output of the first make statement: Next we will install the pigpio C library.
In order to do this correctly, we need to start with the source code, so just enter the following lines: the installation above takes about 3 minutes.
Now is the time to get Python project files.
Enter the following: then to execute it, type the following: But you don\'t need to do it immediately, as we still have to connect everything. . .
As mentioned earlier, we use the same power adapter that powers the pi to power the LED panel.
In order to do this, you have to splice huge red and black wires onto the head pins so they can be plugged into pins 2 and 9 of the 40 pin pi connector.
Now unplug the pi and connect the LED panel as shown above.
Temporarily keep pin 2 disconnected.
We used a 25 feet CAT5 Ethernet cable and modified it to insert it into the pi head pin at one end and accept the GROVE connector pin at the other end, that way we can have tinyLiDAR sensors.
The photo above shows the cable before and after the modification.
Ignore the color of the header pin lines as they are not related to the chart.
Just make sure you connect your system as shown in the graphic connection diagram shown earlier in step 3.
The correct initial power-on sequence should be to plug the micro usb charger into the pi, waiting for the blue LEDs on the tinyLiDAR sensor to flash quickly, showing that they are being measured.
This proves that the code works fine.
You can then connect pin 2 of the LED panel power supply slowly but firmly.
Be careful not to be faulty when doing this!
If the LED panel shows several chilled bright LEDs, then it may flash, so take out the micro usb power supply from the pi, wait a few seconds and try the power-up order again.
To run the code, enter the following: if everything goes well, you should get a display similar to the one shown in the video.
Take a quick look at the parking lot.
Understand the py code of the restrictions we use.
The front sensor defaults to 200mm.
Since the range of the sensor is 11mm to 2 m, it is better to keep the nom _ parked_front distance at 200mm or higher.
The side sensor nom _ parked _ side is set to 600mm.
For Python Code that displays these configuration options, see the above figure.
If everything is OK, you can continue to install the system in the garage and adjust the above parameters as needed.
Since the pi is connected to WiFi, you can enter and edit the distance settings as needed at any time when installing specific garage settings.
Why? yes, yes! --
It\'s time to dance happily :)
Thank you for reading and enjoy your new parking assistant!
To edit the Python script file directly on the pi, we can install the FTP plugin named Sublime SFTP through Wbond.
You can download this plugin as per the instructions for installing this plugin. We need to configure FTP credentials under file | SFTP/FTP | installation server. . . page.
For our settings, we used: Save this information using Ctrl S or File | Save.
You will be prompted to enter the name to call this configuration.
We now simply call it \"rpiz0_200\" and log in to the pi from SublimeText and go to the file | SFTP/FTP | browse server. . .
Select from the list of options that pop up.
You will want to select a profile with the name specified above; )
Follow the prompts to navigate the folder and edit the required files.
Linux commands used on pi.
Be sure to turn off the pi before unplugging it so that there will be no file corruption on your microSD card.
Enter this command: wait for the green led to turn off before unplugging the power.
Custom message
Chat Online 编辑模式下无法使用
Chat Online inputting...