Main Site Documentation

Sending Multiple Sensor Data From FEZ Spider via Bluetooth to PC


#1

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


#2

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)


#3

maybe have a look at

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

or

welcome to the forum


#4

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


#5

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.


#6

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


#7

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


#8

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… http://mikedodaro.net/2012/04/21/controlling-a-gadgeteer-device-using-bluetooth-module-and-32feet-net-library/


#9

@ 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.


#10

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


#11

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


#12

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


#13

@ 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.


#14

@ 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.


#15

@ 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)


#16

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


#17

@ 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.


#18

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


#19

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


#20

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