WiFi connection to the internet

From NP Tracker projects
Jump to navigation Jump to search

Your NPS-ANPR will connect to the NPS servers online to test and notify you of any lookouts, to do this the Raspberry Pi should first be connected to your internet.

Connecting to your Raspberry Pi (first time)

A fresh installation -first time boot- of the NPS-ANPR will search for the first available open WiFi Network and connect to it.
We found it easier to create an open WiFi hotspot on your phone and let the Raspberry Pi connect to it.

Setup Android WiFi hotspot

  • Goto your phones Settings menu
  • Select Portable hotspot
  • Setup your hotspot by going to Set up portable hotspot
  • Give your Hotspot a name in the SSID field eg. myHotspot
  • Set the Security to None click on save
  • Switch on your Portable hotspot.

NOTE: This should only be used for initial setup of your NPS-ANPR and NOT for final installation.

Get NPS-ANPR network IP address

If you used the open WiFi Hotspot method as above check on your phone for the IP address allocated to your Raspberry Pi - see Connected devices in your phones Portable Hotspot screen.
Alternatively, you will need to connect the NPS-ANPR to a screen to get the IP address during boot.
If you find the Raspberry Pi IP Address you can skip to section Connect with Web Browser

Terminal setup

Only needed if not getting the IP Address or not able to connect to the open WiFi
First step is connecting your Raspberry Pi in order to get to a terminal.
You can do this by connecting your Raspberry Pi to a monitor and keyboard.

Login to the Raspberry Pi with the default NPS-ANPR user credentials:

   Username: pi
   Password: nptracker

Getting your network information

For the purpose of this guide we will be connecting to a WiFi network with the following information:

   SSID (Network Name): Test Wifi Network
   PSK (Password): SecrectPassWord

Every time you see this network name and password in the guide you need to change them to the network name and password of your local network.

If you need to find the network name of your local network you can run the following command in the Raspberry terminal:

sudo iwlist wlan0 scan

This will list all the networks in your vicinity along with some useful information for each network. To find your network name look for something that look like: ESSID:”Test Wifi Network”.

Configuring your WiFi network

To tell the Raspberry Pi to automatically connect to your WiFi network you need to edit a file called: wpa_supplicant.conf.

To open the file in mcedit type the following command:

sudo mcedit /etc/wpa_supplicant/wpa_supplicant.conf

Scroll to the end of the file and add the following to the file to configure your network:

  ssid="Test Wifi Network"

Remember to replace this with your own network name and password.
Save and close the file by pressing [F2] followed by [F10]. At this point the Raspberry Pi should automatically connect to your network.
You can check your network connection by running the following command:

ifconfig wlan0

If the output looks something like this (with an inet addr) you are connected:

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet  netmask  broadcast
       inet6 fe80::30ee:6d8b:385b:520b  prefixlen 64  scopeid 0x20<link>
       ether dc:a6:32:b4:66:32  txqueuelen 1000  (Ethernet)
       RX packets 191  bytes 25003 (24.4 KiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 85  bytes 13815 (13.4 KiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Write down the IP Address and go to section Connect with Web Browser
Sometimes the Raspberry Pi will not connect automatically and require a reboot to connect.
If it doesn’t connect after waiting 2-3 minutes try to reboot the pi using the following command:

sudo reboot

Connect with Web Browser

Now that you have your NPS-ANPR IP Address open a web browser on a device on the same network -like your phone- and enter the IP address.
You should see the main page of your NPS-ANPR in your browser.

NPS ANPR main page