Error 'no matching function' while uploading the code

Hi. I want to control LED by android app. But when I verify the code an error is displayed. this is my code:

#include "BluetoothSerial.h"

BluetoothSerial SerialBT;

const int ledpin = 2;

void setup() {
SerialBT.begin("ESP8266-Bluetooth"); //Bluetooth device name
pinMode(ledpin, OUTPUT);
}

void loop() {
//Read character
if (SerialBT.available()) {
  char c = SerialBT.read();
  if(c=='1'){
    digitalWrite(ledpin,HIGH);
  }
  else if (c=='0'){
    digitalWrite(ledpin,LOW);
  }
}
}

And this is the error message:











sketch_aug07b:3:17: error: no matching function for call to 'BluetoothSerial::BluetoothSerial()'
 BluetoothSerial SerialBT;
                 ^~~~~~~~
In file included from C:\Users\javadi\Documents\Arduino\sketch_aug07b\sketch_aug07b.ino:1:0:
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:42:5: note: candidate: BluetoothSerial::BluetoothSerial(HardwareSerial&, bool)
     BluetoothSerial(HardwareSerial& serial, bool verbose = true);
     ^~~~~~~~~~~~~~~
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:42:5: note:   candidate expects 2 arguments, 0 provided
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:17:7: note: candidate: constexpr BluetoothSerial::BluetoothSerial(const BluetoothSerial&)
 class BluetoothSerial {
       ^~~~~~~~~~~~~~~
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:17:7: note:   candidate expects 1 argument, 0 provided
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:17:7: note: candidate: constexpr BluetoothSerial::BluetoothSerial(BluetoothSerial&&)
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:17:7: note:   candidate expects 1 argument, 0 provided
C:\Users\javadi\Documents\Arduino\sketch_aug07b\sketch_aug07b.ino: In function 'void loop()':
sketch_aug07b:14:14: error: 'class BluetoothSerial' has no member named 'available'
 if (SerialBT.available()) {
              ^~~~~~~~~
sketch_aug07b:15:21: error: 'class BluetoothSerial' has no member named 'read'
   char c = SerialBT.read();
                     ^~~~
exit status 1
no matching function for call to 'BluetoothSerial::BluetoothSerial()'

What is your processor? Esp32?

No. Its Arduino uno

If you have bluetooth module, first use the library examples.

I use HC-05 bluetooth module and Arduino uno board

Try this library and example.

I used this example to control my led but the android app can't recognize the Bluetooth name 'ESP32-Bluetooth'. I used ESP8266 and HC-05.


When I press devices list button no thing is displayed.
I edited the code as bellow:

#include "BluetoothSerial.h"

#define bluetoothModuleSerial Serial1
BluetoothSerial blueSerial(bluetoothModuleSerial, true);

const int ledpin = 16;

void setup() {
Serial1.begin("ESP32-Bluetooth"); //Bluetooth device name
    bluetoothModuleSerial.begin(9600);
}

void loop() {
      blueSerial.readSerial();

if (Serial1.available()) {
  char c = Serial1.read();
  if(c=='1'){
    digitalWrite(ledpin,HIGH);
  }
  else if (c=='0'){
    digitalWrite(ledpin,LOW);
  }
}
}

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