I have a HCM375B sensor

I have a HCM375B sensor and I want to use it in the Arduino Uno, but I could not extract the data from the sensor and print them on the serial. Is there anyone who can help me please?

Welcome to the forum

You mean this?

Always helps to give a link - so we can be sure what you're talking about.

Do you have the RS-232, RS485, or TTL version?

Please show what you tried: post your code, your schematic, and some good, clear photos of your setup.

See 'How to get the best out of this forum' for instructions.

This is what I tried

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX pins of Arduino

void setup() {
Serial.begin(9600); // Initialize serial communication with the computer
mySerial.begin(9600); // Initialize serial communication with the sensor (RS232)
}

void loop() {
if (mySerial.available()) {
// Read the incoming data from the sensor
float receivedData = mySerial.parseFloat();

// Process the received data
processSensorData(receivedData);

}
}

void processSensorData(float data) {
// Perform the necessary operations to interpret and utilize the received data
// You can implement the logic to extract and process the Pitch, Roll, and Yaw values from the received data
// This will depend on the specific data format provided by the sensor's documentation

// Example: Assume the received data format for Pitch and Roll is in decimal degrees
// Extract Pitch value
float pitch = data;

// Example: Assume the received data format for Roll is in decimal degrees
// Extract Roll value
float roll = data;

// Example: Assume the received data format for Yaw is in decimal degrees
// Calculate degrees, minutes, and seconds for Yaw
int degrees = int(data); // Extract the integer part
int minutes = int((data - degrees) * 60); // Calculate minutes
int seconds = int(((data - degrees) * 60 - minutes) * 60); // Calculate seconds

// Print the Pitch, Roll, and Yaw values
Serial.print("Pitch: ");
Serial.print(pitch, 2); // Print with 2 decimal places
Serial.println(" degrees");

Serial.print("Roll: ");
Serial.print(roll, 2); // Print with 2 decimal places
Serial.println(" degrees");

Serial.print("Yaw: ");
Serial.print(degrees);
Serial.print(" degrees, ");
Serial.print(minutes);
Serial.print(" minutes, ");
Serial.print(seconds);
Serial.println(" seconds");
}

how does that correspond to the protocol described in the document? :thinking:

Remember to check the preview to be sure that your post is properly formatted!

http://www.rionsystem.com/en/list_94/351.html

I do not know anything. I am a student. I entered so that you can guide me on the appropriate method and how to do it, please

Please edit your post to enclose the code in code tags "< code >" editor button, and answer the question about which version of the sensor you have.

This is what I tried

That code won't be useful. Study the sensor data sheet to learn how the data are transmitted, section titled "Communication Protocol".

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3);  // RX, TX pins of Arduino

void setup() {
  Serial.begin(9600);         // Initialize serial communication with the computer
  mySerial.begin(9600);       // Initialize serial communication with the sensor (RS232)
}

void loop() {
  if (mySerial.available()) {
    // Read the incoming data from the sensor
    float receivedData = mySerial.parseFloat();

    // Process the received data
    processSensorData(receivedData);
  }
}

void processSensorData(float data) {
  // Perform the necessary operations to interpret and utilize the received data
  // You can implement the logic to extract and process the Pitch, Roll, and Yaw values from the received data
  // This will depend on the specific data format provided by the sensor's documentation

  // Example: Assume the received data format for Pitch and Roll is in decimal degrees
  // Extract Pitch value
  float pitch = data;

  // Example: Assume the received data format for Roll is in decimal degrees
  // Extract Roll value
  float roll = data;

  // Example: Assume the received data format for Yaw is in decimal degrees
  // Calculate degrees, minutes, and seconds for Yaw
  int degrees = int(data);                        // Extract the integer part
  int minutes = int((data - degrees) * 60);        // Calculate minutes
  int seconds = int(((data - degrees) * 60 - minutes) * 60);  // Calculate seconds

  // Print the Pitch, Roll, and Yaw values
  Serial.print("Pitch: ");
  Serial.print(pitch, 2);  // Print with 2 decimal places
  Serial.println(" degrees");

  Serial.print("Roll: ");
  Serial.print(roll, 2);  // Print with 2 decimal places
  Serial.println(" degrees");

  Serial.print("Yaw: ");
  Serial.print(degrees);
  Serial.print(" degrees, ");
  Serial.print(minutes);
  Serial.print(" minutes, ");
  Serial.print(seconds);
  Serial.println(" seconds");
}

I could not, because we do not understand much, and I have an Arduino project for this sensor, and I want someone to help us with the code in order to read the data of the sensor.
Be very grateful to you
This is the sensitive link
http://rionsystem.com/en/static/upload/file/20220302/1646220938575346.pdf

You must tell us which of the three versions of the sensor you have, and exactly how you have connected and powered it.

HCM375B Wiring Definition
HCM375B-485-68-N
Brown=Dc9-36V
Black=GND
Plnk =D+
Blue=D-

في الأحد، ٣ سبتمبر، ٢٠٢٣ ٣:١٣ ص jremington via Arduino Forum <notifications@arduino.discoursemail.com> كتب:

في الأحد، ٣ سبتمبر، ٢٠٢٣ ٣:٢٦ ص وسيم الغالي <walghaly510@gmail.com> كتب:

في الأحد، ٣ سبتمبر، ٢٠٢٣ ٣:٣٣ ص وسيم الغالي <walghaly510@gmail.com> كتب:

HCM370B HCM375B-N HIGH ACCURACY 3D DIGITAL COMPASS.pdf (3.32 MB)

How to run it using the Lnclinometer program on the computer, connect it to USB-RS485//RS422, and feed it with an external source from 9.V to 36V, but I want to run it with Arduino

I moved your topic to an appropriate forum category @alwaseem12.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

I have deleted your other cross-post @alwaseem12.

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

I'm new to this forum and I don't know what to do. I'm not intentional

Did you read the "How to get the best out of this forum" guide as I suggested you do 10 hours ago? If you did, you should have learned that cross-posting is not allowed.

1 Like