Sending Multiple Sensor Data From FEZ Spider via Bluetooth to PC

Hi ,

I’m making a device which is having multiple sensors (i.e PING Sensor, Compass etc;) . But the problems arose are, ,

1. How to Connect to the PC

for this I’ve used the following code fragment,

void InitBluetooth()
        {
            // Keep a quick reference to the Bluetooth client, to make it
            // easier to send commands back over the module
            //bluetooth = new Bluetooth(9);
            
            client = bluetooth.ClientMode;

            // Set the Bluetooth device name to make it easier to identify when
            // you pair this module with your phone
            bluetooth.SetDeviceName("MyDevice");
            bluetooth.SetPinCode("1234");

            // We want to track when we are connected and disconnected
            bluetooth.BluetoothStateChanged += new Bluetooth.BluetoothStateChangedHandler(bluetooth_BluetoothStateChanged);

            // We want to collect all the data coming in
            bluetooth.DataReceived += new Bluetooth.DataReceivedHandler(bluetooth_DataReceived);
        }

But It’s showing and Exiting with 0 after changing the BTSTATE from 1 to 3…

2.Sending Data to the PC Application

Any opinion regarding to this?

Thanks

For the Problem Number 1 ,

I have changed the

Bluettothstatechanged() 

like this ,

void bluetooth_BluetoothStateChanged(Bluetooth sender, Bluetooth.BluetoothState btState)
        {
            switch (btState)
            {
                case Bluetooth.BluetoothState.Connecting:
                    Debug.Print("BLUETOOTH ---> CONNECTING");
                    break;
                case Bluetooth.BluetoothState.Connected:
                    Debug.Print("BLUETOOTH ---> CONNECTED");
                    break;
                case Bluetooth.BluetoothState.Disconnected:
                    Debug.Print("BLUETOOTH --->  DISCONNECTED");
                    break;
                case Bluetooth.BluetoothState.Initializing:
                    Debug.Print("BLUETOOTH --->  INITIALIZNG");
                    break;
                case Bluetooth.BluetoothState.Inquiring:
                    Debug.Print("BLUETOOTH ---> INQUIRING");
                    break;
                case Bluetooth.BluetoothState.Ready:
                    Debug.Print("BLUETOOTH --->  READY");
                    // Enter pairing mode once the device is ready.
                    Debug.Print("ENTERING PAIRING MODE NOW");
                    client.EnterPairingMode();
                    break;
                default:
                    break;
            }    
        }

The Device is stopping in BLUETOOTH —> INQUIRING stage with Blinking LEDs in Bluetooth module (Red and Blue)

maybe have a look at

http://www.tinyclr.com/codeshare/entry/600

or

https://gadgeteerbluetooth.codeplex.com/SourceControl/changeset/view/18482#170995

welcome to the forum

http://www.tinyclr.com/codeshare/entry/446 is exactly what you want. I think I also described how you might see the port on the PC side

Hi,
I’m working on a similar application for some time. I hope that I can post it here in the next days.
Roland

@ Brett – Hi, I used your “Minimal Gadgeteer Bluetooth module test app” from the link above with minor modifications. Your valuable app cannot be found under the tag “bluetooth”. You should add this tag to your project.

1 Like

Good point. If I figure out how, I will :slight_smile:

Hi All,

I’ve connected the device and the PC but , How can I parse the data from Device to my PC Desktop Application . I’ve used the 32feet.net and ,

In My Device I’m sending the data as follows ,

void send_Welcome()
        {
            if (bluetooth.IsConnected)
            {
                client.Send("Hello EarthLings");
            }
            else
            {
                client.EnterPairingMode();
                
            }
        }

In my Desktop Application ,

I’ve used the code as follows ,

 bluetoothStream = bluetooth.GetStream();
                    textBox1.Text = bluetoothStream.ToString();

But It’s not working , Am I missing something ? Please advice

Without a doubt, the best way to debug this is to open a connection to the COM port with Tera Term. If you can read the data, you’ll see that things are working. Prove that is working. Mike has a working 32feet.net example as well… Controlling a Gadgeteer device using Bluetooth Module and 32feet.NET library | Integral Design

@ apprentice - if you give me your e-mail address, I can send you my programs to test. It’s an application for the spider that sends data to the PC via bluetooth and an application in C# for the PC that receives the data and stores them in a xml database. There are still some bugs in the program for the PC which I want to eliminate before I post it.

@ apprentice - I got it, you should delete it now in your post to get not spam.

@ apprentice - did you get it? It was several times rejected by your e-mail filter.

1 Like

@ RoSchmi - was it gmail? Google wont allow alot of file types even if they are in a zip, most painful…

1 Like

@ Justin - yes, gmail. I know that there may be no .exe files but I always forget to delete some of them. Is there an automatic way to make a project sendable.

@ RoSchmi - not that i have found… They don’t allow things like .vb etc, think .cs is ok but there are a few Visual Studio file extensions that they block.

@ RoSchmi - Yes I got that . If you have any Windows Forms /WPF Program to receive data. That would be really helpful. Thanks.

(For the exe problem Use 7ZIP or WinRAR to compress the file)

You cant send or receive any if these via gmail even if they are in a zip, rar etc

ade, .adp, .bat, .chm, .cmd, .com, .cpl, .exe, .hta, .ins, .isp, .jse, .lib, .mde, .msc, .msp, .mst, .pif, .scr, .sct, .shb, .sys, .vb, .vbe, .vbs, .vxd, .wsc, .wsf, .wsh

@ apprentice - Yes, I am working on an Windows Forms application but there are still some bugs. Please tell me, if it works for you with teraterm.

I don’t have a RS 232 module . I’m editing your code a bit after that I’ll tell you the result

Changing the extension of the archive from .zip to something else worked for me in the past.

@ Architect - good idea, I’l try it the next time.