By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

data transmission from a bluetooth module to computer, need C code help.

P: 2

i am trying to write a code in C to transfer my signals from bluetooth to the compuer. I have four signals coming from a sensor unit. 2 AC and 2 DC. In my code I have already read those signals and sampled with AD converter , now when i am sending the data I do not know what should i define in the code. like how to assign values to bytes and pack the data, since im not a prgrammer :( this is my code, i would begrateful if you could give me some hints:
Expand|Select|Wrap|Line Numbers
  1. */
  3. //#include <macros.h>
  4. #include <iom32v.h>
  5. #include <mymacros.h>
  6. #include <AdcADS8341Layout.h>
  7. #include <AdcADS8341.h>
  8. #include <Delay.h>
  9. //#include <Uart.h>
  11. int main(void)
  12. {
  13.         unsigned int PPG_IR_AC;
  14.         unsigned int PPG_IR_DC;
  15.         unsigned int PPG_R_AC;
  16.         unsigned int PPG_R_DC;
  18.     // Insert code
  20.     do
  21.     {
  23.     // init the port
  24.     // Ex
  25.     DDRD = OUT7 | OUT6 | IN5 | IN4 | IN3 | IN2 | IN1 | IN0;
  26.     SetBitMask(PORTD, BIT6);
  28.     //Power On
  29.     SetBit(PORTD,7);
  32.     while(TRUE)
  33.     {
  34.         PPG_IR_AC = GetAdcADS8341(ADS8344_CH5);
  35.         PPG_IR_DC = GetAdcADS8341(ADS8344_CH6);
  36.         PPG_R_AC = GetAdcADS8341(ADS8344_CH7);
  37.         PPG_R_DC = GetAdcADS8341(ADS8344_CH2);
  39.        UartSendByteUB(PPG_IR_AC>>8); // How to send measured data to bluetooth transmitter
  40.        UartSendByteUB(PPG_IR_AC); // How to send measured data to bluetooth transmitter
  42.        UartSendByteUB(PPG_IR_DC>>8);
  43.        UartSendByteUB(PPG_IR_DC);
  45.        UartSendByteUB(PPG_R_AC>>8);
  46.        UartSendByteUB(PPG_R_AC);
  48.        UartSendByteUB(PPG_R_DC>>8);
  49.        UartSendByteUB(PPG_R_DC);
  52.    Delay(1024, 0.013); // delay
  55.     }
  57.     }while(0);
  59.     return 0;
  60. }
Dec 17 '10 #1
Share this Question
Share on Google+
3 Replies

P: 256
There's a device discovery procedure that must be done to get the communication channel established. So, your PC needs to have a bluetooth dongle. Is your PC able to see your device? Are you past that initialization part already?

If the PC isn't seeing your embedded device yet you'll have to go to your datasheet/userguide and figure out how to set up bluetooth and make sure both sides work.

#include <iom32v.h> says you've got some AVR chip, does it have bluetooth support embedded in it? (I'm unfamiliar with AVR details).

Once you get bluetooth communication going and the PC can see the embedded device just throw any data at it and make sure you can see it on the PC side. Simple text works well.

Then you're at the point where you need to format your data to be useable on the PC side. Maybe you're there already. You have to decide if you want to send binary data or text based data. There's a good FAQ on the subject at It's focused on C++, but the basic concept is all you need.

What's the device you're programming and how does the PC side use data it's receiving?

I guess I'm a bit scrambled in my response because I can't tell if you have any communications established already or not.
Dec 17 '10 #2

P: 2
the pc recognize the bluetooth, and we use labview to recieve the data, but the thing is that i dont know how to send the data , so when it gets into the labview , it will be clear which signal is it. like how to distinguish the signals over there. since its asynchronous data, and 4 signals go in a line of 64 bits (16 each). so i wanna know how can i use a flag or something in my c code for bluetooth while sampling, so when it gets to the computer we can easily speerate them.
Dec 18 '10 #3

P: 256
Well, as the FAQ states, you have to decide if you want to send data in binary format (as your code does currently), or text format.

I've never used lab view so I can't tell you how to make it recognize your numbers. Is there a certain format that it expects that you need to have your input conform to?
Dec 21 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.