How to troubleshoot, breadboard worked, prototype doesn't

I'm using an HC-05 Bluetooth module connected to an Arduino Nano Every to send sensor data to my android phone using App Inventor. I have successfully written the code for the Nano Every and the Android phone and breadboarded the hardware. All was good until I created the actual prototype. Now it seems that data is not being sent out from the HC-05 and therefore the data is not displayed on the phone. I have done as much troubleshooting as I know how and am at a loss as to what is wrong. I am using a potentiometer to simulate the analog pressure sensor for one of three sensors and am using SoftwareSerial to activate pins 10 and 11 for Rx and Tx respectively. The Nano and HC-05 are the same units used in the breadboard. Here's my simple schematic:

When I use a terminal program rather than my phone, I can connect to the HC-05 but there is no data displayed on the terminal. I disconnected the Tx and Rx wires to the Nano and shorted them together. The HC-05 responded with whatever I typed in through the terminal so it seems the HC-05 is working properly.

Here's my Nano code with only the necessary lines included since my code is fairly bloated. This will make it easier to read.


#include <SoftwareSerial.h>   //Allows use of pins 10/11 for Tx/Rx instead of 0,1
/* RX is digital pin 10 (connect to TX of HC-05)
 * TX is digital pin 11 (connect to RX of HC-05)*/
 SoftwareSerial mySerial(10, 11); // RX, TX
.
.
.
  int Fpin = A0;                     //Connect Fresh Water transduer to pin A0
  int Gpin = A1;                     //Connect Grey Water transduer to pin A1
  int Bpin = A2;                     //Connect Black Water transduer to pin A2

/*****************************************************************************/

void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);  //initializes software serial
  Serial.println(fileName);
  pinMode(Fpin, INPUT);
  pinMode(Gpin, INPUT);
  pinMode(Bpin, INPUT);
}


void loop()
{

     FreshWaterDetail();
     GreyWaterDetail();
     BlackWaterDetail();




 // Send data to HC-05

  String vals = String(int(FPercentheightinTank)) + "#" + String(int(GPercentheightinTank))
  + "#" + String(int(BPercentheightinTank));  //needed to send all data to HC-05 at once

   mySerial.println(vals); //prints to software serial

  Serial.print("1st FreadIndex = ");
  Serial.print(FreadIndex);
  Serial.print(" FPercentheightinTank = ");
  Serial.print(FPercentheightinTank);
  Serial.print(" Freading = ");
  Serial.print(analogRead(Fpin));
  Serial.print(" String = ");
  Serial.println(vals);   //prints to serial monitor

}


//*********************Subroutines****************************************
//************************************************************************


void FreshWaterDetail()   //Calculates percent full
{
.
.
.
}

void GreyWaterDetail()   //Calculates percent full
{
.
.
.
 }
void BlackWaterDetail()   //Calculates percent full
{
.
.
.
}

Can you suggest how to troubleshoot? Can I disconnect the wires to Pins 10 and 11 and connect to pins 0,1 (through a voltage divider to the Rx on the HC-05) using the same code except using only Serial.println(vals)) to see if that works?

Thanks for your help.

I think that your problem resides in the hardware, not the software. How do you power the breadboard and the prototype versions?

Request to kindly share full code
Have u check HC-05 earlier like turning on and of led using Bluetooth or not

So a detailed photograph of that might be a good idea.

Good one !
How about loading an empty sketch onto the Nano and using it as a USB to TTL, connecting TX to TX & RX to Voltage divider to RX, and use the Serial monitor to send data to the HC-05

Just a thought. Could it be that the HC-05 is not set to 9600bps anymore ? That would explain why it still communicates with itself, but not with the Nano anymore.

Power through the USB port until all is working, then 12V into Vin but I haven't used the Vin route yet on the prototype.

OK, but as I said, I think it is bloated. It is to measure liquid amounts in RV tanks, fresh, grey and black water.

char fileName[ ] = "Camper 2.1";
/********************************************
 * Rev 2.1 combines Camper 2.0.2 with Boat monitor part of
 * freshwater tank code
 * Sends percentage to full number (ie x10) to HC-05
 */
#include <SoftwareSerial.h>   //Allows use of pins 10/11 for Tx/Rx instead of 0,1
/* RX is digital pin 10 (connect to TX of HC-05)
 * TX is digital pin 11 (connect to RX of HC-05)*/
 SoftwareSerial mySerial(10, 11); // RX, TX


// F = fresh water,G = grey water, B = black water  :
  float FsensorRange = 12.06;   //pressure range for sensor converted from kPa to inches
  float GsensorRange = 12.06;   //pressure range for sensor converted from kPa to inches
  float BsensorRange = 12.06;   //pressure range for sensor converted from kPa to inches

  float FsensorToTankTop = 10.375;    //distance in inches from tank Top to snensor at zero pressure
  float GsensorToTankTop = 10.375;    //distance in inches from tank Top to snensor at zero pressure
  float BsensorToTankTop = 10.375;    //distance in inches from tank Top to snensor at zero pressure

  float FpercentSensorInchRange;  //% of 12.06 max range of sensor that the top of the tabk is from sensor
  float GpercentSensorInchRange;  //% of 12.06 max range of sensor that the top of the tabk is from sensor
  float BpercentSensorInchRange;  //% of 12.06 max range of sensor that the top of the tabk is from sensor

  float FmaxPinAtTankTop;   //Pin value at top of tank
  float GmaxPinAtTankTop;   //Pin value at top of tank
  float BmaxPinAtTankTop;   //Pin value at top of tank

  float FmaxVoltageAtTankTop;   //Voltage at top of tank
  float GmaxVoltageAtTankTop;   //Voltage at top of tank
  float BmaxVoltageAtTankTop;   //Voltage at top of tank

  int FmaxPinValueRange = 921;  //at 3kPa, 12.06inches and 4.5 volts, pin value is 920 (ie 4.5*1023/5)
  int GmaxPinValueRange = 921;  //at 3kPa, 12.06inches and 4.5 volts, pin value is 920 (ie 4.5*1023/5)
  int BmaxPinValueRange = 921;  //at 3kPa, 12.06inches and 4.5 volts, pin value is 920 (ie 4.5*1023/5)

  int Fbase = 102;  //0 pressure at sensor pin value, ie .5V*1023/5V
  int Gbase = 102;  //0 pressure at sensor pin value, ie .5V*1023/5V
  int Bbase = 102;  //0 pressure at sensor pin value, ie .5V*1023/5V

  int FmaxPinValue;  //Pin Value at top of tank
  int GmaxPinValue;  //Pin Value at top of tank
  int BmaxPinValue;  //Pin Value at top of tank

  float FmaxPinVoltage;  //Voltage when level is at top of tank
  float GmaxPinVoltage;  //Voltage when level is at top of tank
  float BmaxPinVoltage;  //Voltage when level is at top of tank

  float FpercentValueIs;  //% of range from sensor to tank top that value read is
  float GpercentValueIs;  //% of range from sensor to tank top that value read is
  float BpercentValueIs;  //% of range from sensor to tank top that value read is

  float FtankHeight = 12.375;  // Total height of tank
  float GtankHeight = 12.375;  // Total height of tank
  float BtankHeight = 12.375;  // Total height of tank

  float FheightinTank;  //Calculated level above sensor
  float GheightinTank;  //Calculated level above sensor
  float BheightinTank;  //Calculated level above sensor

  float FPercentheightinTank;  //Calculated level above bottom of tank
  float GPercentheightinTank;  //Calculated level above bottom of tank
  float BPercentheightinTank;  //Calculated level above bottom of tank

  int FsensorValue;   //Pin value of sensor output
  int GsensorValue;   //Pin value of sensor output
  int BsensorValue;   //Pin value of sensor output

  float Fvoltage;   //Calculated value of voltage of sensor output
  float Gvoltage;   //Calculated value of voltage of sensor output
  float Bvoltage;   //Calculated value of voltage of sensor output

  float FabsHeight;  //Absolute value in inches from bottom of tank
  float GabsHeight;  //Absolute value in inches from bottom of tank
  float BabsHeight;  //Absolute value in inches from bottom of tank

  const int FnumReadings = 100;  //number of readings to be averaged
  const int GnumReadings = 100;  //number of readings to be averaged
  const int BnumReadings = 100;  //number of readings to be averaged

  int FreadingsArray[FnumReadings];      // the readings from the analog input
  int GreadingsArray[GnumReadings];      // the readings from the analog input
  int BreadingsArray[BnumReadings];      // the readings from the analog input

  int FreadIndex = 0;              // the index of the current reading
  int GreadIndex = 0;              // the index of the current reading
  int BreadIndex = 0;              // the index of the current reading

  float Ftotal = 0;                  // the running total
  float Gtotal = 0;                  // the running total
  float Btotal = 0;                  // the running total

  int FaveSensor = 0;                // the average
  int GaveSensor = 0;                // the average
  int BaveSensor = 0;                // the average

  int FgoodAveFlag = 0;              //when first turned on, a final average is arrived at
  int GgoodAveFlag = 0;              //when first turned on, a final average is arrived at
  int BgoodAveFlag = 0;              //when first turned on, a final average is arrived at

  int Fpin = A0;                     //Connect Fresh Water transduer to pin A0
  int Gpin = A1;                     //Connect Grey Water transduer to pin A1
  int Bpin = A2;                     //Connect Black Water transduer to pin A2

