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.

Connect Pin 1 and Pin 3 of LM35 with 5V Pin and GND Pin of Arduino respectively. Connect Pin 2 of LM35 with Analogue Pin A1 of Arduino. Connect a 10k resistor between Pin 2 and Pin 3 of LM35. (not shown in diagram). Connect one pin of LDR with 5V of Arduino. Connect second pin of LDR with pin A0 of Arduino. 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:

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

Bring Cursor to anywhere in LabVIEW “Block Diagram” panel and place the “Init”.

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. 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.

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. Second input is “Baud Rate”. Create it as constant as done for “VISA resource”. Right click on “Baud Rate” then “create” and then “constant”. Third input is “Board Type”, fourth is “Bytes per packet” and fifth is “Connection type” make them also constant.

Click on white space on LabVIEW “Block Diagram” and follow “Structure → select While loop”. Place two “analogue read pin” as follows one by one. Result is as follows.

Join diagram as follows. Create “Control” for input parameter “Analogue input pin” of both “Analogue Read Pin” blocks as follows. This step results as. Right click on white area. Go to “numeric” and find “divide”. Similarly find “multiply” and place it and join them as follows. Create indicated “constants”. Similarly create “multiply” and “constant” as indicated.

Go to Front panel and find “thermometer” as shown on block diagram of LabVIEW. Also find “slide” as we found thermometer. Place both of them on front panel one by one. Join “Slide” and “temperature” as shown on block diagram of LabVIEW. Create “Close” block as follows on block diagram of LabVIEW.

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.

Now Start Ardunio IDE. Click “File” then “Open” and Follow as shown. Go through all these folders from “Computer” onward and open LIFA_BASE Arduino file.

Upload the program opened in Arduino IDE using Arrow button on top of Arduino IDE. 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. 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. Run the program for weather station in toolbar menu of LabVIEW. Complete weather station status is as below when running the program.

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.