I NEED HELP FOR A PROJECT ASAP PLEASE!! IT'S DUE IN 4 DAYS!!

Southpark:
It just appears at the moment that you're not putting enough care or effort into connecting components together properly. So, what you need to do is to think, and double-think about whether or not you're connecting a component properly - each time you insert a component leg into a particular hole in the breadboard grid.

I've never used Arduino before and I'm doing this project by myself with no physical help. Sorry if it looks like I'm not putting in enough care. I really am trying to figure things out.

Wawa:
You have ignored several things I wrote about the RX TX connection of the BT device.

Leo…

I asked the manufacturers of the device and they said that’s how you’re supposed to set it up.

Ok I think I fixed it, but before I post a pic, can you tell me how I’m supposed to represent this on a breadboard with the resistors?

Screen Shot 2018-05-03 at 7.53.57 PM.png

You must have figured out by know that five holes in a row (width of the breadboard) are all connected.

Start by plugging in the 2k2 resistor (red, red, ...).
One wire in the same row of the RX pin of the BT device.
The other wire in the same row as ground of the BT device.

Now plug one wire of the 1k resistor into the RX row, and the other wire of the 1k resistor in an unused row.
Use a Dupond wire to extend that not yet connected resistor wire to Arduino pin 7.
Leo..

jkg9:
I asked the manufacturers of the device and they said that’s how you’re supposed to set it up.

You mean you talked to a reseller.
You can, but don’t have to use the hardware serial port for BT.
Pin 0 and 1 of an Uno are already used by the USB<>Serial chip.
Using the same pins for BT is like having an affair with two girlfriends.
Usually better to move BT comms to two different pins (set up with e.g. softwareSerial).
Leo…

Ok I’ll change that. But before I get to the fix you suggested, would this work or no? I mean it looks like the parallel resistor setup in the diagram. And then, I would just connect the ports from the BT module to the Arduino.

jkg9:
Ok I'll change that. But before I get to the fix you suggested, would this work or no? I mean it looks like the parallel resistor setup in the diagram. And then, I would just connect the ports from the BT module to the Arduino.

The meeting point between your two resistors. You're meant to connect that point to something, right? such as.... to the 'Rx' pin of the HC-06? At the moment..... that mid-point on your breadboard.... is connected to nothing.

Yes of course

I see one resistor between the +rail and a short row.
And the other resistor between that short row and another short row.
Not what I explained.

Did you read/understand the Sparkfun breadboard layout I linked to?
Leo..

Wawa:
I see one resistor between the +rail and a short row.
And the other resistor between that short row and another short row.
Not what I explained.

Did you read/understand the Sparkfun breadboard layout I linked to?
Leo…

Sorry I just wanted to see if I could figure it out myself one last time. Ok I will change it to your suggestion and send a pic. I did read the Sparkfun breadboard layout and understood it.

Ok here it is. Hopefully this time it’s correct. If it is, then I can connect everything else normally?

I see a resistor (1k?) between the red wire and the STATE pin.
And a resistor (2k2?) between RX and GND.

So almost right.
Move the 1k resistor from the State pin to the RX pin.

Why did you remove the power wires?
They were right.
Leo..

I removed the wires cause they were getting in the way and I couldn't put the resistors in. I'll add them back. And yes 2k2 is between RX and GND and 1K is between red wire and (now) RX pin. So where should the TX pin be connected?

Post#11

The red wire (from the RX voltage divider) could go to pin 7.

Use another Dupond wire between the TX pin and pin 6.

The same pin numbers must also be used when you set up a software serial port.
Leo..

Wawa:
Post#11

Use another Dupond wire between the TX pin and pin 6.

Don't you need a resistor for the TX pin?

Here’s the final thing. If you could take a quick look at the gas sensor and give me some feedback, that would be highly appreciated.

Screen Shot 2018-05-03 at 10.32.42 PM.png

jkg9:
Don’t you need a resistor for the TX pin?

No.

You connected the yellow 5volt wire to the EN (enable) pin instead of the VCC pin.

Can’t tell if the gas sensor is connected right, because you didn’t post a link to that module.

And you didn’t post any code yet.
Don’t forget the code tags (read the howto sticky).
Leo…

Wawa:
No.

You connected the yellow 5volt wire to the EN (enable) pin instead of the VCC pin.

Can't tell if the gas sensor is connected right, because you didn't post a link to that module.

And you didn't post any code yet.
Don't forget the code tags (read the howto sticky).
Leo..

I will work on the code tomorrow. Here is a link to the sensor. It's part of a kit.

https://www.amazon.com/gp/product/B01N1UB89A/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1

It seems that the sensor has an analogue output and a digital output.

The digital output is a gas/no gas output.
The threshold of that can be adjusted with onboard the trimpot.
Seems you don't need the digital output.

The analogue output will give you the actual gas concentration.

You can already try to pair with the BT module.
You don't need any code for that.
Leo..

