Sending more than one digit with HC06

I was trying to make a thermostat with bluetooth controlled trigger point but I have encouraged with some problems.
I can't send to digit at the same time to arduino .( it receives 2 and 0 individually not 20)
Neither int nor float made any difference.

I need to being able to sent 20 not this
image

#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

#include <SoftwareSerial.h>
SoftwareSerial bt_modul(7, 8);  // RX,TX

#include <Wire.h>
float susica;
char a;
char targettemp= 24 ;
//int targettemp ;

void setup() {
  pinMode(6, OUTPUT);

  Serial.begin(9600);
  bt_modul.begin(9600);
  sensors.begin();
  bt_modul.println("bslior");

  Serial.println("bslior");
}

void loop() {
  sensors.requestTemperatures();
  susica = sensors.getTempCByIndex(0);
  bt_modul.println(susica);
  Serial.println(susica);
  /*if (susica > targettemp) {
     Serial.println("chancing");
    digitalWrite(6, HIGH);// To test bluetooth functions
    delay(60000);
    digitalWrite(6, LOW);
  }
  */
  if (bt_modul.available()) {
    targettemp = bt_modul.read();
    delay(50);
  }
  Serial.println(targettemp);
}

This reads one character. See the Serial Input Basics tutorial on this forum for an overview of serial data collection.

I can't modify the code to receiving data from bluetooth rather than serial monitor
can you send a example

The Serial input basics tutorial has examples. It really shows good robust ways to receive and parse serial data.

The goal for this forum is helping members that want to learn and grow in programming. It's not free gift fixing toys shop.
IDE examples, Arduino/reference are great sources to find out things quickly instead of waiting for replies.

Examples are in the Serial Input Basics tutorial.

Turns out there is a different function to fullfill my project

.parseInt

I am pretty sure all of the " go check this stuff " replayers didn't know that the tutorial they sent to me doesn't mention this basic function to make faster codes.
Funny thing , I don't need a fast code and the tutorial was way beyond my both knowledge and requirement to make this project

so yeah i changed

targettemp = bt_modul.read(); 
//to
targettemp = bt_modul.parseInt();

now everyting' fine also i find this dude's video to make faster codes

https://www.youtube.com/watch?v=tlMbca59Q-M

The basic parseInt() and parseFloat functions in the Serial class don't work very well. They are very limited, and are blocking, unreliable and fail with timeouts. But if that works for you, great!

The reason that I did kot mention parseInt() is not because I don't know about it. I know about readString(), too, but I know enough to not recommend it either.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.