Introduction: Using a Raspberry Pi to Control a BeagleBone Black Over Wi-Fi
In this Instructable I will show you how to use a Raspberry Pi to control a BeagleBone Black over Wi-Fi using LabVIEW and LINX 3.0. In this simple project, LED's controlled by the BeagleBone Black are turned on when a push button attached the Raspberry Pi is pressed. My code is simple enough that it could easily be modified, this means you could attach many different types of sensors or controls to the Raspberry Pi 2 and have them control any number of things attached to the BeagleBone Black over Wi-Fi. Before you can start this project you will need to download LINX 3.0 which gives you the ability to deploy LabVIEW code to run on BeagleBone Black and Raspberry PI 2 and 3. For help with the setup visit this Labviewmakerhub.com.
Step 1: Materials
- Raspberry Pi 2
- BeagleBone Black
- Wi-Pi WiFi dongle
- 4 LED's
- 4 push buttons(momentary switches)
- 2 Breadboards
- External power source (I use Anker Astro External Power Banks)
(The push buttons, breadboards and the LED's are included in the LabVIEW Interaction Parts Kit)
Step 2: Raspberry Pi Circuit Setup
First, connect the 3.3V pin(pin 1 or 17) to the bus on one side of your breadboard. Next, connect the bus on the opposite side to one of the ground pins(pin 9, 14, 20, 25, 30, 34, 39).
Add 4 momentary switches across the center of the breadboard. Connecting one side of each to the 3.3 Volt bus. Add a 10 Kohm pull-down resistor in series with ground on the output of both switches, Next connect wires from the DIO Pins(I chose 12, 16,18 and 22) to the other leg of the same side of the switch that is connected to ground.
Step 3: BeagleBone Black Circuit Setup
First, connect one of the busses to one of the ground pins(pin 1, 2, 47, 48, 89, 90, 91, 92).
Add 4 LED's breadboard, connect the shorter leg(the cathode) of each LED to the ground bus with a wire. Next wire 4 of your DIO pins to your breadboard(I chose 8, 10, 12, 16), then run a 220 Kohm resistor from each to the longer leg(the anode).
Step 4: LabVIEW Code
Download the LabVIEW project attached below. Before you open the individual VI's you will need to change the IP address shown to the specific IP addresses of your BeagleBone Black and the Raspberry Pi. To do this right click on the Beaglebone Black and select "properties".
Change the IP address in the input that says "IP address/DNS name". Repeat this process with the Raspberry Pi. Once the IP address is correct right click each and select connect, this will open a connection to each device.
Step 5: Raspberry Pi LabVIEW Code
Start by opening the RPI control VI under the Raspberry Pi category. Before you can deploy you will need to change some things on the front panel. Start by changing the DI channels to the DIO pins you attached to the switches. Next, input the IP address of your BeagleBone Black. Finally, you will choose the Local port and the port you will be sending to, I would keep these the same unless you have reason to change them.
Above is the block diagram for this VI, the first block is a LINX open. It is set to Local I/O because we are using a Raspberry Pi the code that you write in LabVIEW actually gets deployed to the board. After LINX is opened open a UDP socket and then enter the while loop. 4 digital reads inside the loop get data from each switch then it is it is all bundled and UDP write sends it to the BeagleBone Black over Wi-Fi. Once the stop button is pressed we leave the loop and close the LINX reference as well as the UPD socket.
Step 6: BeagleBone Black LabVIEW Code
Next, open the BBB_LED VI under the BeagleBone Black category. Again, before you can deploy you will need to change some things on the front panel. Start by changing the DO channels to the DIO pins you attached to the LED's. Next, input the IP address of your BeagleBone Black. Finally, you will choose the port, make sure this matches the port you set in the RPI control VI.
Above is the block diagram for this VI, you can see that again we start with a LINX open set to local I/O because we are deploying this code to the BeagleBone Black. Next, we enter the While loop and open up a UDP socket, it then splits into two different while loops. The top while loop uses a UDP read to collect the data sent over from the controller, the bottom loop uses that information to determine whether or not each specific LED should be lit. To end this code, we press the stop button which will exit both the inner loops, then when it's out of the outer while loop we close LINX as well as the UDP socket.
Step 7: The End
Thank you for reading my instructable, if you are interested in making this project yourself but don't have the right supplies you can purchase the LabVIEW computing kit for the BeagleBone Black or the Raspberry Pi 2. This kit includes a copy of LabVIEW 2014 home edition and everything you will need to run LINX 3.0 and start making projects. Please comment with any questions or comments you may have.