Can’t send data from arduino to processing via hc05

Hello, I’m trying to send and receive data from my laptop to arduino nano via hc05 Bluetooth for a rocket flight computer. For some reasons which I don’t know, I can send data from processing software using myPort.write() but cannot send a String back from arduino back to processing for telemetry purpose. At some point it was working, then stopped. I tried another code from and still it didn’t work. For some reasns, now its working but im getting junk data(although i can see some expected numbers in the junk data) I’m using the Serial.println function on Hardware serial

Baudrate is at 115200, stop bit 1, parity 0
Does the stop bit or parity bit have anything to do with it?

Pls help

In the processing code, I use all necessary libraries and functions e.g serialEvent(), myPort.bufferUntil(\n), myPort.readStringUntil(‘\n’)

Stripped down arduino code

type or paste code here[code]

void setup() {
  digitalWrite(resetbutton, HIGH);
  prevAltitude = 0;

  pinMode(BlueLed, OUTPUT);
  pinMode(RedLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(Startbutton, INPUT);
  pinMode(readybutton , INPUT);
   pinMode(resetbutton, OUTPUT);
  pinMode(BtState, INPUT);


void loop() {

  int startbutton = digitalRead(Startbutton);
  int Readybutton = digitalRead(readybutton);

  unsigned long currentMillis = millis();

  if (Serial.available() > 0) {   //Save incoming bluetooth  data to variable 'state'
    state =; //read what button is pressed on phone
  if (state == 's'){
    state = 0;

  if ((state == 'r') || (Readybutton == HIGH)) { //if char r is received via bluetooth or Readybutton pressed
    digitalWrite(RedLed, HIGH);
    tone(buzzer, 1200, 1000);
    mode = 1;
    state = 0;

  if (mode == 1) {
    datalogging(); //Set datalogmging to start. 
  if (state== 'R'){
    digitalWrite(resetbutton, LOW);
void Initialization() {
  int delayPeriod = 500;
  servo1.write(130);    //Arm servo to hold the parachute door
  Serial.println("Initializing SD card...");

  if (!SD.begin(chipSelect)) {      // see if the card is present and can be initialized:
    Serial.println("Card failed,or not present");
    digitalWrite(buzzer, HIGH); //if not initialized, Buzzer keeps buzzing
    return; // stops the code from continuing

  digitalWrite(buzzer, LOW);  //Turn off buzzer if SDcard is initialized

  for (i = 0; i < 4; i++)   {
    digitalWrite(BlueLed, HIGH);
    digitalWrite(RedLed, HIGH);
    tone(buzzer, 1000);
  Serial.println("Initialization ok");

Processing code

import processing.serial.*;
Serial myPort;
String stateStatus=" ";;

void setup() {
  size(450, 500); 
  myPort= new Serial(this, "COM8", 115200);
void serialEvent  (Serial myPort) {
  stateStatus= myPort.readStringUntil('\n');

void draw() {
  background(237, 240, 241);

  text("Status:", 80, 280);
  text(stateStatus, 20, 300);

Can't really help without seeing your sketch or your circuit.

1 Like

I'm sorry, I have uploaded the sketch

Update: After trying numerous codes, I was :100: sure that it wasn’t a software problem. I then removed the Hc05 module from the circuit, and I was able to put it in AT mode(this means my module is working fine). This leaves only one possible problem I.e the circuit. I used a multimeter to measure the voltage between Hc05 RX and GND. I got 1.8v(but how?). After retracing the connections, I figured out the problem was with the voltage divide I used to step down 5v to 3.3v. I used a 2k Ohm resistor in place of a 1k, and a 1k in place of the 2k resistor. So that’s why I’m getting a voltage of around 1.8v. Turns out 1.8v is too low for Hc05 rx pin to use. After correcting it, everything works fine​:smiley:

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