Introduction: Using a Raspberry Pi to Control a WF32 With LabVIEW (Fan Control)

Picture of Using a Raspberry Pi to Control a WF32 With LabVIEW (Fan Control)

This Instructable takes a project from my last Instructable ( Thermistor - Fan control using LabVIEW) and adds in the use of a Raspberry pi 3 for wireless control of the WF32. This means that you can now set up the fans and servo with your WF32 in your entertainment center and then control them over WiFi. In this Instructable I go over how to set up the Raspberry Pi but if you run into any trouble please refer to the Getting Started With the Raspberry Pi 2 (LabVIEW) Instructable.

Step 1: Materials

Picture of Materials

1) Temperature sensor [TMP36] (250 mV output at 25°C)

2) Two Slide switches

3) three 240Ω resistors

4) 100 uF electrolytic capacitor

5) Tactile button switch

6) Breadboard(I use a MyProto Protoboard and a 270 tie breadboard)

7) Two PWM controlled fans(I use two different sizes in my demo)

8) Small servo motor

9) ChipKIT WF32

10) Raspberry Pi 2 (I use the Raspberry Pi 3, but the process is the same)

11) Wifi dongle (Wi-Pi USB WiFi Module is a good choice)

12) microSD with adaptor(8GB or larger)

13) LabVIEW

Everything but the fans, LabVIEW, Raspberry Pi, Wifi dongle, and WF32 is included in the LabVIEW Interaction Parts Kit

Step 2: Connecting WF32 to WiFi

Picture of Connecting WF32 to WiFi
  1. Launch the LINX Firmware Wizard
  2. Choose the chipKIT WF32
  3. Go to Device Manager
  4. Click on "Ports(COM & LPT)" to find the WF32's COM port
  5. Select that COM port
  6. Configure the network settings:
    • SSID is the name of your network
    • Assign the chipKIT WF32 an available IP Address. You will need to specify this IP address again later as an input to the LINXInit VI.
    • Select the Port to use, unless you have reason to use another you should select 44300
    • You will need to specify this IP address again later as an input to the LINX Init VI.
    • Specify the Wifi security type and passphrase.
      • Note: It is recommended that you disable network security to start and then re-enable it after you confirm the LINX connection is working.
  7. Click Launch Example

A video going over these instructions can be found here

Step 3: Raspberry Pi Setup

Picture of Raspberry Pi Setup
  1. Download a Raspbian image here
    • LINX was developed using Raspbian Jessie.
  2. Click the Download ZIP button under the RASPBIAN JESSIE image
  3. Unzip the Raspbian image.
  4. Google win32diskimager and click on the top link or click here
  5. Download Win32 Disk Imager.
  6. Open it from your downloads folder
  7. complete the installation but unclick the View and launch boxes after completing the setup wizard
  8. Open File explorer and go to This PC
  9. Select Program Files(x86)
  10. Select ImageWriter
  11. Then Select Win32DiskImager
  12. Click on the Folder next to the image file dialog box and then select your raspbian jessie disk image
  13. Insert the SD card into your computer and set the device dropdown so your SD card is selected and click Write
  14. Connect ethernet to the Raspberry Pi and power on your Raspberry Pi. Launch LabVIEW and open the Target Configuration Wizard from Tools»MakerHub» LINX»Target Configuration.

  15. Enter the Raspberry Pi's Hostname or IP and a username and password with root privileges and click connect. (Eventually you will want your Raspberry Pi connected to WiFi, click here if you need help)
    • Default Hostname is 'raspberrypi'.
    • Default Username is 'pi' Default Password is 'raspberry'
  16. Click the Install Software tab and click Install and then review any warnings and complete the installation.

A video going over these instructions can be found here

Step 4: Circuit Setup Part 1 - WF32

Picture of Circuit Setup Part 1 - WF32

