hi
ineed to showing sensors data on my android app
const int sensor1=A0; // Assigning analog pin A0 to variable 'sensor'
float tempc1; //variable to store temperature in degree Celsius
float tempvalue1; //temporary variable to hold sensor reading
const int sensor2=A1; // Assigning analog pin A1 to variable 'sensor'
float tempc2; //variable to store temperature in degree Celsius
float tempvalue2;
const int sensor3=A2; // Assigning analog pin A2 to variable 'sensor'
float tempc3; //variable to store temperature in degree Celsius
float tempvalue3;
/* Simple example code for Force Sensitive Resistor (FSR) with Arduino */
int FSRsensor1=A3;// Assigning analog pin A3 to variable 'sensor' //Variable to store FSR value
int fsrVoltage1; // the analog reading converted to voltage
unsigned long fsrresistance1; // The voltage converted to resistance, can be very big so make "long"
unsigned long fsrConductance1;
float FSRforce1; // The resistance converted to force.
float weight1; // The force converted to weight.
/* Simple example code for Force Sensitive Resistor (FSR) with Arduino */
int FSRsensor2=A4;// Assigning analog pin A4 to variable 'sensor' //Variable to store FSR value
int fsrVoltage2; // the analog reading converted to voltage
unsigned long fsrresistance2; // The voltage converted to resistance, can be very big so make "long"
unsigned long fsrConductance2;
float FSRforce2; // The resistance converted to force.
float weight2; // The force converted to weight.
/* Simple example code for Force Sensitive Resistor (FSR) with Arduino */
int FSRsensor3=A5;// Assigning analog pin A3 to variable 'sensor' //Variable to store FSR value
int fsrVoltage3; // the analog reading converted to voltage
unsigned long fsrresistance3; // The voltage converted to resistance, can be very big so make "long"
unsigned long fsrConductance3;
float FSRforce3; // The resistance converted to force.
float weight3; // The force converted to weight.
#include <SoftwareSerial.h>
SoftwareSerial BTserial(0, 1); // RX | TX
void setup() {
pinMode(sensor1,INPUT); // Configuring pin A0 as input
Serial.begin(9600);
pinMode(sensor2,INPUT); // Configuring pin A1 as input
Serial.begin(9600);
pinMode(sensor3,INPUT); // Configuring pin A2 as input
Serial.begin(9600);
pinMode(FSRsensor1,INPUT); // Configuring pin A3 as input
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
pinMode(FSRsensor2,INPUT); // Configuring pin A3 as input
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
pinMode(FSRsensor3,INPUT); // Configuring pin A3 as input
// Begin serial communication at a baud rate of 9600:
Serial.begin(9600);
// HC-06 default serial speed is 9600
BTserial.begin(9600);
}
void loop() {
tempvalue1=analogRead(sensor1);
tempvalue1=(tempvalue1*500)/1023;
tempc1=tempvalue1; // Storing value in Degree Celsius
Serial.print("temp 1 in DegreeC =");
Serial.print("\t");
Serial.print(tempc1);
Serial.println();
delay(5000); //Delay of 5 second for ease of viewing
tempvalue2=analogRead(sensor2);
tempvalue2=(tempvalue2*500)/1023;
tempc2=tempvalue2; // Storing value in Degree Celsius
Serial.print("temp 2 in DegreeC =");
Serial.print("\t");
Serial.print(tempc2);
Serial.println();
delay(5000); //Delay of 5 second for ease of viewing
tempvalue3=analogRead(sensor3);
tempvalue3=(tempvalue3*500)/1023;
tempc3=tempvalue3; // Storing value in Degree Celsius
Serial.print("temp 3 in DegreeC =");
Serial.print("\t");
Serial.print(tempc3);
Serial.println();
delay(5000); //Delay of 5 second for ease of viewing
// Read the FSR pin and store the output as fsrreading:
int fsrreading1 = analogRead(FSRsensor1);
// Print the fsrreading in the serial monitor:
// Print the string "Analog reading = ".
Serial.print("FSR1 = ");
Serial.print("\t");
// Print the FSR1:
Serial.print(fsrreading1);
Serial.println();
// analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
fsrVoltage1 = map(fsrreading1, 0, 1023, 0, 5000);
Serial.print("Voltage reading in mV = ");
Serial.println(fsrVoltage1);
if (fsrVoltage1 == 0) {
Serial.println("No pressure");
} else {
// The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
// so FSR = ( (Vcc - V) * R) / V
// fsrVoltage is in millivolts so 5V = 5000mV
fsrresistance1 = 5000 - fsrVoltage1;
fsrresistance1 *= 10000; // 10K resistor
fsrresistance1 /= fsrVoltage1; // FSR resistance in ohms.
fsrConductance1 = 1000000; //We measure in micromhos.
fsrConductance1 /= fsrresistance1; //Conductance in microMhos.
// Calculate the force.
FSRforce1 = fsrConductance1 / 80.00;
Serial.print("force in Newton =");
Serial.print("\t");
Serial.print(FSRforce1);
Serial.println();
weight1 = FSRforce1 / 9,8;
Serial.print("weight in Kg =");
Serial.print("\t");
Serial.print(weight1);
Serial.println();
}
delay(500); //Delay 500 ms.
// Read the FSR pin and store the output as fsrreading:
int fsrreading2 = analogRead(FSRsensor2);
// Print the fsrreading in the serial monitor:
// Print the string "Analog reading = ".
Serial.print("FSR2 = ");
Serial.print("\t");
// Print the FSR2:
Serial.print(fsrreading2);
Serial.println();
// analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
fsrVoltage2 = map(fsrreading2, 0, 1023, 0, 5000);
Serial.print("Voltage reading in mV = ");
Serial.println(fsrVoltage2);
if (fsrVoltage2 == 0) {
Serial.println("No pressure");
} else {
// The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
// so FSR = ( (Vcc - V) * R) / V
// fsrVoltage is in millivolts so 5V = 5000mV
fsrresistance2 = 5000 - fsrVoltage2;
fsrresistance2 *= 10000; // 10K resistor
fsrresistance2 /= fsrVoltage2; // FSR resistance in ohms.
fsrConductance2 = 1000000; //We measure in micromhos.
fsrConductance2 /= fsrresistance2; //Conductance in microMhos.
// Calculate the force.
FSRforce2 = fsrConductance2 / 80.00;
Serial.print("force in Newton =");
Serial.print("\t");
Serial.print(FSRforce2);
Serial.println();
weight2 = FSRforce2 / 9,8;
Serial.print("weight in Kg =");
Serial.print("\t");
Serial.print(weight1);
Serial.println();
}
delay(500); //Delay 500 ms.
// Read the FSR pin and store the output as fsrreading:
int fsrreading3 = analogRead(FSRsensor3);
// Print the fsrreading in the serial monitor:
// Print the string "Analog reading = ".
Serial.print("FSR3 = ");
Serial.print("\t");
// Print the FSR3:
Serial.print(fsrreading3);
Serial.println();
// analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV)
fsrVoltage3 = map(fsrreading3, 0, 1023, 0, 5000);
Serial.print("Voltage reading in mV = ");
Serial.println(fsrVoltage3);
if (fsrVoltage3 == 0) {
Serial.println("No pressure");
} else {
// The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V
// so FSR = ( (Vcc - V) * R) / V
// fsrVoltage is in millivolts so 5V = 5000mV
fsrresistance3 = 5000 - fsrVoltage1;
fsrresistance3 *= 10000; // 10K resistor
fsrresistance3 /= fsrVoltage3; // FSR resistance in ohms.
fsrConductance3 = 1000000; //We measure in micromhos.
fsrConductance3 /= fsrresistance3; //Conductance in microMhos.
// Calculate the force.
FSRforce3 = fsrConductance3 / 80.00;
Serial.print("force in Newton =");
Serial.print("\t");
Serial.print(FSRforce3);
Serial.println();
weight3 = FSRforce3 / 9,8;
Serial.print("weight in Kg =");
Serial.print("\t");
Serial.print(weight3);
Serial.println();
}
delay(500); //Delay 500 ms.
// Keep reading from Arduino Serial Monitor and send to HC-06
if (Serial.available())
{
BTserial.write(Serial.read());
}
//Write sensor data to HC06
BTserial.println(tempc1);
delay(100);
}
please help me please