Weather Station using Arduino and LabVIEW

Tutorial 4: Weather Station using Arduino and LabVIEW: In our last tutorial we have seen how to control speed and direction of DC motor using LabVIEW and Arduino? We created User Interface in LabVIEW front panel.  In today’s tutorial, we will interface Arduino with LabVIEW and create a simple weather station to display intensity of light and temperature on front panel of LabVIEW. For this purpose, we will connect a LM35 and a light sensor for our weather station, which will measure temperature and intensity of light in real time and using LabIEW interface it will be displayed on panel of our weather station. We will divide our weather station project in following steps.

  • Software Requirements for weather station.
  • Hardware Requirements for weather station.
  • Circuit Wiring of weather station
  • LabVIEW VI for weather station

Software Requirement for weather station:

  • Arduino IDE
  • LabVIEW with Arduino interface installed

If you don’t have any of these, visit tutorial 1.

Hardware Requirement for weather station:

  • Arduino UNO Board
  • LM35

In our weather station, LM35 is a sensor used to measure the temperature of surrounding. The output is actually an analogue voltage which corresponds to surrounding temperature when multiplied by 100.

  • Light dependent resistor (LDR) :

In our weather station, Light dependent resistor is used to detect change in light intensity or as a light sensor. LDR is basically a variable resistor. LDR resistance changes with the change in intensity of light. If intensity of light falling on LDR is high, LDR will have low resistance. When intensity of light decreases, LDR offers high resistance. Hence there is inverse relationship between intensity of light and resistance of LDR. So LDR is used as a light sensor. Now the question comes to mind, how to measure resistance which in return can be used to calculate intensity of light. As you know Arduino UNO R3 board have six analog to digital converter channels. All analog to digital converters can measure voltage only. These channels cannot measure resistance directly. But resistance can be measured indirectly by converting it into voltage form. This is basically called signal conditioning. 10K ohm resistor is used in series with LDR through 5 volt source. This circuit is used to convert resistance into voltage form. Voltage measured across LDR can be measure with the help of analog to digital converter of Arduino. This measured voltage can be converted back into resistance using voltage division formula.

  • Jumper Wires
  • Bread Board

Circuit Wiring of weather station:

In this section, we will discuss wiring diagram of this project and show a complete circuit diagram.

  1. Connect Pin 1 and Pin 3 of LM35 with 5V Pin and GND Pin of Arduino respectively.
  2. Connect Pin 2 of LM35 with Analogue Pin A1 of Arduino.
  3. Connect a 10k resistor between Pin 2 and Pin 3 of LM35. (not shown in diagram).
  4. Connect one pin of LDR with 5V of Arduino.
  5. Connect second pin of LDR with pin A0 of Arduino.
  6. Also connect a 10k resistor between second pin of LDR and ground.

This completes our circuit for weather station measuring temperature and light intensity.

LabVIEW VI for weather station:

  1. Start the LabVIEW.
  2. Creat Blank VI for weather station as in Tutorial 1.
  3. Go to LabVIEW “Block Diagram” Panel
  4. Right Click on white space. Go to “Arduino” and select “init”. This will add Initializations of Arduino board.
  1. Bring Cursor to anywhere in LabVIEW “Block Diagram” panel and place the “Init”.

  1. First input is “VISA resource”. It is the serial port you are using for interfacing of Adruino. You can find it in “device manager” of your computer under “ports (COM & LPT)….” Make sure Arduino board is connected with computer otherwise it won’t be shown. In my case it is COM4.
  2. Bring cursor on first input of “Init” until it shows “VISA resource”. Right click on it. Go to “create” and select “constant”. As it will be a constant value of Port which will be always used for serial communication.

  1. Click on arrow it will show available option. In my case its “COM4”. Select appropriate one after checking from device manger as mentioned above otherwise it won’t work.
  2. Second input is “Baud Rate”. Create it as constant as done for “VISA resource”. Right click on “Baud Rate” then “create” and then “constant”.
  3. Third input is “Board Type”, fourth is “Bytes per packet” and fifth is “Connection type” make them also constant.

  1. Click on white space on LabVIEW “Block Diagram” and follow “Structure → select While loop”.
  2. Place two “analogue read pin” as follows one by one.
  3. Result is as follows.
  1. Join diagram as follows.
  2. Create “Control” for input parameter “Analogue input pin” of both “Analogue Read Pin” blocks as follows.
  3. This step results as.
  4. Right click on white area. Go to “numeric” and find “divide”.
  5. Similarly find “multiply” and place it and join them as follows. Create indicated “constants”.
  6. Similarly create “multiply” and “constant” as indicated.
  1. Go to Front panel and find “thermometer” as shown on block diagram of LabVIEW.
  2. Also find “slide” as we found thermometer. Place both of them on front panel one by one.Weather Station using Arduino and LabVIEW
  3. Join “Slide” and “temperature” as shown on block diagram of LabVIEW.
  4. Create “Close” block as follows on block diagram of LabVIEW.
  1. Join as shown on block diagram of LabVIEW.

This completes our VI.

Now we will upload program to Arduino and Run it from LabVIEW as indicated in previous tutorials.

  1. Now Start Ardunio IDE.
  2. Click “File” then “Open” and Follow as shown. Go through all these folders from “Computer” onward and open LIFA_BASE Arduino file.
  1. Upload the program opened in Arduino IDE using Arrow button on top of Arduino IDE.
  2. Once uploading done close the Arduino IDE. It’s very important to close Arduino IDE because both LabVIEW and Arduino are using COM4. If not closed LabVIEW will not be able to communicate and LabVIEW will crash.
  3. Go to front panel. Write “0” in LDR box and “1” in Temperature box. They indicate the arduino pins to which LDR and LM35 are connected in real time.
  4. Run the program for weather station in toolbar menu of LabVIEW. Complete weather station status is as below when running the program.Weather Station using Arduino and LabVIEW

You will see the temperature and light intensity indications on panel of weather station that is front panel of LabVIEW. When we change temperature in real world, thermometer shows on the panel of LabVIEW and also when intensity of light is changes it is also indicated on the front panel of LabVIEW.

 

2 thoughts on “Weather Station using Arduino and LabVIEW”

Leave a Comment