Click here to Skip to main content
15,742,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i created an app that fetches accelerometer data and displays in a textbox. How can I send these readings via bluetooth to control my bot using it.?
Please help guys.

additional information copied from comments below
I got the data. But the problem is that I dont know how to send it via bluetooth from the same app. If you want I can share the code with you. If it can help.?

I want to send the reading as an when they are fetched via bluetooth to other device that uses serial communication. I dont know how to do that. m sharing the code as a comment.

namespace Demo
    public partial class MainPage : PhoneApplicationPage
        Accelerometer accelerometer;
        // Constructor
        public MainPage()

            if (!Accelerometer.IsSupported)
                readings.Text = "No accelerometer sensor found.";

            if (accelerometer==null)
                accelerometer = new Accelerometer();
                accelerometer.TimeBetweenUpdates = TimeSpan.FromMilliseconds(5);
                accelerometer.CurrentValueChanged += new EventHandler<sensorreadingeventargs<accelerometerreading>>(accelerometerEventHandler);

        private void accelerometerEventHandler(object sender, SensorReadingEventArgs<accelerometerreading> e)
            Dispatcher.BeginInvoke(()=> UpdateUI(e.SensorReading));

        private void UpdateUI(AccelerometerReading accelerometerReading)
            Vector3 accelerateDir = accelerometerReading.Acceleration;
            readings.Text = "X: "+accelerateDir.X.ToString()+"\nY: "+accelerateDir.Y.ToString()+"\nZ: "+accelerateDir.Z.ToString();

Updated 7-Nov-14 7:18am
Sergey Alexandrovich Kryukov 7-Nov-14 12:58pm    
Not clear. This is your code and your control. You already got the data. You send your data the way you defined in your code.
Nelek 7-Nov-14 12:58pm    
Help with what?
Where are you stuck?

Please read following links:
What have you tried?[^]
How to ask a question?[^]
Nikhil_Malik 7-Nov-14 13:12pm    
Did you get what m trying to do now and where M stuck.?
Sergey Alexandrovich Kryukov 7-Nov-14 14:28pm    
It's clear what you do. There is nothing wrong with that.
But better use DispatcherTimer:
Not clear what your problem is.
Nikhil_Malik 8-Nov-14 0:53am    
The code i have written is working fine. There is no problem with it. Now I want to extent this code so that the readings of accelerometer can be send via bluetooth to other device instead of being displayed in the textbox.? Did you get it now.?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900