stephanecodo
Posts: 12
Joined: Tue Jan 22, 2013 10:14 am

[Tutorial] In-Car Raspberry with Wifi Access point - DWA-121

Sat Jan 26, 2013 7:59 pm

My car is a Renault Espace with integrated screens at the back of the headrests (infrared transmitter for the sound to headsets) with a DVD Player and an extra RCA audio/video input.

Since I was bored with kids battles choosing cartoons from old DVDs I decided to use a Raspberry Pi together with Raspbmc as a media center. Everything had to be powered from the cigar lighter receptacle...

I took an old 2.5" hard-drive as the repository for cartoons. Because of power constraints, I bought a 2.1A dual USB car adapter: it provides enough power for the Raspberry Pi and for the hard-drive; one USB cable goes to the power input of the Raspberry and another "Y" USB cable is connected to the USB car adapter, to the Rabspberry Pi USB port and to the hard-drive. Y USB Cable like this one: http://www.lacie.com/lu/products/product.htm?id=10572.

I wanted to use my iPad as a remote control for XBMC so the idea was to have a wifi emitter in the Raspberry Pi, to connect the iPad to this Wifi network and to use the official remote control app.

So I bought a cheap USB Wifi dongle: D-Link DWA-121 (less than 13€ on Amazon.fr). This dongle has a Realtek RTL8188CUS chipset compatible with the rtl8192cu linux driver already installed on the latest Raspbmc. However, configuring this dongle as a Wifi access point can turn to be a nightmare! So this post is to help people doing the same thing!

Here is how to proceed, using your home network first before going into the car.

