Go Down

Topic: How to connect both FSR and HC-05 to Arduino Nano at the same time? (Read 80 times) previous topic - next topic

shoesoles

Hi! Are there any suggestions about how to connect a force sensitive resistor (FSR) together with a HC-05 bluetooth module to a Arduino Nano via a breadboard? We wish to obtain real time data from the FSR with an Android app that is connected to the HC-05.

So far, we've managed to connect the FSR to the Arduino Nano and the HC-05 to the Arduino Nano individually. Here are the setups we've done and the codes we've used:

FSR set up: Fritzing/schematic diagram
FSR code:
Code: [Select]
int fsrPin_In = A0;

void setup(void) {
  Serial.begin(9600);
}

void loop(void) {
  analogRead(fsrPin_In);

  Serial.print("Analog reading = ");
  Serial.print(analogRead(fsrPin_In));  

if (analogRead(fsrPin_In) < 10){
  Serial.println(" NO PRESSURE");
} else if (analogRead(fsrPin_In) < 100){
  Serial.println(" LIGHT TOUCH");
} else if (analogRead(fsrPin_In) < 200){
  Serial.println (" LIGHT SQUEEZE");
} else if (analogRead(fsrPin_In) < 300){
  Serial.println (" MEDIUM TOUCH");
} else if (analogRead(fsrPin_In) < 500){
  Serial.println (" MEDIUM SQUEEZE");
} else if (analogRead(fsrPin_In) <800){
  Serial.println (" BIG TOUCH");
} else {
  Serial.println(" BIG SQUEEZE");
}
delay(1000);
}      


HC-05 set up: here
HC-05 code:
Code: [Select]
// Basic Bluetooth sketch HC-05_02
// Connect the HC-05 module and communicate using the serial monitor
//
// The HC-05 defaults to commincation mode when first powered on.
// The default baud rate for communication mode is 9600
//
 
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
// Connect the HC-05 TX to Arduino pin 2 RX.
// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.
//
 
char c = ' ';
 
void setup()
{
    Serial.begin(9600);
    Serial.println("Arduino is ready");
 
    // HC-05 default serial speed for commincation mode is 9600
    BTserial.begin(9600);  
}
 
void loop()
{
 
    // Keep reading from HC-05 and send to Arduino Serial Monitor
    if (BTserial.available())
    {  
        c = BTserial.read();
        Serial.write(c);
    }
 
    // Keep reading from Arduino Serial Monitor and send to HC-05
    if (Serial.available())
    {
        c =  Serial.read();
        BTserial.write(c);  
    }
 
}


How do we combine the two set ups and the two code? Fritzing/schematic diagrams would be helpful. Thanks!

PaulS

Quote
How do we combine the set ups and the code?
Fire up your favorite text editor, and copy and paste.

Quote
Fritzing/schematic diagrams would be helpful.
For code? Are you kidding?
The art of getting good answers lies in asking good questions.

shoesoles

Fire up your favorite text editor, and copy and paste.
For code? Are you kidding?
Sorry if I wasnt clear earlier. What i meant is that i want to combine the both FSR and HC-05 set ups together, then both FSR and HC-05 codes together. So that the data from the FSR can be sent to a Bluetooth enabled phone.

I want the diagrams for the set ups, not the code.

Hope this clears things up

slipstick

You have the FSR connected to pin A0 and HC-05 connected to pins 2 and 3. So they can both be connected at the same time exactly as you are connecting them now.

Then you just have to merge the codes and for you can follow the instructions from somewhere like http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html  It's not very much more than adding the code from the two setup()s into a new combined setup() and from the two loop()s into a combined loop().

Give it a try and if you have problems post what you've tried here and tell us the problems.

Steve

srnet

You said in the other post;

Quote
Since some pins will overlap with each other for FSR and the Bluetooth module when connecting to the arduino
Which are the pins that are overlapping ?


Who should we reply to;  @yqsoh @seloseohs or @shoesoles ?
$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

Go Up