/*****************************************************************************/

void setup()
{

  //init pins

  // initialize all the readings to 0 for average
  for (int BthisReading = 0; BthisReading < BnumReadings; BthisReading++) {
    BreadingsArray[BthisReading] = 0;
  }
  Serial.begin(9600);
  mySerial.begin(9600);  //initializes software serial
  Serial.println(fileName);
  pinMode(Fpin, INPUT);
  pinMode(Gpin, INPUT);
  pinMode(Bpin, INPUT);
}


void loop()
{

 // delay (1000);

     FreshWaterDetail();
     GreyWaterDetail();
     BlackWaterDetail();



 //For testing with only one pot to simulate transducer:

/* if (FPercentheightinTank+25 >= 100)
 {
    GPercentheightinTank = 100;
 }
    else
    {
      GPercentheightinTank = FPercentheightinTank + 25;
    }
   if (FPercentheightinTank+50 >= 100)
 {
    BPercentheightinTank = 100;
 }
    else
    {
      BPercentheightinTank = FPercentheightinTank + 50;
    }
*/
 // Send data to HC-05

  String vals = String(int(FPercentheightinTank)) + "#" + String(int(GPercentheightinTank))
  + "#" + String(int(BPercentheightinTank));  //needed to send all data to HC-05 at once

 /*  if(FgoodAveFlag == 0)
   {                               // Do nothing
   }
   else
    {
      delay(500);                   // else add a delay
    }
   */
   mySerial.println(vals); //prints to software serial

  Serial.print("1st FreadIndex = ");
  Serial.print(FreadIndex);
  Serial.print(" FPercentheightinTank = ");
  Serial.print(FPercentheightinTank);
  Serial.print(" Freading = ");
  Serial.print(analogRead(Fpin));
  Serial.print(" String = ");
  Serial.println(vals);   //prints to serial monitor

}


//*********************Subroutines****************************************
//************************************************************************






