As I mentioned on hackaday it won't be the exact copy as I improved it to react not only to 'BLINK' command but also 'FLASH' and 'CYCLE'... done that just because google voice search usually returns 'pink' or even 'd#ck' instead of BLINK
but apart from that it's the same
If you have any problems with downloading the files just let me know
I just gave this a try myself and it worked great. Now I am trying to receive data (an integer value) from the arduino instead of sending to it, but cant seem to figure out how...
Use a call bluetoothclient.receivetext and set th number of bytes to -1, which reads until delimiter byte is received.
Mmake sure you set the delimiter byte - I used '13' which is carriage return... ohh you might find this useful -> http://www.asciitable.com/index/asciifull.gif
What's more, it's seems there is no serial timout implemented yet and the app freezes if it doesn't receive anything. To solve that I set up the app to first send a 1 byte number to the arduino, when arduino receives that it sends its data.
Thanks for sharing your code and work! I have now started trying to learn app inventor because of your post! I too wish to send and receive bluetooth data so, I am very interested in that!
kerimil:
What's more, it's seems there is no serial timout implemented yet and the app freezes if it doesn't receive anything. To solve that I set up the app to first send a 1 byte number to the arduino, when arduino receives that it sends its data.
I wonder if you have to test for bytes available? In the Arduino it would be a test like if(Serial.available()){ Serial.read } .
In the code blocks you have a something that says BluetoothClient1BytesAvailableToReceive.............I think it should be combined with a if > 0 { read the byte }....or something like that.
P.S. I am tring to adapt your code to my purpose and I am learning while making the attempt.
cyclegadget:
I wonder if you have to test for bytes available? In the Arduino it would be a test like if(Serial.available()){ Serial.read } .
In the code blocks you have a something that says BluetoothClient1BytesAvailableToReceive.............I think it should be combined with a if > 0 { read the byte }....or something like that.
Well yeah, but you can't have (Serial.available()){ Serial.read } all by itself - meaning the control structure block has to be attached to something else - ideally it should happen with no user input. The only thing I can think of is to have it inside Clock.timer block and set it to fire every 10 ms or so. That's not ideal but it might work.
I had had some problems when I tried to implement it. Though the idea might be ok. I might have messed up something else - it is possible I sent data more often than the app received them and that freezed the app because of the buffer. Well at least that's my understanding of it
it's a BTM222 module on a custom breakout board - kind of cool because it is a class 1 device - so the max range is not 10m but 100m
I bought it from a local tinkerer who makes them - so I don't think you'd be able to get it
Though there are lots of such boards all over ebay - though most of them are class 2 (range ~10meter)
kerimil:
I had had some problems when I tried to implement it. Though the idea might be ok. I might have messed up something else - it is possible I sent data more often than the app received them and that freezed the app because of the buffer. Well at least that's my understanding of it
I kept getting the same thing, its quite frustrating as my phone takes forever to recover! In my arduino code I just had Serial.println(...) in the loop and had my app to receive text every 1 second (with delimiter byte set to 13). I either get some odd values or it just crashes.
First of all THANKS,
this was the project that I was waiting for.
I do not understand very much the wiring connection, especially the bt connection, my lack.
green wire: pin0 (arduino) - ? (bt)
yellow wire: pin 7 (arduino) - led
black wire: ? (arduino) - resistor - ? (bt)
red wire: ? (arduino) - ? (bt)
and like in a loop I finish with
End of all THANKS
Here is arduino code I used (note that you need OneWire library for it to work)
#include <OneWire.h>
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2
void setup()
{
// initialize the serial communication:
Serial.begin(19200);
// initialize the ledPin as an output:
}
void loop() {
float temperature = getTemp();
Serial.println(temperature); delay (250);
}
float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -100;
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}
if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for (int i = 0; i < 9; i++) {
data[i] = ds.read();
}
ds.reset_search();
byte MSB = data[1];
byte LSB = data[0];
float tempRead = ((MSB << 8) | LSB);
float TemperatureSum = tempRead / 16;
return TemperatureSum;}
Then copy and paste the URL into a QR code generator, generate a QR code and scan it using the app. You might as well use the feed I created for the app - it's the default URL set in the app so you don't have to enter it - it's already there
The module I got has a proper level shifter on it, but AFAIK one could improvise with zener diodes to achieve the same effect (not that level shifters are very expensive)
Tanks a lot Kerimil for your project vert helpfull.
I tried to do the same without Voice recognising. The connection From my phone and Bluetooth device is ok, the wiring sure ok ( rx to dx and dx to rx). But nô serial data is send. On your sketch, you initialise serial communication with 19200 bauds. I think the Bluetooth deviçe should send is data at same speed. Where did you initialise serial data speed on Bluetooth device? Perhaps the problème comes From there.
Tanks for your answer
Where did you initialise serial data speed on Bluetooth device?
Cyclegadget is right - it's either when pairing or whenever connection is established
Even if baud rate was wrong you'd still receive something - if you don't then it has to be something else.
Verify if the module and the mobile works using a USB bluetooth dongle and a program like putty. Also check the datasheet of the module and the settings - is the module set as slave or master ? For apps I created it has to be set as master
Thanks for sharing your work. I tried it without voice detection. BT is paired with my phone but apperently no serial data is send. If I try to send "1" or "2" with my computer connected in bt, using putty the led switch on and off correctly so the hardware and arduino sketch is ok. my problem is coming from app inventor. what is button 1 set and number for? is the real value 1 and 2 are send or ascii value. I tried with mega 2560 with external power and connect rx and tx to serial 0