user87209: In my code I want to send some float values from my phone to the Arduino's Bluetooth which I will then split using the substring function. it will then print that split value to the serial monitor.
I don't even know what is wrong but there is no error and it just spits out the ascii code of those numbers (not split). Please help if anyone has any idea.
Here is my code:
#include <Wire.h>
#include<SoftwareSerial.h>
#define TxD 3 
#define RxD 2 
SoftwareSerial bluetoothSerial(TxD,RxD);

String Sstring;
String arrayOne;

void setup() 
{
  bluetoothSerial.begin(9600);  
  Serial.begin(9600);
}

void loop() 
{
 
 if(bluetoothSerial.available()>0)
 {
  
  arrayOne=bluetoothSerial.read();
  
  Sstring=arrayOne.substring(0);
  Serial.println(Sstring);
 } 
}


user7508: First thing, you have to decide what data format the phone application
will use for sending the data to the Arduino: define a “language” of
sorts. Then you have to program both the phone and the Arduino to speak
that same language.
Unless the data throughput is critical, I strongly advise you to use a
text-based format, where each “message” is followed by a dedicated
character that signals the end of the message. Popular choices for the
message terminator are '\n' (ASCII line feed, numeric value 0x0a =
10), '\r' (carriage return = 0x0d = 13) and ';' (semicolon = 0x3b =
59). The semicolon is often used as a second-level separator, to split a
message into smaller fields.
Here is a simple example that reads one-line messages, using a line feed
as a delimiter:
void loop() {
    if (bluetoothSerial.available() > 0) {
        String message = bluetoothSerial.readStringUntil('\n');
        Serial.println(message);
    }
}

If you want to send the data as binary, then message framing becomes a
tricky problem. Since every possible byte value can legitimately appear
within the message (any byte can appear within a float), you cannot
simply reserve one byte to serve as a terminator. This is why, unless
you are an advanced programmer, I strongly encourage you to send
whatever data you want to send as text. Text also makes debugging much
easier.
Finally, I have to warn you that the String class is not friendly to
the memory of your Arduino, and can lead to instabilities if used
extensively. If you have time, I encourage you to study the robust way
to read text from the serial port: see the article Reading Serial on
the Arduino, by Majenko.

87209: <p>In my code I want to send some float values from my phone to the Arduino's Bluetooth which I will then split using the substring function. it will then print that split value to the serial monitor.</p>
<p>I don't even know what is wrong but there is no error and it just spits out the ascii code of those numbers (not split). Please help if anyone has any idea.
Here is my code:</p>
<pre><code>#include &lt;Wire.h&gt;
#include&lt;SoftwareSerial.h&gt;
#define TxD 3 
#define RxD 2 
SoftwareSerial bluetoothSerial(TxD,RxD);

String Sstring;
String arrayOne;

void setup() 
{
  bluetoothSerial.begin(9600);  
  Serial.begin(9600);
}

void loop() 
{
 
 if(bluetoothSerial.available()&gt;0)
 {
  
  arrayOne=bluetoothSerial.read();
  
  Sstring=arrayOne.substring(0);
  Serial.println(Sstring);
 } 
}
</code></pre>
 7508: <p>First thing, you have to decide what data format the phone application
will use for sending the data to the Arduino: define a “language” of
sorts. Then you have to program both the phone and the Arduino to speak
that same language.</p>
<p>Unless the data throughput is critical, I strongly advise you to use a
text-based format, where each “message” is followed by a dedicated
character that signals the end of the message. Popular choices for the
message terminator are <code>'\n'</code> (ASCII line feed, numeric value 0x0a =
10), <code>'\r'</code> (carriage return = 0x0d = 13) and <code>';'</code> (semicolon = 0x3b =
59). The semicolon is often used as a second-level separator, to split a
message into smaller fields.</p>
<p>Here is a simple example that reads one-line messages, using a line feed
as a delimiter:</p>
<pre class="lang-cpp prettyprint-override"><code>void loop() {
    if (bluetoothSerial.available() &gt; 0) {
        String message = bluetoothSerial.readStringUntil('\n');
        Serial.println(message);
    }
}
</code></pre>
<p>If you want to send the data as binary, then message framing becomes a
tricky problem. Since every possible byte value can legitimately appear
within the message (any byte can appear within a float), you cannot
simply reserve one byte to serve as a terminator. This is why, unless
you are an advanced programmer, I strongly encourage you to send
whatever data you want to send as text. Text also makes debugging much
easier.</p>
<p>Finally, I have to warn you that the <code>String</code> class is not friendly to
the memory of your Arduino, and can lead to instabilities if used
extensively. If you have time, I encourage you to study the robust way
to read text from the serial port: see the article <a href="https://majenko.co.uk/blog/our-blog-1/reading-serial-on-the-arduino-27" rel="nofollow noreferrer">Reading Serial on
the Arduino</a>, by Majenko.</p>
