Hello. This is my scenario, i have an arduino uno and a hc-05 bluetooth module.
i use software serial for hc-05, this is my arduino code:
(from this link :
http://stackoverflow.com/questions/18376468/arduino-using-serial-and-software-serial-with-bluetooth-module[
^])
#include <SoftwareSerial.h>
#define rxPin 8
#define txPin 7
SoftwareSerial mySerial(rxPin, txPin); // RX, TX
char myChar ;
void setup() {
Serial.begin(9600);
Serial.println("Goodnight moon!");
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop(){
while(mySerial.available()){
myChar = mySerial.read();
Serial.print(myChar);
mySerial.print(myChar);
}
while(Serial.available()){
myChar = Serial.read();
mySerial.print(myChar);
}
}
And i downloaded the app2device sample from msdn (link :
https://code.msdn.microsoft.com/Bluetooth-app-to-device-644870ba[
^])
I can connect my hc-05 bluetooth module, i see connected message box with host name. And when i send data to arduino hc-05, arduino receives it. I send the data with this method (link
A Simple Bluetooth Application[
^]) :
DataWriter dataWriter = new DataWriter(_socket.OutputStream);
string message = "selammm";
dataWriter.WriteInt32(message.Length);
await dataWriter.StoreAsync();
dataWriter.WriteString(message);
await dataWriter.StoreAsync();
There is no problem here. But arduino should send this message back from bluetooth,
with SoftwareSerial with
mySerial.print(myChar);
But with this code from last codeproject link 'A Simple Bluetooth Application', windows phone does not receive anything.
DataReader dataReader = new DataReader(socket.InputStream);
await dataReader.LoadAsync(4);
uint messageLen =(uint)dataReader.ReadInt32();
await dataReader.loadAsync(messageLen)
String Message = dataReader.ReadString(messageLen);
i set a breakpoint to datareader, and i see it stacked at
await dataReader.LoadAsync(4);
. no errors, but no messages.
You can see there is nothing special from me with this codes, i am a beginner, and from samples i want to make my own app (bluetooth connection between arduino and windows phone ), but i can't manage to get this working...
arduino wiring is here:
5v to hc-05 vcc
gnd to gnd
hc-05 tx to pin 8
hc-05 rx with 1k resistor to pin7 and 2k resistor to gnd
i also copied this from a site
http://www.instructables.com/id/Cheap-2-Way-Bluetooth-Connection-Between-Arduino-a/[
^]
my arduino wiring is this except the rx,tx. i use 7,8 instead of 0,1 and software serial.
I will be really happy if someone helps me on this.
Thanks from now.