The goal is to communicate between RPi3 and the Arduino with bluetooth.
I'm running it with this code:
#include <SoftwareSerial.h>
char data = 0; //Variable for storing received data
void setup()
{
Serial.begin(9600); //Sets the baud for serial data transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}
void loop()
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data & store into data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n");
if(data == '1') // Checks whether value of data is equal to 1
digitalWrite(13, HIGH); //If value is 1 then LED turns ON
else if(data == '0') // Checks whether value of data is equal to 0
digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
}
The problem is I can't find my HC12 module with my Android or my Raspberry PI.
Any help would be apreciated!
Your code is either junk, or it is incomplete - or possibly both. You have called for Software serial but you are not using it.
Your procedure to use Android is probably very different to that for Raspberry Pi. I assume Raspberry doesn't have a master bluetooth built-in and you need another like that on Arduino, and they both need to be configured to talk to each other. Have you done that? Bluetooth does/should not need to be configured to talk to Android. Can Android see it when the power is connected?
I suggest you leave Raspberry out of the game until you know what you are doing.
All of the above assumes that your "HC-12 bluetooth module" is indeed a bluetooth module, and I'm not sure about that. If in fact it isn't, I guess that goes quite some way to explain why Android cannot see it.
Some resellers claim HC-12 is Bluetooth but in fact, it's NOT. So that's logical you can't see it on Android.
If you want to control a "robot" (eg) at long distance, you have to build 2 devices: one for the robot with the HC-12 and a second one, near the Android, which have a HC-12 (so receving data from the robot) and a HC-05 (which is a real Bluetooth module) to communicate with the Android.