Pages: 1 [2] 3 4 ... 7   Go Down
Author Topic: Using android mobile to control arduino  (Read 91113 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 6
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found out how to send data from the app to cosm website

here is a video showing an example app as well as a brief explanation of how to use app inventor



You can download the app here >>
<a href="http://speedy.sh/d4444/bluetoothAppCosmExampleTemperature1.apk">Download at SpeedyShare</a>

Here you can download the source >>
http://speedy.sh/Vwwww/bluetoothAppCosmExampleTemperature.zip


Here is arduino code I used (note that you need OneWire library for it to work)
Code:
#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;}
  
  


And here is the feed I created for the app -> The feed is available here - https://cosm.com/feeds/118188


In order to send data from or to your own COSM feed you have to modify the URL as follows (parts that you have to fill in are in capital letters):

http://api.cosm.com/v2/feeds/YOUR FEED ID/datastreams/YOUR DATASTREAM ID.csv?key=YOUR API KEY&_method=put

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



If you have any questions feel free to ask them


« Last Edit: March 10, 2013, 03:31:15 pm by kerimil » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When is necessary to use a level-shifter? some people use the 74HC4050N level shifter in conjunction with the btm222 module!
Logged

0
Offline Offline
Full Member
***
Karma: 6
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1330
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Where did you initialise serial data speed on Bluetooth device?

Between the Bluetooth device and the phone, the serial data speed is solved during "pairing" of the device to the phone. At least this is my belief.
Logged


0
Offline Offline
Full Member
***
Karma: 6
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Greenville, IL
Offline Offline
Edison Member
*
Karma: 15
Posts: 1330
Warning Novice on board! 0 to 1 chance of errors!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 @sisyph

 I recommend you share your code that you are using, just to eliminate the possibility of the code being the problem.
Logged


0
Offline Offline
Full Member
***
Karma: 6
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ohh I see now... the problem you are experiencing is caused by data types

The app sends bytes so it converts '1' into '49' and that's what's sent through bluetooth.


Ohh and you really should have connected the app to the bluetooth dongle - that would make everything clear for you.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah !! it works.
I used in my sketch : case '1' : instead of case 1:
So many hours for ''...
The strange things is that it worked before when I used my bt connection with my computer...
Thanks for your help
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just found this app. Those who are interested can check out ArduinoCommander android app too:
https://play.google.com/store/apps/details?id=name.antonsmirnov.android.arduinocommander
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi kerimill,

i wanna buy a bluetooth for this project.so just went through ebay and found this link
 
http://www.ebay.com/itm/JY-MCU-HC-06-V1-03-Bluetooth-Transeiver-RF-Module-Wireless-Serial-4p-Port-line-/261053366958?pt=LH_DefaultDomain_0&hash=item3cc7fe42aehttp://www.ebay.com/itm/JY-MCU-HC-06-V1-03-Bluetooth-Transeiver-RF-Module-Wireless-Serial-4p-Port-line-/261053366958?pt=LH_DefaultDomain_0&hash=item3cc7fe42ae

this bluetooth module has a pairing code 1234. so to pair this module with ur app, should i modify ur project?? will it automatically ask for code??
plz tel me that can i use this module??

thnx
Jazly smiley
Logged

0
Offline Offline
Full Member
***
Karma: 6
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The app doesn't have to pair with the module - just pair with it from the phone and then run the app

It should work just fine - just make sure you check the datasheet of the module & make sure the baud rate is the same (if so then the arduino code has to be modified or the setting of the module)
« Last Edit: April 03, 2013, 11:38:48 am by kerimil » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi , i am interested in such project .. i purchased arduino uno , bluetooth bee , and x bee sheild ..
i am having a problem in bluetoothfor arduino app.. i couldnt figure out on wat program it will run ...
thnk u for ur cooperation ..
Logged

0
Offline Offline
Full Member
***
Karma: 6
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't really understand the question... could you be more specific ? I know English is probably not your native language but I can't really tell what's the problem
Logged

Pages: 1 [2] 3 4 ... 7   Go Up
Jump to: