Saturday, 8 October 2016

Temperature on GUI using visual studio and arduino

In this post, first we will interface LM35 with arduino uno and then  upload this data through serial communication. With the help of visual studio we can make computer gui application and though this gui application, we can do lot of stuffs like temperature logger, humidity monitoring. The

Stuff we require:

  1. Arduino uno with usb cable
  2. LM35
  3. Jumper wires
  4. Visual Studio (I had used VS 2012)
Make connections as follows:

How to interface temperature sensor, lm35 with arduino
LM35 interfacing with arduino

Simply provide, Vcc and GND to temperature sensor (LM35) and it's output should be connected to A0 of arduino. You can connect it to any channel from A0 to A5.

Calculation part:

There is little bit calculation. LM35 gives analog output. It's linearity is 10 mV/°C
which literally means for rise in temperature of 1°C, there be an increment of mV from output of lm35. It's graph is linear. It's temperature range is from: -55°C to +150°C.
Since, we are using LM35 it is calibrated in terms of degree celsius. There are other variants available like lm235 and lm335.

Arduino Code: 

The code is very simple

Code Starts

float val=0.0;

void setup() {

void loop() 
Serial.println("VALUE OF TEMPERATURE IS: " + String(val) );

Code Ends

VS Code:

/* Code starts here

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;

namespace LM335
    public partial class Form1 : Form
        public Form1()

        void getAvailablePorts()
            String[] ports = SerialPort.GetPortNames();


        private void button3_Click(object sender, EventArgs e)
            textBox1.Text = "";
                if (comboBox1.Text == "" || comboBox2.Text == "")
                    textBox1.Text = "Please select your port settings";

                    serialPort1.PortName = comboBox1.Text;
                    serialPort1.BaudRate = Convert.ToInt32(comboBox2.Text);
                    progressBar1.Value = 100;
                    button1.Enabled = true;
                    button2.Enabled = true;
                    textBox2.Enabled = true;
                    button3.Enabled = false;
                    button4.Enabled = true;

                textBox1.Text = "Unauthorized Access";


        private void button4_Click(object sender, EventArgs e)
            progressBar1.Value = 0;
            button1.Enabled = false;
            button2.Enabled = false;
            textBox2.Enabled = false;
            button3.Enabled = true;
            button4.Enabled = false;

        private void button1_Click(object sender, EventArgs e)
            textBox2.Text = "";

        private void button2_Click(object sender, EventArgs e)
                textBox1.Text = serialPort1.ReadLine();
//                textBox1.Text = serialPort1.ReadLine();

            catch (TimeoutException)
                textBox1.Text = "Timeout Exception";




*/ Code Ends here

Check out the video:

Visit this blog for more updates !!


  1. Where is your studio code? Nothing is shown in the video that you have managed to do this.

    1. updated the vs code. Hope you will find it useful