WeatherCar

Introduction: WeatherCar

The WeatherCar, a small home-made project that can drive while also collecting usefull data!

I made this project as a final for my first year in the Howest of Kortrijk. This project doesn't have a good finish yet but this document goes about all the internals of this car, without making the full frame.

Step 1: Requirements

You will need all of these components for this project:
  • Raspberry PI
  • 2 x motor (12v)
  • Servo
  • DHT11
  • BMP280
  • GY-NEO6MV2 GPS module
  • 4 x NPN Transistors
  • 2 x Resistors (1k and 2k)
  • Motor driver
  • 2 x 6v battery packs
  • Prototyping board
  • Step-down voltage regulator
  • Insulated Copper wire
  • Flat cable
  • Old Micro-USB cable
  • Plywood

Step 2: Soldering / Wiring

For the first step we'll go straight into connecting all the wires. (PS. You can use a breadboard for testing before soldering everything)

I provided a scheme that shows you how i wired everything, altough i couldn't find the right part for my motordriver. For my motordriver I used the 4 NPN transistors to convert my 3.3v signal to a 12v signal to control the motor driver. This because the one i used only supports 1 voltage (12v because my motors are 12v).

Step 3: Raspberry Pi Setup

If you don't have a setup already, you'll need to do this first, otherwise you can skip this step if you have the requirered programs from the last code snippet in this step.

First of you'll need to download Raspbian desktop version, wich can be found here: https://www.raspberrypi.org/downloads/raspbian/

After you've downloaded this you'll have to use Etcher or WinDiskImager to put the image file onto the SD card from your raspberry Pi. (This could take a while).

When the program is done, open up file explorer and open the drive called "boot". In here you'll find a text file "cmdline.txt". Open this up and add ip=169.254.10.1 to the end of the file. Be carefull not to add any enters to the file as this could lead to trouble.

Now that the PI has a default ip address, we'll still need to enable SSH to be able to connect to it. You can do this by making a new file called "SSH" without any extension, this will tell the raspberry pi to enable ssh on first boot.

With this we can now connect to the raspberry pi using an ethernet cable. Connect the cable between your pc and the raspberry PI. Now we'll need an SSH client. For this i used putty (https://www.putty.org/). Open up putty and put 169.254.10.1 as hostname. It may take a while before you'll be able to connect.

Once you're connected, log in with these credentials:

Login: pi<br>Password: raspberry

Now we're able to setup an internet connection, to do this. Execute this command and replace SSID and Network password with your wifi's name and password.

echo "password" | wpa_passphrase "SSID" >> /etc/wpa_supplicant/wpa_supplicant/wpa_supplicant.conf

wpa_cli -i wlan0 reconfigure

Now that we have an internet connection we can install python and other needed programs using following commands

sudo apt update

sudo apt install -y python3-venv python3-pip python3-mysqldb mariadb-server uwsgi nginx uwsgi-plugin-python3

python3 -m pip install --upgrade pip setuptools wheel virtualenv

mkdir weathercar && cd weathercar

python3 -m venv --system-site-packages env

source env/bin/activate

python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib flask-socketio

Step 4: Database Setup

Now that you're raspberry pi has all the needed programs, we'll still need configure the database. Wich we can do by first starting Mysql

sudo mariadb

and then

CREATE USER 'project1-admin'@'localhost' IDENTIFIED BY 'adminpassword';
CREATE USER 'project1-web'@'localhost' IDENTIFIED BY 'webpassword';
CREATE USER 'project1-sensor'@'localhost' IDENTIFIED BY 'sensorpassword';

CREATE DATABASE weathercar_db;

GRANT ALL PRIVILEGES ON weathercar.* to 'project1-admin'@'localhost' WITH GRANT OPTION;
GRANT SELECT, INSERT, UPDATE, DELETE ON project1.* TO 'project1-web'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON project1.* TO 'project1-sensor'@'localhost';
FLUSH PRIVILEGES;

Step 5: Code

In this step we'll be cloning the needed code onto your raspberry pi. This we'll do by doing this:

First of all make sure you're in your home directory by entering "cd"

cd

now we'll clone the repository using

git clone https://github.com/WardDejonckheere/weathercar.git

Now we can import the database settings using:

sudo mariadb weathercar_db < /weathercar/sql/weathercar_db_historiek.sql
sudo mariadb weathercar_db < /weathercar/sql/weathercar_db_sensoren.sql

Now that we have finished the database we can go ahead and setup our service

sudo cp weathercar/conf/project1-*.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl start project1-*
sudo systemctl enable project1-*

Step 6: Connect!

We're almost there, just one more step. And that's getting the ip address the wifi gave us.

We'll do this by putting

ip addr

a bunch of crap will show up, but you should be able to find "wlan0" and then a few lines further "inet 192.168.x.x"

put that ip address inside your browser and off you go. You're connected to the website.

Share

    Recommendations

    • Creative Misuse Contest

      Creative Misuse Contest
    • Tiny Home Contest

      Tiny Home Contest
    • Water Contest

      Water Contest

    Discussions