Hello everyone,
I am trying exaustly to send a simple text from kodular to my esp32 by Bluetooth.
What makes me confuse is that I can do it using Serial Bluetooth Terminal on my phone very easily and works. But it make me think if there is any diference version format to use bluetooth with kodular. Something to classic ou BLE bluetooth or maybe the Espwroom32 incompatibility.
I´m just blinking a simple led to begin my project but I´m stuck. It shows bluetooth conection sucessfully but when I click the button to send the text “a” nothing happends like this command was unterminated.
Does any one knows anything could help me?
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
int received;// received value will be stored in this variable
char receivedChar;// received value will be stored as CHAR in this variable
int turnON ='a';
int turnOFF ='b';
int LEDpin = 2;
char Tempo14Giro = 0;
char Tempototal14giro = 0;
char TempoAltMax = 0;
char TempoGirando = 0;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32_Teste Novo"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
Serial.println("To turn ON send: a");//print on serial monitor
Serial.println("To turn OFF send: b"); //print on serial monitor
pinMode(LEDpin, OUTPUT);
}
void loop() {
receivedChar =(char)SerialBT.read();
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
SerialBT.print("Received:");// write on BT app
SerialBT.println(receivedChar);// write on BT app
Serial.print ("Received:");//print on serial monitor
Serial.println(receivedChar);//print on serial monitor
//SerialBT.println(receivedChar);//print on the app
//SerialBT.write(receivedChar); //print on serial monitor
if(receivedChar == turnON)
{
SerialBT.println("LED ON:");// write on BT app
Serial.println("LED ON:");//write on serial monitor
digitalWrite(LEDpin, HIGH);// turn the LED ON
Serial.println("Ligado");
}
if(receivedChar == turnOFF)
{
SerialBT.println("LED OFF:");// write on BT app
Serial.println("LED OFF:");//write on serial monitor
digitalWrite(LEDpin, LOW);// turn the LED off
Serial.println("Desligado");
}
}
delay(20);