HC-06 with PMS 7003(fine dust sensor)

Hi!
I'm trying to connect HC-06(Bluetooth) with PMS 7003(Fine dust sensor).
Measure fine dust data by using PMS 7003 and I want to send this data to another computer by Bluetooth(HC-06).
So, i already connect HC-06 with another computer. I receive manually entered texts. But fine dust data is not displayed in the correct way.
Below is the code what i use

#include <SoftwareSerial.h>
#include <PMS.h>


#define BT_RX 11
#define BT_TX 10

SoftwareSerial nockanda(2,3); //tx=2, rx=3

SoftwareSerial btSerial(BT_RX, BT_TX);

PMS pms(nockanda);
PMS::DATA data;

void setup() {
  Serial.begin(115200);
  nockanda.begin(9600);
  btSerial.begin(115200);
}

void loop() {
  if (pms.read(data))
  {
    Serial.print("PM 1.0 : ");
    Serial.println(data.PM_AE_UG_1_0);

    Serial.print("PM 2.5 : ");
    Serial.println(data.PM_AE_UG_2_5);

    Serial.print("PM 10.0 : ");
    Serial.println(data.PM_AE_UG_10_0);

    Serial.println();
  }

  if (Serial.available()) { // From Serial monitor to Bluetooth
    btSerial.write(Serial.read());
  }

  if (btSerial.available()) { // From Bluetooth to Serial monitor
    Serial.write(btSerial.read());
  }
}

Below is error message

Below images are my real connection.


Using software serial at 115200 is not a proposition. Stick with 9600.
Using two instances of software serial is fraught with problems. If you don't actually need the keyboard input, now is the time to ditch it, and put Bluetooth on hardware serial. If you do this, note that Bluetooth must be disconnected while uploading your programme.

I think it's a baud rate mismatch. The baud rate that you define in your code should be as same as the one you select when opening the serial monitor.

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