Connect power and ground to both sides of the breadboard. Next, insert male headers into the 3 or 4 female sockets on the servo motor and the fans(see figure above for fan pin instructions). For the servo connect the orange wire to power, and the brown wire to ground. Place a 100uF electrolytic capacitor across power and ground to smooth out any irregularities in voltage. Connect the servo's data wire(yellow wire) to pin three on your WF32(important to use a pin that supports PWM). Repeat this procedure for each of the two fans connecting the data wire of one to pin 2 and the other to pin 4. Place the TMP36 on the breadboard (the order of the pins is important) connect the left pin of the flat facing side to power, and the right pin to ground. Connect the center pin to Analog pin 1(A1) of the WF32.

Step 5: Circuit Setup Part 2 - Raspberry Pi

Picture of Circuit Setup Part 2 - Raspberry Pi

Connect power and ground to both sides of the breadboard. Next, Place the pushbutton on the breadboard and connect one end to the 5V. On the other side of the switch, connect to ground through a 240Ω resistor. Connect this junction to digital pin 11 on the WF32. Next step is to attach a slide switch, First place the three pin switch on the breadboard. Next run a wire from one of the outer pins to power and then place a 240Ω resistor between the opposite sides pin and ground. Finally run a wire from the center pin to digital pin seven on the WF32. Repeat this step with the next slide switch except connect the center pin to 13.

Step 6: Raspberry Pi - Deploying a Startup Executable

Picture of Raspberry Pi - Deploying a Startup Executable
  1. Open my LabVIEW project "Raspberrypi-WF32_Fan_Control" attached below and then select File-> New
  2. Select "Empty Project" in the "Project" folder
  3. A pop-up will ask you if you want to add the open VI to the new project, select Add
  4. Right click "Project: Untitled Project 1" and select "New"» "Target and Devices"
  5. Select "Raspberry Pi 2 B" in the LINX folder and then click OK
  6. Right click "Raspberry Pi 2 B" and select Properties
  7. Under the "General" category enter the IP address for your Raspberry Pi(should be the one you set in a previous step)
  8. Next step is to open up a pinout diagram for the Raspberry Pi 2 for later use. From the front panel select Help»MakerHub»LINX»"Pinout - Raspberry Pi B"
  9. Next, enter the correct values for the TCP settings, RPI settings, and the WF32 settings.
  10. To make sure these values don't change, click Edit»"Make Current Values Default"
  11. Pull the "Raspberrypi-WF32_Fan_Control" into the Raspberry Pi 2 section and right click Build Specifications then choose New»Real-Time Application.
  12. Rename the build specification.
  13. Click the Source Files category on the left side of the dialog.
  14. Under Project, Files select the top level VI ("Raspberrypi-WF32_Fan_Control") and click the right arrow to add it to Startup VIs. Click OK.
  15. Right click the new build specification and choose Build.
  16. Click Done.
  17. Right click the new build specification and choose Run as Startup.
  18. Click Yes to reboot the target.

The VI will now run whenever the target is powered on. A video going over these instructions can be found here

Step 7: Labview Code

Picture of Labview Code

From the thermistors sensors datasheet, I found that every 10 millivolts of change from the sensor is equivalent to 1 degree Celsius. If you take the voltage, subtract 0.5, and multiply it by 100, you get the accurate temperature in degrees Celsius.

You can download my LabVIEW code by clicking on the "Raspberrypi-WF32_Fan_Control.vi" file below. If you followed my instruction above, then the default channel values are already set but if you used different channels you will have to change them. Also, if you are using a different servo, you will want to play around with the pulse width values for both positions. Otherwise, just follow the instructions given on the front panel and feel free to comment with any questions you may have.

Comments

About This Instructable

2,170views

13favorites

License:

Bio: I graduated from Washington State University with a degree in Bioengineering.
More by Austin Stanton:LIRC - LabVIEW - Remote ReplacementLIRC - LabVIEW - Raspberry PiLIRC - LabVIEW - Sending a Remote Command From LabVIEW
Add instructable to: