Bluetooth (HC05) connection 'buffer' error?

So i am trying to build a weather station project and i am sending my values over Bluetooth to my MIT App Inventor app and then from there uploading it to thingspeak.

I was uploading the values perfectly to the internet on a breadboard. I then built my PCB and due to other sensors had to move my software serial pins over from RXD=8,TXD=9, to pins 0 and 1 respectively, but i cannot get it to work. By work i mean send data succesfully to my phone… it worked before…
The power supply is from the arduino uno 5V pin (the only thing powered from it) and i added a 220uF cap to smooth out any ripples 5V to Gnd. I think on the bread board i used a 1A 5V linear regulator chip. I used an oscilloscope to check the 5V (from the arduino 5V pin) when the Bluetooth is connected vs not connected and it appears steady and smooth.

So i started software debugging, just printing out my variable string to the Arduino serial monitor. That seemed fine.

I noticed that when i connected from my phone to the HC05 then the serial.println would start behaving very strange, the basic string would start being ‘corrupt’ (see picture below). I am pretty sure it is connecting as i can tell by the red flashing LED period changing and also my app says it is connected.

I was thinking it could be that i am not clearing a buffer or something… I did notice in my app that initially the is a BUNCH of stuff coming through and then nothing… so do i need to monitor a ‘to-be-sent’ buffer and clear it if it gets too long (so i don’t just keep adding data to my string instead of cllearing and starting a fresh data push) ?

Any help/guidance would be greatly appreciated… I had it working on a breadboard!!! Grrr
I am happy to provide any other info.

For testing
Here is my ‘debug’ code

//Temp-Humidity sensors
#include <dht.h>
dht DHT;
#define DHT11_PIN 12 //temp/humid sensor

//Bluetooth
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(0, 1); //BlueTooth RX ,TX

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);

unsigned long volatile rain_ISR_millis = 0;
unsigned long volatile wind_ISR_millis = 0;

unsigned long timestampSend = 0; // BT Write wait period
unsigned long timestampWind = 0; // Wind Speed Meter
unsigned long timestampRainH = 0; // Rainfall per hour
long SendDataPeriodS = 1; //in S 3600 = 1hr
double WindSpinnerDistance = 125.6; //20mm radius = 2*20*Pi = 125.6 mm
double RainArea = 4071; //radius = 36mm mm^2,
long volatile rainCount = 0; //counter for bucket
int volatile Rainfall = 0;
long volatile windCount = 0;
int volatile lastKnownWindPosition = 0;
int volatile WindDir = 0;
double volatile AvgWindSpeed = 0;
double volatile Vbat1 = 0;
double volatile Vbat2 = 0;

int wind1 = 11;
int wind2 = 4;
int wind3 = 5;
int wind4 = 6;
int wind5 = 7;
int wind6 = 8;
int wind7 = 9;
int wind8 = 10;

//int AvgTemp = 0; //in C - FD1:##                  1
//int AvgHum = 0; // in % - FD2:##                  2
//int AvgBaro = 0; //in hPa - FD3:##                3
int AccumRain = 0; // in mm - FD4:##              4
//int AvgWindSpeed = 0; // km/h - FD5:##            5
//int WindDir = 0; // 8hr clock = North   - FD6:##  6
//double Vbat1 = 0; // Volts FD7:##                 7
//double Vbat2 = 0; // Volts FD8:##                 8

void setup()
{

  pinMode(2, INPUT);           // set pin to input
  digitalWrite(2, HIGH);       // turn on pullup resistors
  pinMode(3, INPUT);           // set pin to input
  digitalWrite(3, HIGH);       // turn on pullup resistors

  attachInterrupt(0, Rain_ISR, FALLING); // using Interrupt 0 on pin 2
  attachInterrupt(1, Wind_ISR, FALLING); // using Interrupt 1 on pin 3

  Serial.begin(9600);
  bluetooth.begin(9600);

  //Check Baro Sensor check
  if (!bmp.begin())
  {
    /* There was a problem detecting the BMP085 ... check your connections */
    Serial.print("Ooops, no BMP085 detected ... Check your wiring or I2C ADDR!");
  }
  // Wait for the sensors to stabilize
  delay(1000);
  Serial.print("Ready");
}