Ok so this is the plan I have for the rest of the project: I want to connect the BT module and gas sensor with an app called AirCasting Android app (link explaining app and website: http://aircasting.org/). The code (down below) is what I have so far for the gas sensor. How would I be able to add code for the BT module? Also, how do I read the graph in the datasheet in case I wanted to change the sensor? I’m using an MQ-2 gas sensor. I’m attaching details about it from the manual from the kit and the datasheet that I got online.

/************************Hardware Related Macros************************************/
#define         MQ_PIN                       (2)     //define which analog input channel you are going to use
#define         RL_VALUE                     (5)     //define the load resistance on the board, in kilo ohms
#define         RO_CLEAN_AIR_FACTOR          (9.83)  //RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO,
                                                     //which is derived from the chart in datasheet
 
/***********************Software Related Macros************************************/
#define         CALIBARAION_SAMPLE_TIMES     (50)    //define how many samples you are going to take in the calibration phase
#define         CALIBRATION_SAMPLE_INTERVAL  (500)   //define the time interal(in milisecond) between each samples in the
                                                     //cablibration phase
#define         READ_SAMPLE_INTERVAL         (50)    //define how many samples you are going to take in normal operation
#define         READ_SAMPLE_TIMES            (5)     //define the time interal(in milisecond) between each samples in 
                                                     //normal operation
 
/**********************Application Related Macros**********************************/
#define         GAS_LPG                      (0)
#define         GAS_CO                       (1)
#define         GAS_SMOKE                    (2)
 
/*****************************Globals***********************************************/
float           LPGCurve[3]  =  {2.3,0.21,-0.47};   //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent"
                                                    //to the original curve. 
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59) 
float           COCurve[3]  =  {2.3,0.72,-0.34};    //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent" 
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000,  0.15) 
float           SmokeCurve[3] ={2.3,0.53,-0.44};    //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent" 
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.53), point2: (lg10000,  -0.22)                                                     
float           Ro           =  10;                 //Ro is initialized to 10 kilo ohms
 
void setup()
{
  Serial.begin(9600);                               //UART setup, baudrate = 9600bps
  Serial.print("Calibrating...\n");                
  Ro = MQCalibration(MQ_PIN);                       //Calibrating the sensor. Please make sure the sensor is in clean air 
                                                    //when you perform the calibration                    
  Serial.print("Calibration is done...\n"); 
  Serial.print("Ro=");
  Serial.print(Ro);
  Serial.print("kohm");
  Serial.print("\n");
}
 
void loop()
{
   Serial.print("LPG:"); 
   Serial.print(MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_LPG) );
   Serial.print( "ppm" );
   Serial.print("    ");   
   Serial.print("CO:"); 
   Serial.print(MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_CO) );
   Serial.print( "ppm" );
   Serial.print("    ");   
   Serial.print("SMOKE:"); 
   Serial.print(MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_SMOKE) );
   Serial.print( "ppm" );
   Serial.print("\n");
   delay(200);
}
 
/****************** MQResistanceCalculation ****************************************
Input:   raw_adc - raw value read from adc, which represents the voltage
Output:  the calculated sensor resistance
Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage
         across the load resistor and its resistance, the resistance of the sensor
         could be derived.
************************************************************************************/ 
float MQResistanceCalculation(int raw_adc)
{
  return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc));
}
 
/***************************** MQCalibration ****************************************
Input:   mq_pin - analog channel
Output:  Ro of the sensor
Remarks: This function assumes that the sensor is in clean air. It use  
         MQResistanceCalculation to calculates the sensor resistance in clean air 
         and then divides it with RO_CLEAN_AIR_FACTOR. RO_CLEAN_AIR_FACTOR is about 
         10, which differs slightly between different sensors.
************************************************************************************/ 
float MQCalibration(int mq_pin) 
{
  int i;
  float val=0;
 
  for (i=0;i<CALIBARAION_SAMPLE_TIMES;i++) {            //take multiple samples
    val += MQResistanceCalculation(analogRead(mq_pin));
    delay(CALIBRATION_SAMPLE_INTERVAL);
  }
  val = val/CALIBARAION_SAMPLE_TIMES;                   //calculate the average value
 
  val = val/RO_CLEAN_AIR_FACTOR;                        //divided by RO_CLEAN_AIR_FACTOR yields the Ro 
                                                        //according to the chart in the datasheet 
 
  return val; 
}
/*****************************  MQRead *********************************************
Input:   mq_pin - analog channel
Output:  Rs of the sensor
Remarks: This function use MQResistanceCalculation to caculate the sensor resistenc (Rs).
         The Rs changes as the sensor is in the different consentration of the target
         gas. The sample times and the time interval between samples could be configured
         by changing the definition of the macros.
************************************************************************************/ 
float MQRead(int mq_pin)
{
  int i;
  float rs=0;
 
  for (i=0;i<READ_SAMPLE_TIMES;i++) {
    rs += MQResistanceCalculation(analogRead(mq_pin));
    delay(READ_SAMPLE_INTERVAL);
  }
 
  rs = rs/READ_SAMPLE_TIMES;
 
  return rs;  
}
 
/*****************************  MQGetGasPercentage **********************************
Input:   rs_ro_ratio - Rs divided by Ro
         gas_id      - target gas type
Output:  ppm of the target gas
Remarks: This function passes different curves to the MQGetPercentage function which 
         calculates the ppm (parts per million) of the target gas.
************************************************************************************/ 
int MQGetGasPercentage(float rs_ro_ratio, int gas_id)
{
  if ( gas_id == GAS_LPG ) {
     return MQGetPercentage(rs_ro_ratio,LPGCurve);
  } else if ( gas_id == GAS_CO ) {
     return MQGetPercentage(rs_ro_ratio,COCurve);
  } else if ( gas_id == GAS_SMOKE ) {
     return MQGetPercentage(rs_ro_ratio,SmokeCurve);
  }    
 
  return 0;
}
 
/*****************************  MQGetPercentage **********************************
Input:   rs_ro_ratio - Rs divided by Ro
         pcurve      - pointer to the curve of the target gas
Output:  ppm of the target gas
Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm) 
         of the line could be derived if y(rs_ro_ratio) is provided. As it is a 
         logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic 
         value.
************************************************************************************/ 
int  MQGetPercentage(float rs_ro_ratio, float *pcurve)
{
  return (pow(10,( ((log(rs_ro_ratio)-pcurve[1])/pcurve[2]) + pcurve[0])));
}

605-00008-MQ-2-Datasheet-370464.pdf (55.4 KB)