Send pressure sensor value to a smartphone by bluetooth

Does anybody here have an Idea about how to send a pressure sensor to a smartphone to use in apps like Altimeter/Variometer Using bluetooth?

tks a lot.

Any idea?

If you want to write a program yourself i´d suggset looking for Android documentation, there are lots of examples how to initiate a bluetooth connection (i did it myself just some nasty work waiting := ). I guess you are using a serial bluetooth module so the arduino code is just Serial.print but you have to look up your baud rate of your bluetooth module (most have 9600 default). On some modules it is easy to change that , which module are you using ?

If you just want to test little around if it transmissions are working (and they will, bluetooth has FEC built in) just grab a terminal probgram like bterm or bluetooth terminal (https://play.google.com/store/apps/details?id=Qwerty.BluetoothTerminal i used that one).

Best regards, smithy

Hi, not much experience but wanted to be of help. If you are looking for a relatively easy solution (it directly connects and sends data to internet/smartphone via cloud servers) go to spark.io and look at photon Otherwise, as smithy said you could write your own code - fine if you are good with C++ or you could use a BLE module, and some kind of third party application for processing the data from the arduino

You could also I suppose use the ethernet shield to set up a webpage for it sending data. Please elaborate on what your projects specs are - does it need to be portable etc, what arduino will you use? Hope this helps.

Android is not written in c++ its written like Java, the c++ code for the arduino should not be a problem at all.

Since you want to use your data in other programs you have to check in which format they need to be, i still recommend setting up a plain bluetooth communication with bluetooth terminal (easy for checking if a connection is being made and if you can send data) and then think about how to send data to one of your chosen applications.

Hi,
for the Arduino code see the following which worked for me using the Bluefruit EZ-Link:

//send temperature value to a paired Bluetooth device (Bluefruit EZ-Link)
//BTM RX-1 (green) - Arduino Pin D3
//BTM TX-0 (yellow)- Arduino Pin D2

//Temperature
//Dallas DS1820 Temperature Sensor
//Pin 1 left, seen from the legs -> Arduino GND
//Pin 2 middle -> Arduino Digital Pin 4
//Pin 3 right -> Arduino + 5 Volt
//additional 4.7 k Ohm pull-up resistor between Pin 4 and + 5 Volt

//configuration for PuTTY to control Serial
//COM10
//Parity: None
//Flow Control: None
//baud rate: 9600

#include <SoftwareSerial.h>  
#include <DallasTemperature.h>
#include <OneWire.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 4
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

int bluetoothTx = 2;  // TX-O pin of bluetooth mate, Arduino D2
int bluetoothRx = 3;  // RX-I pin of bluetooth mate, Arduino D3

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
  Serial.begin(9600);
  
  bluetooth.begin(115200);  //start talking to Bluefruit EZ-Link with default 115200bps
  bluetooth.print("$$");  // Enter command mode
  
  delay(2000);  // Short delay, wait for the Bluefruit EZ-Link to send back CMD
  
  bluetooth.println("U,9600,N");  // switch to 9600, no parity
  bluetooth.begin(9600);  //start bluetooth serial at 9600 to be compatible with Arduino
}

void loop()
{
  if(bluetooth.available())  //if the bluetooth sent any characters
  {
    //send any characters the bluetooth prints to the serial monitor
    Serial.print((char)bluetooth.read());  
  }
  if(Serial.available())  //if stuff was typed in the serial monitor
  {
    //send any characters the Serial monitor prints to the bluetooth
    bluetooth.println(millis());
    sensors.requestTemperatures(); //send the command to get temperatures

    float currTemp = sensors.getTempCByIndex(0);
    Serial.print(sensors.getTempCByIndex(0));  
    Serial.println(" C");
    bluetooth.println(currTemp);
    delay(5000);
  }
}

Of course you need to change the coding for your pressure sensor.

For the Android part you should refer to the following page where you see detailed code example:
Bluetooth Android

You can test bluetooth communication way more simple:

unsigned long time;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);   // pick the right baudrate, most bluetooth modules have 9600 default
  time = millis();  
}

void loop() {
  // put your main code here, to run repeatedly:  
  if(millis() - time >= 1000){
    Serial.println("Hello Test");  // Here is where we send data, now you just have to get your pressure sensor data and put it in the right format for your application
    time = millis();
  }
}

In order for this to work you need to cross your connection of your bluetooth module to the arduino(bt rx to Arduino serial tx, bt tx to arduino rx). When you do it like this you won´t be able to flash sketches while the bluetooth module is connected, therefore you can use your non-blocking hardware serial. If you want to print out incoming data its nice to have another serial (hard or software), just do something like this:

while(Serial.available() > 0)Serial1.println(Serial.read() )  // Serial 1 is your second serial

cabecinhas: Does anybody here have an Idea about how to send a pressure sensor to a smartphone to use in apps like Altimeter/Variometer Using bluetooth?

The first thing to do is be able to send the data to the serial monitor. Once you have succeeded at that, all you need do is connect the bluetooth to pins 0,1 and use your bluetooth device. Essentially, that's all there is to it. If you want to write software, re-invent the wheel etc., you can do that at the phone end, not Arduino, but before you do, you may find there are sufficient apps already available. I find Bluetooth Graphics Terminal a real gem but I find Bluetooth Terminal better for downloading logged data. All this assumes that by smartphone, you mean Android.

You might find the following background notes useful

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

And here is an complete example how you do it on the Android side in Java: Bluethooth