Main Site Documentation

Connecting a .NET Gadgeteer (FEZ Cerberus) and a Windows Store App/Windows form application


#1

To whom it may concern,

I recently acquired a .NET Gadgeteer FEZ Cerberus board with the Tinker Kit and I also purchased a USB-Serial 1.5 (https://www.ghielectronics.com/catalog/product/287). I want to gather data from a light sensor included in the kit (https://www.ghielectronics.com/catalog/product/336) then transmit it to a PC running Windows 8.1 and finally have a Windows Store app or a Windows Form Application process the information to modify settings in the application (Windows Form or Store app) and display the data from the sensor. Would this be possible? Could you assist me in programming (send the data from the light sensor to a Windows Store or Windows Form app) this either in VB.NET or C#? Your help and time is greatly appreciated.

Sincerely,

Coder 206


#2

I would like to add that I did a little coding that was not successful.


var light = lightSense.GetIlluminance();
usbSerial.ToString(light);

Visual Studio flags an error at this code. It states
No overload for method ‘ToString’ takes 1 arguments


#3

Welcome to the forum coder206.

Yes, this is certainly achievable - there are a few things I’d suggest that you make sure you spend time reviewing that will help you figure some of these items out for yourself.

But here’s my very first pointer… the ToString() method (or whatever it’s technical name is) works ON an object, so your statement is trying to operate on the USBSerial object and convert it to a string. What you should be trying to do is operate on the “light” object and create a string representation of that, that you will then send over the serial line.

So here’s step 1. Debug.Print(“Hello world”) is your friend. Get used to using this and it’ll produce visible output in VS so you can see where your program is going. Same for using breakpoints and the cool debugging features like breakpoints and real-time evaluation. I would replace your current “tostring” command with:


And go from there.  You'll then want to use the Write method of the usbSerial device to send data over the serial port.  

Step 2 I'd suggest is that you try having a look at GHI's Gadgeteer "getting started" guide over https://www.ghielectronics.com/docs (it's a work in progress but might help get you some quick wins)

Hope this helps, let us know how you get on!

#4

Thanks for the swift and helpful response!


#5

@ Brett - Hello Brett,

Thanks for your help.
I am contacting you once more because I attempted to change my code to match your suggestions however, I cannot find the Write method for the USB serial module (https://www.ghielectronics.com/catalog/product/287) you wrote about in the last reply. I would appreciate it if you could guide me a little more (help me send data threw the USB serial module to the desired Windows Forms Application). When I write usbserial in Visual Studio Community 2013 here are my options (via a snapshot of my current project in Visual Studio written in C#). Thank you very much for your precious time.

Sincerely,

Coder 206


#6

https://www.ghielectronics.com/docs/15/uart-serial has the info on a “pure” serial port. I haven’t used the USBSerial device so am not sure here, but here goes.

SerialLine returns the GTI.Serial object associated with your device. You will use that to do the write. So the syntax is probably going to be usbSerial.SerialLine.Write()

Make sure you “Configure” the port before use :slight_smile:


#7

And if you then continue to write:

usbSerial.SerialLine.

you will see the Options you have with this (including the write method)

However I think you are still using NETMF 4.2 and an old GHI SDK.
It’s advisable to switch always to the newest Version.

in 4.3 the code for the usbSerial module is a little bit different:


using GTI = Gadgeteer.SocketInterfaces;
..
..
usbSerial.Configure(9600, GTI.SerialParity.None, GTI.SerialStopBits.One, 8, GTI.HardwareFlowControl.NotRequired);
 if (!usbSerial.Port.IsOpen)
{
                usbSerial.Port.Open();
}
usbSerial.Port.Write("Hello");