#define power_led 10 byte byteRead; char myChar ; void setup() { pinMode(power_led, OUTPUT); digitalWrite(power_led, LOW); Serial.begin(115200); // set the data rate for the SoftwareSerial port Serial1.begin(38400); //default rate of bluetooth RN4020 is 115200, we changed it for more reliable data over Software serial //There's a good chance you might need to run the commands the first time by setting this to 115200 since that is default /* Initialize Bluetooth Baud to lower speed for Software Serial Serial1.begin(115200); //default rate of bluetooth RN4020 is 115200, delay(500); Serial1.println("SB,0"); // 0 = 2400 Baud 1 = 9600 baud 2= 19200 baud 4 = 115200 baud (default) delay(500); Serial1.println("R,1"); //Reboot delay(1000); */ //Always nice to let it chill a bit delay(1000); //BLUETOOTH SETUP //Initialize BT RN4020 Serial1.println("SB,3");// Serial Baudrate 38400 delay(500); //Set as central or as a peripheral device //Serial1.println("SR,20000000"); //Set device in peripheral mode and set turn on auto advertising Serial1.println("SR,80004000");// Set device as central, support MLDP and enable y Apple Bueetooth delay(500); Serial1.println("SS,20000000");// Set device as Heart Rate delay(500); Serial1.println("ST,0064,0002,0064");// Set the interval to 125 ms, latency to 2, and time-out to 1 second delay(500); //Change the name that's displayed, this is always a good first thing to check in your debugging Serial1.println("S-,HYBRID"); delay(500); //Reboot the sucker to make the changes stick. the light should turn off when you reboot (also good for debugging) Serial1.println("R,1"); //Reboot delay(2000); //Make the device show up on scanners Serial1.println("A"); //Start advertising delay(500); //List all the details about the Buetooth device (what it's connected to, it's Mac address, etc. Serial1.println("D"); //Get details of the RN4020 chip's current status } void loop() { //This code below will let everything on your arduino's Software Serial talk to the hardware serial //So you can see it all through while (Serial1.available()) { myChar = Serial1.read(); Serial.print(myChar); } // delay(500); // wait for a second while (Serial.available()) { myChar = Serial.read(); Serial1.print(myChar); } }