0
votes

I have an App that is, besides other things, supposed to alert when the Fire Alarm that I have on my project is triggered. The sensor is a thermistor and it activates a blinking led and a buzzer when the data it is getting is >700. I am using Bluetooth (HC-05) for my connection. I already have on the app a temperature sensor that is supposed to work independently and the readings from the Arduino are already being received, so I can´t mix the values (receive text number of bytes already being used). I was thinking of, e.g. when the led is blinking (meaning that the fire alarm is triggered), it sends some kind of info to the app that notifies me through an extension and the internal Notifier, without entering in conflict with the other blocks.`

visual aspect of app`

blocks of app

[code]
#include <SoftwareSerial.h>

SoftwareSerial BT(10, 11); //TX, RX respetively
float temp;
float seno;
int frequencia;
float temptermistor;
String state;// string to store incoming message from bluetooth

void setup() {

BT.begin(9600);// bluetooth serial communication will happen on pin 10 and 11
  Serial.begin(9600); // serial com. to check the data on serial monitor
pinMode(A0, INPUT); //temperatura
pinMode(A1, INPUT); //termistor
pinMode(9, OUTPUT); //led alarme
pinMode(13, OUTPUT); //buzzer
}

void loop() {
temp = analogRead(A0);
delay(200);
temp = analogRead(A0);
temp = temp * 0.48828125;
temptermistor = analogRead(A1);
delay(10);
temptermistor = analogRead(A1);
delay(10);
Serial.println(temp);
BT.println(temp);
delay(250);
if (temptermistor >= 700)
{ 
digitalWrite(9, HIGH);
delay(50);
digitalWrite(9, LOW);
delay(50);
for(int x=0;x<180;x++){ //converte graus para rad. e obtém o valor do seno
seno=(sin(x*3.1416/180)); //gera uma frequência a partir do valor do seno
frequencia = 2000+(int(seno*1000));
tone(13,frequencia);
delay(2);
}
}
else
{
noTone(13);
}
while (BT.available()){  //Check if there is an available byte to read
delay(10); //Delay added to make thing stable 
char c = BT.read(); //Conduct a serial read
state += c; //build the string- either "On" or "off"
}  
if (state.length() > 0) {



if(state == "A") 
{
digitalWrite(2, HIGH);

  } 

else if(state == "a") 
{
digitalWrite(2, LOW);
 }
if(state == "B") 
{
digitalWrite(3, HIGH);

  } 

else if(state == "b") 
{
digitalWrite(3, LOW);
 }
if(state == "C") 
{
digitalWrite(4, HIGH);

  } 

else if(state == "c") 
{
digitalWrite(4, LOW);
 }
if(state == "D") 
{
digitalWrite(5, HIGH);

  } 

else if(state == "d") 
{
digitalWrite(5, LOW);
 }
if(state == "E") 
{
digitalWrite(6, HIGH);

  } 

else if(state == "e") 
{
digitalWrite(6, LOW);
 }
if(state == "F") 
{
digitalWrite(7, HIGH);

  } 

else if(state == "f") 
{
digitalWrite(7, LOW);
 }
if(state == "G") 
{
digitalWrite(8, HIGH);

  } 

else if(state == "g") 
{
digitalWrite(8, LOW);
 }
if(state == "H") 
{
digitalWrite(12, HIGH);

  } 

else if(state == "h") 
{
digitalWrite(12, LOW);
 }


state ="";}
}
[/code]
1
So whats your problem? - Sandun Isuru Niraj
How can I send information to the app to send a notification, without entering in conflict with the already receiving data from the temperature sensor? - Francisco Ribeiro

1 Answers

1
votes

For sending the Temperature value and notification message you can use delimiter as like & or some kind of symbol in the BT.println();.

Try something like this

BT.print(temp);
BT.print("&");
BT.println("notification");

When you see the output in Bluetooth terminal you can see output like this.

temp&notification
temp&notification

Then at the Mobile App capture that output and break it from the & symbol. then you can grab the two variables.

You can refer these tutorials. 1 2 3