Friday, December 8, 2017

Create Ad-hoc Wifi Hotspot On Your Donkeycar (RPi3)

Here is some quick instructions on how to create an ad-hoc Wifi connection on your Donkeycar (RPi3).  This connection is mainly used for direct connections to the Donkeycar at the track.  You will then not need a router or other Wifi access point.  I have found the range of the Wifi connection to be great.

Intro

So the typical way to communicate with your Donkeycar is through SSH.  To connect through SSH, both your laptop and the Donkeycar must be on the same network.  These instructions will make your Donkeycar (RPi3) a Wifi Hotspot.  You will then connect to the Donkeycar through Wifi just like you connect to any other Wifi connection.

Your Donkeycar will have a static IP.  So you will always know the IP address.  So when you SSH into your Donkeycar, you can always give the same IP address.  You will need to make your laptop match your Donkeycar IP address.


Instructions

  • On your Raspberry PI modify the file:
sudo nano /etc/network/interfaces

  • Modify the wlan0 entry to create an ad-hoc network.
#allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  address 192.168.1.123
  netmask 255.255.255.0
  wireless-channel 1
  wireless-essid Donkeycar_Rico
  wireless-mode ad-hoc
The address is any address you would like for your Donkeycar. The essid is any name you want.  The essid entry is the the name you find in available Wifi networks.

  • Close the file.
Ctrl-X, then Y to save.

  • Reboot the RPi3.
sudo reboot

 Connect to RPi3 through Wifi

When the RPi3 reboots, you will see in the list of available Wifi connections your essid name listed.  



  • Connect to the Donkeycar Wifi network
  • You will now need to set your IP address on your laptop to a static IP address.  The RPi3 does not have DHCP to give you an IP address.
The IP Address must be similar to the RPi3 address.  But it cannot be the same.  So something like 192.168.1.222.

Depending on your OS, this will vary how you set your IP address. 


Here is a site for OSX
http://www.macinstruct.com/node/550

Here is a site to show you how on Windows.
https://www.howtogeek.com/howto/19249/how-to-assign-a-static-ip-address-in-xp-vista-or-windows-7/
I notice that Windows 10 is having issues connecting to an Ad-hoc network, but OSX works fine.

And here is a site for Ubuntu
https://www.swiftstack.com/docs/install/configure_networking.html


Notes:

This wifi connection will make you lose your internet connection.  It will only be connected to the RPi3 now.


You can then SSH or RSYNC to the RPi3.  If you need to transfer files from the internet to your RPi3, you will first need to reconnect to your Wifi connection with the internet.  Get the files you need.  Then connect to the Wifi connection for the Donkeycar.  Then RSYNC the files between the laptop and RPi3.  This connection is mainly used for remote connections at the track.

0 comments:

Post a Comment