@jim-p I am sorry for that mistake related to datasheet, my version is HCM375B-232-68N
Below attached is the correct datasheet.
https://inelso.ru/upload/specs/HCM370B%20HCM375B-N%20HIGH%20ACCURACY%203D%20DIGITAL%20COMPASS-1.pdf
I have new code that should work for he model you have
#include <SoftwareSerial.h>
#define rxPin 4
#define txPin 5
int response;
SoftwareSerial mySerial (rxPin, txPin);
void setup()
{
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(9600);
Serial.begin(9600);
Serial.println("Running ");
}
void loop()
{
mySerial.write (0x68);
mySerial.write (0x04);
mySerial.write ((byte)0x00);
mySerial.write (0x04);
mySerial.write (0x08);
delay(100);
Serial.print("TX: ");
Serial.print (0x68, HEX);
Serial.print (" ");
Serial.print (0x04, HEX);
Serial.print (" ");
Serial.print (0x00, HEX);
Serial.print (" ");
Serial.print (0x04, HEX);
Serial.print (" ");
Serial.print (0x08, HEX);
Serial.println (" ");
while (mySerial.available() < 12)
{
delay(50);
}
Serial.print("RX: ");
for (int i=0; i<15; i++)
{
response = mySerial.read();
Serial.print (response, HEX);
Serial.print (" ");
}
Serial.println(" ");
delay (1500);
}
@jim-p Yes, I restarted the arduino multiple times , I think there could be an error from our side regarding the hexa command which we are sending to start calibration with the compass.
I am working on that you also guide me through.
See posts #40 and #43
Try the new software first
@jim-p Ok , So I tried the code and schematic together but no response.
I am attaching below the output there was no response from tx , the values which i am mentioning were only during when i was changing tx and rx of hw-044 on arduino 2&3 pins.
I swapped the pins multiple times and refreshed the arduino many times.
Output:
Running
TX: 68 4 0 4 8
Running
TX: 68 4 0 4 8
Running
TX: 68 4 0 4 8
RX: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FFFFFFFF
TX: 68 4 0 4 8
RX: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TX: 68 4 0 4 8
RX: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TX: 68 4 0 4 8
RX: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TX: 68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
TX: 68 4 0 4 8
Running
TX: 68 4 0 4 8
Swapping pins, and connecting it wrong can damage the compass, the HW-044 and the Arduino.
Connecting the compass directly to the Arduino without the HW-044 could damage the compass and Arduino.
You better check if the compass still works with your original set-up with the Rion software.
When you run the code with the correct connections, what do you get?
No no I have'nt moved these pins alot just once or twice.
However when the connections were made according to your schematic I got:
Running
TX: 68 4 0 4 8
You better check if the compass still works with the Rion software
@jim-p It's working perfectly with rion software.
However in rion software I have placed the tx of compass with rx of D9-male connector and vice versa. But I am getting all correct readings.
That is good news.
For connecting to a computer that is corect but connections are backwards when you use an converter like the HW-044
I still trying to fiure out what is wrong
What kind of test equipment do you have?
@jim-p Can you give me few examples, maybe I might have them.
- a multimeter - auto ranging if possible
- a logic-analyzer can be useful for analyzing protocols such as RS232, I2C, etc
- an oscilloscope - but the high bandwidth versions can be expensive
There is the possibility that the HW-044 module you have is wired backwards, I have seen this happen before with similar modules.
So you need to swap pins 2 and 3 on the DB9 connector.
Compass TXD --> DB9 pin 2
Compass RXD --> DB9 pin 3
The Arduino code should print out 15 bytes of data, maybe zeros
I always think it is worth checking the voltage on the RS232 D-type connector
- transmitter TX pin 2 to pin 5 GND when idle it should be a DC negative voltage between - 6 and -12
- receiver pin3 Rx should show 0 or a minimal voltage
you then know it is a RS232 signal, which pins are Tx and RX and not TTL (which when idle is typically positive 5V or 3.3V depending on the processor)
@horace
I do have a multimeter , similar to the one shown below.

@jim-p
Thankyou I'll re-attempt it according to your new connections.
However there is one question that should I use a separate dc 5V as you have shown or I can use the 5V from arduino ?
similar to my auto ranging multimeter
use it to check the RS232 voltages - Tx (D-type in 2) should be in the range -6 to -12 when idle
@horace
So I have checked using multimeter and below are the results obtained:
- when GND-pin 5 & TX-pin 2:
I got -1 to -6 or more in mV ,but the values were constantly changing in negative side.
2.When GND-pin5 & RX-pin 3
I got 0 or 1 mV.
The compass does not use a lot of current so you can connect it the arduino 5V along with the converter Vcc
