I am working on a self-payment car park project and I have to put a rectangle on the screen to help the buyer present problems, I could not write a code for Bluetooth to send and receive messages from Android to Bluetooth and from Bluetooth to Android
Hi @aappaaqq,
welcome to the forum.
You have posted a nice introduction to you and your project.
For beeing able to really help it is nescessary to write more detail-information.
You have to expand on what i really means to
"put a rectangle on the screen to help buyer present problems"
How does this work? How is "putting a rectangle on the screen helping presenting problems"?
If you don't want to learn anything about programming.
This user-forum has a sub-forum Jobs and Paid Consultancy - Arduino Forum
This would be the right place to ask for questions like "can somebody write the complete code for my project?"
Anyway even there interested people would ask for a lot of details.
What type of microcontroller shall be used?
If you don't know yet a lot of following up questions arise to make a good descision.
Now there are basically two ways to go on.
The not recommended way is to not read this thread
the recommended second way will finishing your project minimum one week faster if you are willing to invest
1 hour of time to carefully read and then to carefully write a project description like recommended here
best regards Stefan
have a look at Arduino and HC-06
note that the HC-06 is a 3.3V logic device and if using it with a 5V logic Arduino you require a potential divider as shown in the link (I tend to use an Arduino Due which is a 3.3V device)
what language are you using on the Android? I use Android Studio programming in Java
it may be simpler to use a ESP32 which has builtin Bluetooth and BLE and has a Bluetooth serial library which is easy to use
I useing the c# language for the final search in electronics and I use the Serial bluetooth terminal, this is the bluetooth program on the Android phone, but I find it difficult to write a code to send and receive data
the Arduinos are programmed in C/C++ so C# exprience should help
this is a program I used on an ESP32 to communicate over Bluetooth classic with Serial Bluetooth terminal on an Android phone
// Bluetooth Classic tested with the DOIT ESP32 DEVKIT V1
// see https://randomnerdtutorials.com/esp32-bluetooth-classic-arduino-ide/
// from File > Examples > BluetoothSerial > SerialtoSerialBT
// works ESP32 OK to PC running teraterm and Androd running Serial Bluetooth Terminal
//This example code is in the Public Domain (or CC0 licensed, at your option.)
//By Evandro Copercini - 2018
//
//This example creates a bridge between Serial and Classical Bluetooth (SPP)
//and also demonstrate that SerialBT have the same functionalities of a normal Serial
#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;
void setup() {
while(!Serial);
Serial.begin(115200);
Serial.println("SerialToSerialBT");
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
Serial.write(SerialBT.read());
}
delay(20);
}
the ESP32 appears as Bluetooth device ESP32test - you pair the Android with it and can send text between the devices
once you have basic serial communications working you can modify/update/create your own code to meet the specification
google is always worth a 5 minute search
https://www.google.de/search?as_q=arduino+send+and+receive+data+over+brluetooth
You will get useful answers if you show some own effort.
In your situation you can show some own effort by taking any kind of code and asking a specific question about the code.
Beeing a question what a certain line of code does
or posting the original code and posting code that is modified by you asking for the opinion of the users here or how to improve your modification.
By posting such short postings as you posted above you build up a picture of beeing too lazy to show own effort.
If you go on in this manner you are in danger that the forum member start asking
"Is he trying to hide the explicit command for "write the whole code for me?"
best regards Stefan
i dont know how to send and receiveing masseges from bluetooth to android and from android to bluetooth i use hc-06 and i but (rx,bleutooth)on(tx/D1,arduino) and (tx, bluetooth)on (rx/D0,arduino), and how di i know if the code is correct and work ?
i try to write code but i didnt success
Which Ardiono board are you using ?
Your question is very confused, but it sounds like you have connected the HC-06 to the Tx and Rx pins on the Arduino. Is that what you have done ? If so, it may cause problems depending on which Arduino board you are using.
How is the HC-06 powered ?
Please post your sketch, using code tags when you do
I have merged your cross-posts @aappaaqq.
Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting can result in a suspension from the forum.
In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
As I suspected, you have connected the HC-06 to the hardware Serial pins of the Nano. This is not likely to work as those pins are also used when uploading code and by the Serial monitor
Consider using SoftwareSerial on 2 other pins of your choice.
post your code to show some own effort.
if you are implementing an app for an Android phone the simplest way is probably to use MIT app inventor
if you do a web search for arduino MIT app inventor Blueetooth you will get plenty of links, e.g.
mit-app-inventor-arduino-bluetooth-application discusses connecting a HC-05 to a UNO and communicating with an Android phone
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.