Introduction: Controlling a Raspberry Pi Via Windows Hotspot
This Instructable is about controlling a Raspberry Pi microcomputer through a hosted network on a windows computer.
How it works:
The windows computer essentially sets up a Wifi hotspot, and allows the Raspberry Pi to connect to it. You can then use a vnc or ssh to control your Pi. With my Wifi card, I can connect to my router and setup a hosted network(windows hotspot tool) simultaneously. I do not know if this setup works with all Wifi cards, or if mine is special. From tutorials on hosted network it appeared as if I could only have a router connection or a hotspot, not both, but my computer runs just fine with both. A work around if your card cannot do this would be to use a USB Wifi dongle for one of the connections.
Why I made this:
I needed a way to control my Pi while moving around, and possibly being out of range of routers. Most current solutions for controlling a Pi remotely require connecting both to a router. This works, unless you want to leave the range of your router. With the setup described in this Instructable, you can not only control your Pi while outside of the range of any routers, but your Pi can also access an internet connection through your computer.
Note: I have tested this process with Windows 10 and 8, but it should work on Windows 7 and other OS's, if a similar hotspot tool is used.
Step 1: Materials Needed
-Raspberry Pi. Any model should be fine, I tested this with a Pi 2. The OS I used was Raspbian Jesse (Pixel) 9-23-16. Other versions should work as well, but vnc server comes pre-setup in this version, making my vnc connection easier.
-Windows 8 or 10 computer with Wifi card or dongle
-USB Wifi Dongle, or internal Wifi chip on the Pi
-Power supply or battery to run the Pi
-Monitor capable of displaying from the Pi (only needed for setup)
-Keyboard and mouse for setup of Pi (only needed for setup)
Step 2: Setup Hosted Network
This step will set up your wireless hotspot from your computer.
Open up a command prompt, and enter the following commands:
netsh wlan set hostednetwork mode=allow ssid=NETWORKNAME key=PASSWORD
netsh wlan start hostednetwork
Hit enter after each line, and replace NETWORKNAME and PASSWORD with your desired network name and password. Your password must be at least 8 characters. In Windows 8 you may need to run your command prompt as administrator.
If you need to stop the network, just type:
netsh wlan stop hostednetwork
Optional: If you use the hosted network frequently, create a file in notepad or similar software containing the lines entered above. Name it FILENAME.bat, where FILENAME can be any allowed name for a file. Just open this file, and it will automatically create the hosted network. You can also add "cmd /K" as an extra line at the end of the file to keep the command window open after running the commands in the file.
Step 3: Allowing Your Connection to Access the Internet
This step allows your Pi to access your computer's internet connection. Without this step, you can still control your Pi, but your Pi will not be able to connect to the internet.
First, open "Network and Sharing Center."
Click on your internet connection(not your hosted network connection). Left click on "Properties" in the window that pops up. Now, left click on the sharing tab. Check the box that says "Allow other network users to connect through this computer's internet connection." Finally, select your hosted network. On my system, this came up as "Local Area Connection*14."
Click OK to get out of this window, and close out of "Network and Sharing Center."
Step 4: Connecting Pi to Hosted Network
Now, plug in your Raspberry Pi to a keyboard, a mouse, a usb Wifi dongle, and a monitor. Then, plug your Pi into its power supply, and wait for it to boot up.
Once it has booted up, left click on the network manager on the top right of the taskbar. Left click on the network name you just created on your Windows computer. On my screen it is labelled "KevinConnect." Enter the password you selected, and click OK to connect to the network.
After you have connected to your computer's hotspot, click on the VNC Server icon on the top right of the taskbar. A window with information about the Pi's server should pop up on the screen. Record the IP address under the "Connectivity" section, you will need this information later.
Note: The version of Raspbian I use has a vnc server pre-installed. If your Pi does not come with a vnc server, you will have to install one. The Real VNC Server that comes with the Pi functions well, and is easy to set up and use.
Step 5: Connecting to Your Pi Using Vnc Viewer
For this step, you will need a vnc viewer. Additionally, you could control your Pi through other means, such as PuTTY.
For my use, I needed to control the original desktop, not a new session, and I wanted to visually see the desktop. For these reasons, I used a vnc viewer. You can download the same one I have at this link:
Once it is downloaded, open up the viewer and type in the IP address you recorded in the last step into the text box. Left click connect. A new window should pop up with a login screen. Enter your credentials, the default username and password for Raspberry Pi are pi and raspberry, respectively. Left click OK, and your Pi desktop should show up in a window on your vnc viewer.
If so, congratulations! You can now unplug your monitor, keyboard, and mouse. You will be able to control your Pi on the go, with or without internet coverage, and with no cables coming out of your Pi. Also, if your hotspot connection is the default connection on your Pi, it will auto connect to your windows computer when it is booted, allowing you to re-connect with the vnc viewer.
If the login screen did not come up, you may have more work to do. Ensure your Pi is properly connected to your hosted network. Next, try setting the IP of the Pi to something different, and see if that new IP will fix your problem. Finally, the connection settings on your Pi may be to blame. Try looking online to find Wifi solutions for your specific version of Raspbian.
If you have any trouble connecting to your computer, let me know, and I will try my best to assist you.
Thanks for you interest in this project, have fun controlling your Pi!
We have a be nice policy.
Please be positive and constructive.