Introduction: Arduino and Visual Basic RF Over Temperature Humidity Measurement

About: Mechanical engineer, Entrepreneur, Maker, robotic systems expert and founder of Robimek and RobiBot

We can see Arduino using 433 MHz RF with instantaneous display of temperature and humidity values as we do with the visual basic program.

http://make.robimek.com/arduino-visual-basic-wireless-temperature-humidity-control/

Let's start with temperature and humidity before our project then let us interface with the visual basic program. Materials:

  • 2 Number Arduino (no matter nano models will suffice.)
  • RF module 433 MHz (433 MHz, we used in this project. You can also use modules of different frequencies)
  • Temperature Humidity Meter Module

Step 1: Transmitter Circuit:

Temperature and humidity values will be sent to the transmitter circuit and the receiver circuit.

Pin connector of the circuit:

Tx signal pin >> Arduino's digital 3.pin

Temperature-Humidity Sensor Data Pin >> Arduino's digital 2.Pin

Step 2: Receiver Circuit:

Our circuit will be transferred to the PC by taking the data receiver from the transmitter.

Circuit Connections:

Rx signal pin >> Arduino's digital 11.p

We have completed our transmitter and receiver circuits. Now let's start writing our interface with the visual basic program.

Step 3: Visual Basic Interface Program:

You can design the form as shown in figure.

Tools Required to our form:

  • 3 Piece Button
  • 2 Number combobox
  • 2 Number Progressbar
  • 11 Number Label
  • 2 Number Picturebox
  • 1 Piece SerialPort
  • 1 Piece Timor

Step 4: Add the System Libraries.

Imports System

Imports System.ComponentModel

Imports System.Threading

Imports System.IO.Ports

Step 5: Let's Define Our Serial Port Object.

Dim myPort As Array ‘port name identification

Delegate Sub SetTextCallback(ByVal [text]As String)

Step 6: Let's Define Our Form Loader Part.

myPort = IO.Ports.SerialPort.GetPortNames()

ComboBox2.Items.Add(9600)

ComboBox2.Items.Add(19200)

ComboBox2.Items.Add(38400)

ComboBox2.Items.Add(57600)

ComboBox2.Items.Add(115200)

For i = 0 To UBound(myPort)

ComboBox1.Items.Add(myPort(i))

Next

ComboBox1.Text = ComboBox1.Items.Item(0)

ComboBox2.Text = ComboBox2.Items.Item(0

)Button2.Enabled = False

Step 7: Let's Define Our Butonu Necessary to Enable Us to Connect Our Ports to Receive Data.

Timer1.Start()SerialPort1.PortName = ComboBox1.Text

SerialPort1.BaudRate = ComboBox2.Text

SerialPort1.Parity = IO.Ports.Parity.None

SerialPort1.StopBits = IO.Ports.StopBits.One

SerialPort1.DataBits = 8SerialPort1.Open()

Label10.Text = “Connected sensors”

Button1.Enabled = FalseButton2.Enabled = True

TextBox4.ForeColor = Color.GreenLabel11.Text = “Receiving Data…”

Step 8: Let's Define Our Butonu Disconnect Necessary to Stop the Data Acquisition.

Timer1.Stop()SerialPort1.Close()

Button1.Enabled = TrueButton2.Enabled = FalseText

Box3.ForeColor = Color.Red

Label10.Text = “Disconnected.”

Label11.Text = “Data Stopped.”

Step 9: Let Us Define One of Our Combobox to Select the Port.

If SerialPort1.IsOpen = False Then

SerialPort1.PortName = ComboBox1.Text

Else

MsgBox(“Port while you can not change”, vbCritical)End If

Step 10: Let Us Define for Us to Select the Required Baud Rate Value.

If SerialPort1.IsOpen = False Then

SerialPort1.BaudRate = ComboBox2.Text

Else

MsgBox(“Port while you can not change”, vbCritical)

End If

Step 11: Finally, the Serial Data Will Allow Us to Do Our Part Identification Is Necessary to Time.

Dim str As Stringstr = “1”

SerialPort1.Write(str)

Dim receiveddata As Integer = SerialPort1.ReadLine()

Label7.Text = receiveddata

If receiveddata < 0 Then

ProgressBar1.Value = -receiveddata

Else

ProgressBar1.Value = receiveddata

End If

System.Threading.Thread.Sleep(500)

Dim receiveddata2 As Integer = SerialPort1.ReadLine()

Label8.Text = receiveddata2

ProgressBar2.Value = receiveddata2

System.Threading.Thread.Sleep(500)

Step 12: Arduino Transmitter Software

#include <VirtualWire.h>

#include <dht11.h>

.#define DHT11PIN 2

dht11 DHT11;char msg[6];

void setup()

{

vw_setup(2400);

vw_set_tx_pin(3);

}

void loop()

{

int chk = DHT11.read(DHT11PIN);

int sicaklik =DHT11.temperature;

int nem = DHT11.humidity;

sprintf(msg, “%d,%d”, sicaklik, nem);

vw_send((uint8_t *)msg, strlen(msg));

vw_wait_tx(); delay(1000);

}

Step 13: Arduino Receiver Software

#include <VirtualWire.h>

int sicaklik;

int nem;

int i;

char x;

char StringReceived[6];

void setup(){ Serial.begin(115200);

vw_set_rx_pin(11); vw_setup(2400);

vw_rx_start();

}

void loop()

{

if(Serial.available()>0)

x=Serial.read();

uint8_t buf[VW_MAX_MESSAGE_LEN];

uint8_t buflen = VW_MAX_MESSAGE_LEN;

if(x==’1′)

{

if( vw_get_message(buf, &buflen) )

{

for (i = 0; i < buflen; i++)

{

StringReceived[i]= char(buf[i]);

}

sscanf(StringReceived, “%d,%d”,&sicaklik, &nem);

Serial.println(sicaklik);

delay(500);

Serial.println(nem);

delay(500);

memset( StringReceived, 0, sizeof( StringReceived));

}

}

}

Step 14: Description:

500 millisecond delay is happening with data acquisition software.

If the timer of the form System.Threading.Thread.Sleep(500) change this value should also change the value. Otherwise you will get the wrong values.

More İnformation and example project : http://make.robimek.com/arduino-visual-basic-wireless-temperature-humidity-control/