Go Down

Topic: arduino- bluetooth - relay (Read 1 time) previous topic - next topic

MrSilece

Hello,

I would like to control my outputs with my android phone. @ this moment im building my own relay shield + an option for bluetooth module. The only big problem I have no knowledge about how to creat a code to get it work. Im new to arduino so i hope there is someone that can help me out.




The way how im going to connect the bluetooth module





Many thank,

razorjack

#1
Jan 21, 2012, 02:54 pm Last Edit: Jan 21, 2012, 02:58 pm by razorjack Reason: 1
you need to create your own 'protocol'

data will be send as a never ending byte array (stream) so you need to be able to find a beginning of a 'command' and it's end.
for example if you want to send two bytes, you can make third byte 0x00 as a 'stop byte' if you are sure, that data bytes have no 0 value.
more sophisticated protocols could look like this:
two bytes - unique signature
two bytes - length of a datablock
byte[] - data

if you want to steer a relay, so you dont want to send data whole the time, you can make 'commads'
for example
one byte - unique signature
one byte - command
one byte  - data

so the command would look like this: 
0xff 0x01 0x00  - means disable device 1 (your relay)
0xff 0x01 0x01  - means enable device 1 (your relay)
0xff 0x02 0x01  - means enable device 2 (next relay)

4ntoine

No needto create special protocol. You can use StandardFirmata sketch (Firmata protocol) and ArduinoCommander android application - https://market.android.com/details?id=name.antonsmirnov.android.arduinocommander

PaulS

@4ntoine - Enough with the spamming. Once or twice is fine. You don't need to post this stuff in EVERY thread that mentions Android!

jack_fr

@4ntoine Too much noise about the app, but i must confess that it's cool  :P

Go Up