void FreshWaterDetail()   //Calculates percent full
{

  //*********************Average data******************************
  // read the input on analog pin A0 and average:
  // subtract the last reading:

  Ftotal = Ftotal - FreadingsArray[FreadIndex];
  // read from the sensor:
  FreadingsArray[FreadIndex] = analogRead(Fpin);
  // add the reading to the total:
  Ftotal = Ftotal + FreadingsArray[FreadIndex];
  // advance to the next position in the array:
  FreadIndex = FreadIndex + 1;

  // if we're at the end of the array...
  if (FreadIndex >= FnumReadings)
   {
    FgoodAveFlag = 1;

    // ...wrap around to the beginning:
    FreadIndex = 0;

   }

  // calculate the average:
  FaveSensor = Ftotal / (FnumReadings);
 //**********************************************************

  FsensorValue = FaveSensor;
  Fvoltage = FsensorValue * (5.0 / 1023.0);
  FpercentSensorInchRange = FsensorToTankTop / FsensorRange;  //% of 12.06 max range of sensor that the top of the tank is from sensor
  FmaxPinAtTankTop = (FpercentSensorInchRange * (FmaxPinValueRange - Fbase)) + Fbase;  //Pin value at top of tank
  FpercentValueIs = (FsensorValue - Fbase) / (FmaxPinAtTankTop-Fbase);   //% of range from sensor to tank top that value read is
  FheightinTank = FpercentValueIs * FsensorToTankTop;   //Height above sensor
  FabsHeight = FheightinTank +(12.375 - FsensorToTankTop);  // Total height in tank


  if(FabsHeight < 0)  // don't show negative heights
  {
    FabsHeight = 0;
  }
  FPercentheightinTank = (FabsHeight / FtankHeight) * 100; //Convert to integer Percentage of tank is full

}

/******************************************************************/
/******************************************************************/

void GreyWaterDetail()   //Calculates percent full
{

  //*********************Average data******************************
  // read the input on analog pin A1 and average:
  // subtract the last reading:

  Gtotal = Gtotal - GreadingsArray[GreadIndex];
  // read from the sensor:
  GreadingsArray[GreadIndex] = analogRead(Gpin);
  // add the reading to the total:
  Gtotal = Gtotal + GreadingsArray[GreadIndex];
  // advance to the next position in the array:
  GreadIndex = GreadIndex + 1;

  // if we're at the end of the array...
  if (GreadIndex >= GnumReadings)
   {
    GgoodAveFlag = 1;

    // ...wrap around to the beginning:
    GreadIndex = 0;

   }

  // calculate the average:
  GaveSensor = Gtotal / (GnumReadings);
 //**********************************************************

  GsensorValue = GaveSensor;
  Gvoltage = GsensorValue * (5.0 / 1023.0);
  GpercentSensorInchRange = GsensorToTankTop / GsensorRange;  //% of 12.06 max range of sensor that the top of the tank is from sensor
  GmaxPinAtTankTop = (GpercentSensorInchRange * (GmaxPinValueRange - Gbase)) + Gbase;  //Pin value at top of tank
  GpercentValueIs = (GsensorValue - Gbase) / (GmaxPinAtTankTop-Gbase);   //% of range from sensor to tank top that value read is
  GheightinTank = GpercentValueIs * GsensorToTankTop;   //Height above sensor
  GabsHeight = GheightinTank +(12.375 - GsensorToTankTop);  // Total height in tank


  if(GabsHeight < 0)  // don't show negative heights
  {
    GabsHeight = 0;
  }
  GPercentheightinTank = (GabsHeight / GtankHeight) * 100; //Percentage of tank is full

}


/****************************************************************/
/****************************************************************/


void BlackWaterDetail()   //Calculates percent full
{

  //*********************Average data******************************
  // read the input on analog pin A3 and average:
  // subtract the last reading:

  Btotal = Btotal - BreadingsArray[BreadIndex];
  // read from the sensor:
  BreadingsArray[BreadIndex] = analogRead(Bpin);
  // add the reading to the total:
  Btotal = Btotal + BreadingsArray[BreadIndex];
  // advance to the next position in the array:
  BreadIndex = BreadIndex + 1;

  // if we're at the end of the array...
  if (BreadIndex >= BnumReadings)
   {
    BgoodAveFlag = 1;

    // ...wrap around to the beginning:
    BreadIndex = 0;

   }

  // calculate the average:
  BaveSensor = Btotal / (BnumReadings);
 //**********************************************************

  BsensorValue = BaveSensor;
  Bvoltage = BsensorValue * (5.0 / 1023.0);
  BpercentSensorInchRange = BsensorToTankTop / BsensorRange;  //% of 12.06 max range of sensor that the top of the tank is from sensor
  BmaxPinAtTankTop = (BpercentSensorInchRange * (BmaxPinValueRange - Bbase)) + Bbase;  //Pin value at top of tank
  BpercentValueIs = (BsensorValue - Bbase) / (BmaxPinAtTankTop-Bbase);   //% of range from sensor to tank top that value read is
  BheightinTank = BpercentValueIs * BsensorToTankTop;   //Height above sensor
  BabsHeight = BheightinTank +(12.375 - BsensorToTankTop);  // Total height in tank


  if(BabsHeight < 0)  // don't show negative heights
  {
    BabsHeight = 0;
  }
  BPercentheightinTank = (BabsHeight / BtankHeight) * 100; //Percentage of tank is full

} 