1. Install Raspbmc (http://www.raspbmc.com/download/) on the SD Card.

2. Start your Raspberry Pi and let it boot with a connection to your Ethernet network first.

3. Use the official XBMC iPad or iPhone app to automatically detect your Raspberry (your iPhone has to be connected to your home Wifi wich uses the same network as the Raspberry Pi).

4. Check the IP address of the Raspberry in the 'Systems' / 'Info' menu.

5. From your PC or your MAC, connect to the Raspberry Pi using an SSH terminal (from MacOS, you can go to a terminal and type

Code: Select all

ssh -l pi IP_ADDRESS
where IP_ADDRESS is the one you just checked (for example 192.168.1.11). The password is raspberry. Type

Code: Select all

sudo -s
to make sure you have sufficient rights on the device.

6. You will need to follow this tutorial: http://elinux.org/RPI-Wireless-Hotspot but at the first step you have to change the following code:

Code: Select all

sudo apt-get install hostapd udhcpd
by this new code:

Code: Select all

sudo apt-get install hostapd udhcpd iptables
7. Later in the tutorial you also need to modify the driver from the file /etc/hostapd/hostapd.conf which is

Code: Select all

driver=nl80211
by this driver instead:

Code: Select all

driver=rtl871xdrv
8. The hostapd file also need to be changed before running hostapd. Download the correct version by typing

Code: Select all

wget http://dl.dropbox.com/u/1663660/hostapd/hostapd
then move it to the right place by typing

Code: Select all

mv hostapd /usr/sbin
and modify the rights by typing

Code: Select all

chmod 755 /usr/sbin/hostapd
9. You should have finished the tutorial by now but there is an ultimate modification to be done. I realized that the Wifi interface was not starting, causing the wifi Access Point not to be working... So you have to modify the /etc/rc.local file by typing

Code: Select all

nano /etc/rc.local
and adding the following 2 lines before the exit 0 line:

Code: Select all

ifup wlan0
service udhcpd restart
10. Restart you Raspberry Pi, check the Wifi from your iPad: you should be able to connect to your newly create access point, to detect your Raspberry Pi from the official xbmc app and to enjoy an autonomous Wifi Raspberry Pi!


Pictures from the installation in my car:
Image

Image

Image

Image

Official XBMC iPad app together with Raspbmc in my Renault Espace:
Image

ben1227
Posts: 6
Joined: Sun Feb 10, 2013 11:04 pm

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Sun Feb 10, 2013 11:51 pm

Hello,

do you speak french ?

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Mon Feb 11, 2013 8:11 am

Very nice.
If you have a Rev 2 Pi, you probably wouldn't even need the power plug in the Pi side, the Pi could be powered from the USB Y cable.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

stephanecodo
Posts: 12
Joined: Tue Jan 22, 2013 10:14 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Mon Feb 18, 2013 10:08 am

ben1227 wrote:Hello,

do you speak french ?
Tout à fait !

stephanecodo
Posts: 12
Joined: Tue Jan 22, 2013 10:14 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Mon Feb 18, 2013 10:11 am

SirLagz wrote:Very nice.
If you have a Rev 2 Pi, you probably wouldn't even need the power plug in the Pi side, the Pi could be powered from the USB Y cable.
It seems (not completely sure) that there is still not enough power going out of the USB port to power the Pi, the hard-drive and the WiFi dongle...

rdidier
Posts: 8
Joined: Thu Feb 21, 2013 7:59 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Feb 21, 2013 9:00 am

Hello,

I've got a problem ...
Everything run up correctly but my iPad can't connect to the hotspot.
SSID is visible, but iPad get wrong range of IP and then turn and turn without connecting.

Any idea ?

Thanks.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Feb 21, 2013 12:37 pm

Does the wifi nic have an IP address when hostapd is running ?
If not then disable ifplugd for wlan0
Instructions can be found @ http://sirlagz.net/2013/02/10/how-to-us ... r-part-3b/
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

stephanecodo
Posts: 12
Joined: Tue Jan 22, 2013 10:14 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Feb 21, 2013 1:34 pm

The fact that you see the SSID means that it is probably a DHCP issue: your raspberry is not providing an IP address to your iPad.

First thing to check: if you type 'ifconfig', do you have an IP address for WLAN0 interface?
If yes, it is really a DHCP issue. If you don't have an IP address let us know.

I also had a DHCP issue once and I changed the DHCP server (after a reinstall from scratch). You can do so by typing:

Code: Select all

apt-get install isc-dhcp-server
to replace the udhcpd server. So you have to stop udhcpd by typing

Code: Select all

service udhcpd stop
Once the udhcpd is stopped and isc-dhcp-server installed, there is a bit of config to be done. You need to change the eth0 line to have wlan0 in the config file:

Code: Select all

sudo nano /etc/default/isc-dhcp-server
And then edit the dhcpd.conf file:

Code: Select all

sudo nano /etc/dhcp/dhcpd.conf
In this file you need to have this type of config (make sure also than eth0 is replaced by wlan0 in this file):

Code: Select all

option subnet-mask 255.255.255.0;
option broadcast-address 192.168.42.255;
option domain-name "home";
option routers 192.168.42.1; #default gateway
 
subnet 192.168.42.0 netmask 255.255.255.0 {
    option routers 192.168.42.1;
    range 192.168.42.10 192.168.42.20; #IP range to offer
    option domain-name-servers 8.8.8.8, 8.8.4.4;
}
Finally you need to start the dhcp-server:

Code: Select all

sudo isc-dhcp-server start
In case of issues, there is a syslog file which gives more details on what fails:

Code: Select all

cat /var/log/syslog
If it works, replace dhcpd in the rc.local file by isc-dhcp-server so that it starts all the time on boot.
Let us know how it goes!

rdidier
Posts: 8
Joined: Thu Feb 21, 2013 7:59 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Feb 21, 2013 5:12 pm

Hum ....
Think I'vi got a big problem :roll: :

- in file /etc/default/isc-dhcp-server : eth0 was not predefined, so I only put wlan0

- in file /etc/dhcp/dhcpd.conf : almost everything is commented and there is no eth0 or wlan0 ...

rdidier
Posts: 8
Joined: Thu Feb 21, 2013 7:59 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Feb 21, 2013 5:53 pm

And yes, I have an IP address for WLAN0 interface.

stephanecodo
Posts: 12
Joined: Tue Jan 22, 2013 10:14 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Feb 21, 2013 6:42 pm

Ok, here is my /etc/dhcp/dhcpd.conf file (and I also updated /etc/dhcpd.conf to be the same...

Code: Select all

ddns-update-style none;
option domain-name "home";
option domain-name-servers 8.8.8.8, 8.8.4.4;

default-lease-time 600;
max-lease-time 7200;
subnet 192.168.42.0 netmask 255.255.255.0 {
  range 192.168.42.2 192.168.42.10;
  option domain-name-servers 8.8.8.8, 8.8.4.4;
  option domain-name "home";
  option routers 192.168.42.1;
}
When you start isc-dhcp-server, does it say 'Fail' ?
And can you tell what you see regarding errors for isc-dhcp-server in the /var/log/syslog file? do a

Code: Select all

cat /var/log/syslog
and look for isc-dhcp-server errors.

rdidier
Posts: 8
Joined: Thu Feb 21, 2013 7:59 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Feb 21, 2013 8:41 pm

You're the Boss !
It works !!!!!!!

PS : Did you try to allow upnp out in raspbmc and watch a movie of your portable hdd on your ipad ?

stephanecodo
Posts: 12
Joined: Tue Jan 22, 2013 10:14 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Feb 21, 2013 8:44 pm

Good to hear: thanks and enjoy!
I didn't try upnp, I just tried in the other direction with AirPlay which works very well! Sounds like a good idea as well!

mgrif
Posts: 1
Joined: Tue Apr 02, 2013 4:59 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Tue Apr 02, 2013 5:06 am

I also can see my Pi's ssid but cannot connect on my iPhone (spinning wheel).

I would like to try and follow your directions to solve this but I cannot ssh into the machine from my Mac after following your directions (cannot connect to host 192.168.42.1 on port 22: Operation timed out).

How can I edit the files on my Pi from my Mac now?

Thanks!

carled
Posts: 37
Joined: Sat Feb 09, 2013 12:23 pm

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Tue Apr 02, 2013 9:37 am

mgrif wrote:I also can see my Pi's ssid but cannot connect on my iPhone (spinning wheel).

I would like to try and follow your directions to solve this but I cannot ssh into the machine from my Mac after following your directions (cannot connect to host 192.168.42.1 on port 22: Operation timed out).

How can I edit the files on my Pi from my Mac now?

Thanks!
Sounds like your Pi does not have an IP address now so it won't let you ssh in and it won't let you connect either. I've had the same thing happen myself. In my case it was an error in the /etc/interfaces file and I need to strip it back completely to assign a static IP.

If you can watch the output of the pi whilst it boots (via hdmi/rca) then it should give you some clues as to what may have gone wrong.

stephanecodo
Posts: 12
Joined: Tue Jan 22, 2013 10:14 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Tue Apr 02, 2013 10:27 am

You can edit the files if you plug the Ethernet cable so that you have at least one valid IP address. Or you manually configure your Mac with à static IP address on the same wifi but it is more complex.

rdidier
Posts: 8
Joined: Thu Feb 21, 2013 7:59 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Wed Apr 03, 2013 12:51 pm

Hello,

Everything works fine but I have another question :

How can I use this Hotspot connection to access internet over wifi ?
It works when ethernet is plug but I would like to use a wifi connection for internet (like this I could control Raspbmc with IPad in car while Raspbmc access internet over wifi to access YouTube, météo ...)

Do you think I need a second wifi adapter ?

Thanks.

stephanecodo
Posts: 12
Joined: Tue Jan 22, 2013 10:14 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Sun Apr 07, 2013 7:18 am

Yes, I think you would need another Wifi adapter to be able to configure one as the hotspot and the other as a receiver. I don't think one adapter can do both at the same time.

aht961
Posts: 9
Joined: Fri Mar 29, 2013 4:55 pm

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Sun Apr 07, 2013 2:25 pm

rdidier wrote:Hello,

Everything works fine but I have another question :

How can I use this Hotspot connection to access internet over wifi ?
It works when ethernet is plug but I would like to use a wifi connection for internet (like this I could control Raspbmc with IPad in car while Raspbmc access internet over wifi to access YouTube, météo ...)

Do you think I need a second wifi adapter ?

Thanks.
I had the same problem. The only practical way seems to be to set up a hotspot with iPhone/android and then connect the raspi to that via wifi as a client. Then you can use the internet access of the iPhone/ipad via raspi as well as you can connect to xbmc using your phone / ipads / androids. If you give a static IP to raspi in line with the iPhone's own DHCP's IP range, then there should not be any problem.

Hope this helps.

Oldchatterman
Posts: 6
Joined: Wed Apr 03, 2013 8:33 pm

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Mon Apr 15, 2013 2:08 pm

@stephanecodo

I also want an in-car raspberry with a wifi AP -RTL8188. Just a connection between my phone or Ipad and the raspberry to control XBMC.

I tried your tutorial but was not able to get the AP running. I got it running with a plain Raspbian image, but the combination with Raspbmc makes it too difficult for me. The scripts in Raspbmc seem to interfere with what I want, but I am not sure.
Result with ifconfig: wlan0 is sometimes up and when up wlan0 has sometimes an IP address
Result with iwconfig: wlan0 is sometimes in auto mode, sometimes in managed mode and almost never in master mode
wpa_supplicant service is sometimes running

My question: did you try to setup an AP with the final Raspbmc version? What version did you use?

rdidier
Posts: 8
Joined: Thu Feb 21, 2013 7:59 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Wed Apr 24, 2013 8:04 pm

rdidier wrote:Hello,

Everything works fine but I have another question :

How can I use this Hotspot connection to access internet over wifi ?
It works when ethernet is plug but I would like to use a wifi connection for internet (like this I could control Raspbmc with IPad in car while Raspbmc access internet over wifi to access YouTube, météo ...)

Do you think I need a second wifi adapter ?

Thanks.

Hello,

Finaly it works with the 2 wifi adaptors.
One for the hotspot and the second one connects to my iphone for sharing connection.

stephanecodo
Posts: 12
Joined: Tue Jan 22, 2013 10:14 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Apr 25, 2013 11:59 am

@Oldchatterman : I have used the version from early February. I need to check which version exactly but I am pretty sure it was the one marked as version 12 'final'. Maybe you have a power issue: are you sure your USB feed has enough power for your adapter?

@rdidier : this is great to know!

rdidier
Posts: 8
Joined: Thu Feb 21, 2013 7:59 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Apr 25, 2013 12:56 pm

@Oldchatterman : And for information I had to reformat many times before it has worked so I use the latest version of Raspbmc.

Oldchatterman
Posts: 6
Joined: Wed Apr 03, 2013 8:33 pm

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Apr 25, 2013 7:23 pm

Incredible. I repeated the exact same steps over and over again with 2 different wifi dongles (1 Realtek RTL8188CUS chipset and 1 Ralink RT5370 chipset). I use a 1A adapter to power the Pi.

When using the wifi dongles to connect to my AP I have no problems at all and I get a stable connection.

How did you install Raspbmc (image or windows installer)? I used the windows installer and used the "manually configured networking" option. I created a static IP.

When do you connect the wifi dongle? I connected the dongle after installation of raspbmc.

I want to understand the differences.

I also bought a Hame MPR-A1 portable router to get rid of debugging my system ...

rdidier
Posts: 8
Joined: Thu Feb 21, 2013 7:59 am

Re: [Tutorial] In-Car Raspberry with Wifi Access point - DWA

Thu Apr 25, 2013 8:38 pm

No, that's my router that assign IP.
Windows installer, absolutely no extra parameters.
I plugged the wifi dongle after raspbmc installation.

If this help ...

Return to “General discussion”