Hi everybody! first, please apologize, i'm french ^^
I've got a problem: I'm trying to simulate sensor datas sending by bluetooth to my mobile phone in which i installed Bluetooth Spp app. But here is the problem: instead of receiving many 1 or 0, i receive many "?" (in squares, like this:
http://www.google.fr/imgres?imgurl=http%3A%2F%2Fwww.aidevirtuelle.com%2Fwp-content%2Fuploads%2F2013%2F07%2Fmessage1.jpg&imgrefurl=http%3A%2F%2Fwww.aidevirtuelle.com%2Fblogue%2F&h=182&w=652&tbnid=CxypANnaGJdiUM%3A&zoom=1&docid=xtkkOpSDDLx73M&ei=YtE3VYXUH5D3arjpgMgB&tbm=isch&iact=rc&uact=3&dur=727&page=1&start=0&ndsp=18&ved=0CCQQrQMwAQ)
I tried to simply communicate between the arduino card and my mobile, and it surprised me because it did function! but unfortunatly I didn't succeed in establishing the data sending...
If anyone could bring me some help I would be extremely thankfull!!
![]()
Hi everybody! first, please apologize, i'm french
That does not mean that you get away with not posting code.
posting code?
polite phrases you mean?
remsya:
posting code?
Yes. You are having some issues involving the code you are running on the Arduino. Where is that code?
int cc;
int CorpsOK = 0;
int lim = 10;
#include <SoftwareSerial.h> //Software Serial Port
#define RxD 10
#define TxD 7
#define DEBUG_ENABLED 1
SoftwareSerial blueToothSerial(RxD,TxD);
void setup()
{
Serial.begin(9600);
pinMode(RxD, INPUT);
pinMode(TxD, OUTPUT);
setupBlueToothConnection();
}
void loop()
{
char recvChar;
while(cc<10)
{
if(blueToothSerial.available())
{//check if there's any data sent from the remote bluetooth shield
recvChar = blueToothSerial.read();
Serial.print(recvChar);
}
if(Serial.available())
{//check if there's any data sent from the local serial terminal, you can add the other applications here
cc = Serial.read();
}
{if ( cc > lim ){CorpsOK = 1;}
else{CorpsOK = 0;}
{blueToothSerial.print(CorpsOK);}
}
}
}
void setupBlueToothConnection()
{
blueToothSerial.begin(38400); // Set BluetoothBee BaudRate to default baud rate 38400
blueToothSerial.print("\r\n+STWMOD=0\r\n"); // set the bluetooth work in slave mode
blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); // set the bluetooth name as "SeeedBTSlave"
blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
blueToothSerial.print("\r\n+INQ=1\r\n"); // make the slave bluetooth inquirable
Serial.println("The slave bluetooth is inquirable!");
delay(2000); // This delay is required.
blueToothSerial.flush();
}
Sorry, i thought this problem was ordinary and people didn't need the code...
in fact this program is supposed to say if a value is validated and communicate the answer to the mobile
There are no printable characters with a value less then 10, so the only value that your Arduino will ever be sending is 1, unless you have line ending set in the serial monitor to send a carriage return and line feed. The arrival of the line feed will trigger sending a 0.Everything else will send a 1.
If you are receiving other than the characters '0' or '1', then the problem is either with the baud rate you are using or the receiving application.
you mean no printable characters with a value <10? In fact I tried, instead of "blueToothSerial.print(CorpsOK)", to write:"blueToothSerial.print("ok")", and "blueToothSerial.print("not ok")" in each if and else, but i received the same symbols (?). I think it's because of the receiving application but i wrote another program which consisted in dialoguing between my mobile and the arduino and the thing was I received the exact messages...
And do you think I should better write blueToothSerial.println? (I have changed the ln)
you mean no printable characters with a value <10?
Correct.
but i received the same symbols (?). I think it's because of the receiving application but i wrote another program which consisted in dialoguing between my mobile and the arduino and the thing was I received the exact messages...
This suggests that the baud rate you are using is incorrect, or that the problem is on the other end.
Ok thank you! But I tried with a baud=300;4900;9600;38400, It just changed the speed... Do you know any application to receive the data? (I tried bluetooth spp)
#7 below will help you get up to speed. Is the bluetooth adapter connected to the arduino serial port pins?