void loop()
{
  if (millis() >= timestampWind + 5000)//check every 5 seconds how many revolutions the spinner made
  {
    AvgWindSpeed = ((windCount * WindSpinnerDistance) / 5) * (0.0036); //=speed in mm/s * (0.0036) = km/h
    windCount = 0; //reset the counter
    timestampWind = millis();
  }

  if (millis() >= timestampRainH + 3600000)//check every 3600 seconds (1 hour) how many ticks the ticker
  {
    Rainfall = (rainCount * 3); // 3 is assumed ml needed to tip bucket --- ml that has fallen ------------------------------------------------------------------------Need to convert this into mm || 1mm = 1L/m^2
    rainCount = 0; //reset the counter
    timestampRainH = millis();
  }

  //int(DHT.temperature) casts it into an int
  if (millis() >= timestampSend + (SendDataPeriodS * 1000))
  {

    //Check Wind Direction
    if (digitalRead(wind1) == LOW)
    {
      WindDir = 1;
      lastKnownWindPosition = 1;
    }
    else if (digitalRead(wind2) == LOW)
    {
      WindDir = 2;
      lastKnownWindPosition = 2;
    }
    else if (digitalRead(wind3) == LOW)
    {
      WindDir = 3;
      lastKnownWindPosition = 3;
    }
    else if (digitalRead(wind4) == LOW)
    {
      WindDir = 4;
      lastKnownWindPosition = 4;
    }
    else if (digitalRead(wind5) == LOW)
    {
      WindDir = 5;
      lastKnownWindPosition = 5;
    }
    else if (digitalRead(wind6) == LOW)
    {
      WindDir = 6;
      lastKnownWindPosition = 6;
    }
    else if (digitalRead(wind7) == LOW)
    {
      WindDir = 7;
      lastKnownWindPosition = 7;
    }
    else if (digitalRead(wind8) == LOW)
    {
      WindDir = 8;
      lastKnownWindPosition = 8;
    }
    else
    {
      WindDir = lastKnownWindPosition;
    }

    //Check Rainfall


    //Check Battery Voltage Sensing
    Vbat1 = ((analogRead(0) * 5. / 1023.) / .232); //R1=395k,R2=120k
    Vbat2 = ((analogRead(1) * 5. / 1023.) / .204); //R1=395k,R2=120k

    //Check Baro sensor
    sensors_event_t event;
    bmp.getEvent(&event);

    //Check Temp & Humidity Sensor
    int chk = DHT.read11(DHT11_PIN);

    //BT it over
    //String dataString = ("FD1:" + String(int(DHT.temperature)));// + ":" + "FD2:" + String(int(DHT.humidity)) + ":" + "FD3:" + String(int(event.pressure)) + ":" + "FD4:" + String(rainCount) + ":" + "FD5:" + String(AvgWindSpeed) + ":" + "FD6:" + String(WindDir) + ":" + "FD7:" + Vbat1 + ":" + "FD8:" + Vbat2);
    String dataString = "15"; // for debugging

    bluetooth.println(dataString);
    Serial.println(dataString);

    timestampSend = millis();

  }
}

void Rain_ISR()
{

  if ( (millis() - rain_ISR_millis) > 100 )
  {
    rainCount = rainCount + 1;
    rain_ISR_millis = millis();
  }

}

void Wind_ISR()
{

  if ( (millis() - wind_ISR_millis) > 5 ) //4.5ms = 100km/h
  {
    windCount = windCount + 1;
    wind_ISR_millis = millis();
  }


}

Odd serial prints when bluetooth is connected.JPG

vermin_sapper:
move my software serial pins over from RXD=8,TXD=9, to pins 0 and 1 respectively,

Since pins 0,1 are for hardware serial, this was a seriously dumb idea, and you deserve all the grief you get. Since everything worked fine on the breadboard, and I assume this is the only change made, it is probably your only problem.

Since your (hardware) Serial commands serve no real purpose, you may be able to get round the problem by changing the software serial commands to Serial.print and eventually deleting your original hardware serial commands.

This means you need to disconnect bluetooth while uploading.

Hi Nick, Thanks for the quick response. Yeah i guess when you make dumb descions you need to pay/ learn the hard way. I did initially ‘think’ of hardware serial, and for some reason figured it was on the other side (12,13) since you can see the pin 13 led flash when programming. But good to know Thanks Solved!!!