sending data with bluetooth

Hello everyone i have two problem,
the first is I want to turn on my circuit through bluetooth, how can I avoid this problem? I intended to send a signal "high" on a relay through bluetooth on a digital pin, I have unfortunately not available to the relay, it might work?

The second problem is this: when i sending the command "C", he gives me a read-only and it stops, but I want to continue to give me the values that detects, what can i solve?:frowning:

void loop() {
  {
   while (mySerial.available())
   {
       char dato= mySerial.read(); 
       switch(dato)
       {
         case 'C': 
         {
           unsigned long Somma = 0;

  for (byte i = 0; i < 10; i ++) {
    Somma += analogRead(A0);
    delayMicroseconds(160);
  }
   Somma /= 10;
 
  GradiK =  Somma * 500 / 1023.0;
  GradiC = GradiK - 248;
  GradiF = (GradiC * 9.0 / 5.0) + 32.0;
  delay(500);
 mySerial.print(GradiC);
 mySerial.println("°C ");
}

guixi:
the first is I want to turn on my circuit through bluetooth, how can I avoid this problem?

I assume English is a second language and you want to turn on an Arduino in response to a signal from a Bluetooth device.

This is a bluetooth problem, not an Arduino problem, but I believe it is possible to do it using the appropriate AT command. I believe the signal would simply be the connection, not data, and, once made, Arduino can be fed the data.

The snippet of code in your original post is not even a complete snippet - there are missing }} - so I have no idea where the problem might be.

Post the complete program.

You may find useful stuff in serial input basics

...R

#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 4); // RX, TX
float GradiK = 0.0;
float GradiC = 0.0;
float GradiF = 0.0;

void setup() {
 mySerial.begin(9600);
}

void loop() {
  {
   while (mySerial.available())
   {
       char dato= mySerial.read(); 
       switch(dato)
       {
         case 'C': 
         {
           unsigned long Somma = 0;

  for (byte i = 0; i < 10; i ++) {
    Somma += analogRead(A0);
    delayMicroseconds(160);
  }
   Somma /= 10;
 
  GradiK =  Somma * 500 / 1023.0;
  GradiC = GradiK - 248;
  GradiF = (GradiC * 9.0 / 5.0) + 32.0;
  delay(500);
 mySerial.print(GradiC);
 mySerial.println("°C ");
}
}
}
}
}

I want a continuous reading,
with this code when i send 'C' it return to me only one value
like this
20 ° C

instead I want
20 ° C
20 ° C
20 ° C
20 ° C
20 ° C
20 ° C

You get ONE read because You send ONE 'C'.

When You do a mySerial.read() the byte is removed from buffer so no more bytes are available() unless You send another one.

I have tidied up your code a little bit (hope I have not broken anything)

#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 4); // RX, TX
float GradiK = 0.0;
float GradiC = 0.0;
float GradiF = 0.0;

void setup() {
	mySerial.begin(9600);
}

void loop()
{
	 while (mySerial.available())
	 {
		 char dato= mySerial.read();
		 switch(dato)
		 {
			 case 'C':
				unsigned long Somma = 0;

				for (byte i = 0; i < 10; i ++) {
					Somma += analogRead(A0);
					delayMicroseconds(160);
				}
				Somma /= 10;

				GradiK =  Somma * 500 / 1023.0;
				GradiC = GradiK - 248;
				GradiF = (GradiC * 9.0 / 5.0) + 32.0;
				delay(500);
				mySerial.print(GradiC);
				mySerial.println("°C ");
				break;
		}
	}
}

As written your code will send the temperature once for every time the Arduino receives 'C'

I don't understand exactly what alternative behaviour you want.

Your system for receiving data is not very reliable. Have a look at the examples in serial input basics.

...R