PC to Arduino UNO connection (via HC-05 Bluetooth module) issue

Hi All! :slight_smile:

What my project is supposed to do:

I need to measure impact force as a function of resistance, remotely. But the wifi signal in the environment that I need to measure can’t be guaranteed so I’m using an HC-05 bluetooth module to connect my PC (running windows 8.1) to my Arduino UNO board (which is to be hardwired to the force sensor).

The fly in the Ointment:

Unfortunately, when I try to upload the sketch, the following error appears on the Arduino IDE (v1.6.8 ):

avrdude: ser_open(): can’t open device “\.\COM3”: Access is denied

Can anyone help (please keep it simple as this is my first proper project)?

What I’ve done (FYI):

To measure force, I have constructed the circuit shown in the attached circuit diagram, including a Force Sensitive Resistor (FSR).

As a first step, I assembled the part of the circuit shown in blue in the circuit diagram attachment, connected the UNO to the PC via USB cable and ran the following code:

const int FSR_PIN = A0; // Pin connected to FSR/resistor divider

// Measure the voltage at 5V and resistance of your 3.3k resistor, and enter
// their value's below:
const float VCC = 4.98; // Measured voltage of Ardunio 5V line
const float R_DIV = 3230.0; // Measured resistance of 3.3k resistor

void setup() 
{
  Serial.begin(38400);
  pinMode(FSR_PIN, INPUT);
}

void loop() 
{
  int fsrADC = analogRead(FSR_PIN);
  // If the FSR has no pressure, the resistance will be
  // near infinite. So the voltage should be near 0.
  if (fsrADC != 0) // If the analog reading is non-zero
  {
    // Use ADC reading to calculate voltage:
    float fsrV = fsrADC * VCC / 1023.0;
    // Use voltage and static resistor value to 
    // calculate FSR resistance:
    float fsrR = R_DIV * (VCC / fsrV - 1.0);
    Serial.println("Resistance: " + String(fsrR) + " ohms");
    // Guesstimate force based on slopes in figure 3 of
    // FSR datasheet:
    float force;
    float fsrG = 1.0 / fsrR; // Calculate conductance
    // Break parabolic curve down into two linear slopes:
    if (fsrR <= 600) 
      force = (fsrG - 0.00075) / 0.00000032639;
    else
      force =  fsrG / 0.000000642857;
    Serial.println("Force: " + String(force) + " g");
    Serial.println();

    delay(500);
  }
  else
  {
    // No pressure detected
  }
}

This worked really well.

I then assembled the rest of the circuit in the circuit diagram so that the HC-05 module could be used to communicate with the PC in place of the USB cable. The PC successfully identifies and pairs with the HC05 module and my multimeter confirms that Tx and Rx signals are being sent between the UNO and HC-05 module, but things fall apart when I try to upload the sketch (as described above).

The PC’s bluetooth uses COM3 and COM4. Initially, I attempted to send the sketch through COM3 on the Arduino IDE and then I specified COM4 when that failed. The same error message was displayed after sending the sketch both times.

I’ve also made sure that the “Arduino/Genuino Uno” board is selected in the IDE’s “Tools” menu.

Any help would be really appreciated as I’m out of ideas :slight_smile:

Thanks!!

You need to look in Device Manager to see which port your Arduino uses.

MrHappy1982:
Unfortunately, when I try to upload the sketch, the following error appears on the Arduino IDE (v1.6.8 ):

avrdude: ser_open(): can't open device "\.\COM3": Access is denied

void setup() 

{
  Serial.begin(38400);
}




This worked really well.

I then assembled the rest of the circuit in the circuit diagram so that the HC-05 module could be used ........but things fall apart when I try to upload the sketch

You are using hardware serial, which is a good idea but the port is shared by bluetooth and the USB cable. This means that you must have the bluetooth device disconnected while uploading. Have you done that? If not, do so now, and all may be well.

The PC successfully identifies and pairs with the HC05

This doesn't do anything more than it tells you. Arduino is not involved, all it does is provide power to HC-05.