Will try that.

Thanks to all for your comments.

So with a continuity tester all connections are good ? Flick her over for us will ya ?

Then "Hello World" it -- compose a sketch that sends "Go!" (or whatever) repeatedly.

Thanks, Looking very good ! A bit confusing that there is an extra solder point on 1 of the rows, which led me to believe you misconnected, but that is not true. The connection between the TX-pin (11) and the resistor is suspect though. I would re-melt that. Just to make sure that's not the issue.
Another unfortunate event is that the voltage divider is mounted in relation the Nano, but it actually belongs to the HC-05. Like this it is hard to test the HC-05 using the Nano as USB to TTL. You could try a simple Serial passthrough at different speeds.

Thanks but I had soldered it on the other side and that one is good.

So desoldered the HC-05 and redid the breadboard and all works good. The issue must be in my soldering of the porotype board. But for the life of me, I can't find the cause. So I am going to start over from scratch and check it all along the way.

Thanks for all your help.

Good plan ! I still think you should be able to find the spot where the soldering is no good.

So, I found the problem, but I don't understand it. What I haven't made clear here in this thread is that I intend to use 12V to power the board and sensors but up to this point on the prototype, I have powered the board through the USB connection. As I was rebuilding the board, I checked the function at each step. As soon as I add a wire from the Vin pin to a pin that happens to be next to the A0 pin, the transfer of data from the Nano Every to the HC-05 and therefore to the app on my phone fails (although the serial monitor is still showing data as it should be). Disconnect the wire from that pin and all is well. It seems there is some cross talk between the A0 pin and the Vin pin that effects the HC-05??? Note I do have a potentiometer attached to pin A0. Can I ground the Vin pin until I actually have 12V on it in order to stop the cross talk or will the Vin pin not go for that when powered by the USB?

Maybe these pics will help:

If you are powering through USB, you should not use the Vin pin at all. If you want 5v, you should use the 5v pin.
The Vin pin should not really provide you with any power at all and should be considered a power input only. In fact i am confused you managed to get it to work using that pin at all.

If you intend to use 12v later, i would still recommend you scale that down to 5v first (using a regulator) and power the board through the 5v pin. Vin takes 7-12v but the onboard linear is not very powerful, and from 12v down to 5v a lot of heat will need to be dissipated.

Doesn't the HC-05 work on a 3.7- 4.2 range ? or is there a regulator included in the unit you are using.

I am using USB for power only to troubleshoot. I have never used 12V yet so there has never been 12V on that line - it is just where I will connect it eventually instead of using the USB. I am planning on using12V since this project will be connected to my RV which will be the source of power (12V).

So the issue is that the Vin pin is getting influenced by the A0 pin and effecting the HC-05. It sounds strange and unlikely, but that's the facts at the moment! Again, when the Vin pin is connected to the terminal strip next to pin A0, I get no output from the HC-05 even though the data is shown on the serial monitor. I guess I will have to reroute that wire and move the connector away from pin A0 and see if that helps ignore the issue. I notice that pins A1 and A2 show the same data as pin A0 even though nothing is connected to them. I'm not sure why that is.

But the Vin pin should not be connected to anything other than a possible external power source. If you are using USB it should not be connected.

And so is that.

Yeah, that's the issue - there is no connection to the Vin pin other than external wires that go nowhere!

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