Visual Foxpro Serial Communication Arduino

  1. Visual Foxpro Serial Communication Arduino Code

Hello Everyone,

I am using an Arduino Uno and a couple of atmosferic sensors. Using DHT11 for humidity and BMP085 for pressure and temperature readings. My goal is to pass this information to a Visual basic program using serial port communication. To do this I concantenate the sensor readings into one string with the format:

MarshallSoft Visual FoxPro serial communications component library for RS232 and multi-drop RS485 and RS422 serial ports. Use WSC4FP to write applications to access data from serial devices such as barcode scanners, modems, lab instruments, medical devices, USB serial devices, scales, GPS navigation, fingerprint scanner, printer servers, etc. Visual Foxpro Serial Communication With Arduino. 3/20/2017 0 Comments Arduino Serial Communication With C Tutorial. The Windows Standard Serial Communications Library for Visual. Develop serial communication applications in Visual FoxPro. The Windows Standard Serial. Using the Communications Control.

'TXXXPYYYYYYHZZZZ'

where X will be the temperature, Y the pressure reading and Z humidity. The letters T,P and H are to facilitate getting the values from string in the visual basic with substring function.

THE PROBLEM:

My problem is that the string arrives fragmented at visual basic. For example I created a msgbox to prompt the message that arduino sent to me and instead of getting one msgbox with the entire message I get 2 or more msgbox with the fragmented message. BUT in the arduino serial monitor the message arrives entirely as one.

WHAT HAVE I TRIED SO FAR:Reducing baudrateBaudrate is the same in Vb as in arduinoReducing the size of the message to only temperature(4chars) still it breaksUsing delays between serial.print

The code on arduino is below:

Arduino

Best regards,Paulo Marcelino B. Soares

This article will show how to communicate between Arduino and Visual Studio through COM (UART) port.

  • 38,596 views
  • 6 comments
  • 30 respects

Components and supplies

Apps and online services

Microsoft Visual Studio 2015

About this project

This article shows how to communicate between Arduino and Visual Studio through COM (UART) port.

(1) Arduino will send data to the Visual Studio program:

(2) Visual Studio program will send data to Arduino. Arduino receives it, then feed it back to Visual Studio program.

Overview of steps:

1. Hardware connection2. Arduino program3. Visual Studio program

1. Hardware connection

2. Arduino program

Make a program for Arduino. At start up, Arduino will send a string (a sentence) every 0.5 sec. This will stop when User sends data (string) to Arduino, then Arduino will send it back to User. In this case, User is Visual Studio program (in part 3).

The code can be downloadhere - Google share

3. Visual Studio program

Make a windows application 🠚 save it.

Add a button, textbox and label to the Form (taken from Toolbox in the left):

Click on button, textbox and label to see Properties in the Toolbox in the right. Remember the name of each item to program in a latter section.

Add components 'serial Port' and 'timer':

Also, see properties to know the name each item. Remember to rename 'serialPort1' 🠚 'Portname' to COM-Port of Arduino (this case is COM4)

Programming works:The whole code of Visual Studio program can be downloaded here - Google share

(1) Double click to Form1 🠚 input the following code.Meaning: open (Arduino) COM-Port and start timer1

(2) Double click to Button1 🠚 input the following code.Meaning: send string from textBox1 to (Arduino) COM-Port

(3) Double click to timer1 🠚 input the following code.Meaning: every time timer1 ticks (it will tick every 0.1s 🠚 setting in 'Interval' of Properties of timer1), label1 will update information

(4) Click to serialPort1 🠚 see at Properties toolbox 🠚 click at 'Event' icon 🠚 double click at 'DataReceived'.

Then input the following code.

Meaning: read COM-Port data at every time receiving 🠚 save it to 'mStr'

Auxiliary code:

(1) Meaning: when Form1 is closed 🠚 close COM-Port and stop timer1

(2) Meaning: make global variable 'mStr'

After all, click icon 'Local Window Debugger' to build and run the program.

If everything runs smoothly, a window form will appear (note: Arduino should be connected to computer through COM4 with the program as in Step2).

At result (1): Form1 will show results from Arduino.

At result (2): Form1 will send data to Arduino, then receive it after Arduino sends it.

Author

engineer2you
  • 14 projects
  • 70 followers

Published on

March 11, 2017
Write a comment

Members who respect this project

and 23 others

See similar projects
you might like

Table of contents

Visual Foxpro Serial Communication Arduino Code

Write a comment