Hello Guys,
I have a 3D digital compass model"HCM375B-232-68N", I have used it with it's Rion software. Now my second step is to connect this compass with arduino, for first few tries I attempted to obtain the data values shown on it's software on arduino serial monitor through rx/tx pins. I got some of values but they were not what I wanted.
Please can anyone guide me how can I connect the compass with arduino so that i could obtain it's movement values on serial monitor of arduino.
Below attached: https://youtu.be/I0Tq7U8Stro?si=YYLQDtRFbor89HQN (connection of compass with vga , then i took single wires splitted in two other wires one connected with rx of vga and one connected with rx of arduino)
@jim-p Thankyou for guiding I am using arduino uno(SMD version).
Can I use HW-044(https://www.seeedstudio.com/RS232-to-TTL-Converter-Module-p-1684.html) as I have it right now, otherwise I will purchase the other one which you have mentioned.
Can you please guide that should I use the 5v supply to HCM375 compass either from arduino uno(which I am using) or from the rs232 ?
the HW-044 RS232-TTL shield should work OK with the UNO
I would suggest you use AltSoftSerial library which works OK on a UNO at 9600 baud
try this simple program
// AltSoftSerial transmit/Receive Test
//
// from https://github.com/PaulStoffregen/AltSoftSerial/blob/master/examples/ReceiveTest/ReceiveTest.ino
//
// Transmit data with Serial1 and try to receive
// it with AltSoftSerial. You must connect a wire
// from Serial1 TX to AltSoftSerial RX.
#include <AltSoftSerial.h>
AltSoftSerial altser;
const int mybaud = 9600;
// Board Serial1 TX AltSoftSerial RX
// ----- ---------- ----------------
// UNO 9 8
// Teensy 3.x 1 20
// Teensy 2.0 8 (D3) 10 (C7)
// Teensy++ 2.0 3 (D3) 4 (D4)
// Arduino Leonardo 1 13
// Arduino Mega 18 48
// Serial1 on AVR @ 16 MHz minimum baud is 245
// Serial1 on Teensy 3.2 @ 96 MHz minimum baud is 733
void setup() {
delay(200);
Serial.begin(115200);
while (!Serial) ; // wait for Arduino Serial Monitor
altser.begin(mybaud); // to AltSoftSerial RX
Serial.println("AltSoftSerial transmit/ Receive Test");
Serial.println("on a UNO connect pins 8 and 9 for a loopback test");
Serial.println("characters entered on serial monitor keyboard are echoed back via serial to the display");
}
void loop() {
// transmit a test byte on Serial 1
if (Serial.available() > 0) {
altser.write(Serial.read());
}
// attempt to receive it by AltSoftSerial
if (altser.available() > 0) {
Serial.write(altser.read());
}
}
to check it works connect UNO pins 8 and 9 together to give a loopback test
characters entered on serial monitor keyboard are echoed back via serial to the display
to connect the RS232module
connect UNO pin 8 Rx to RS232 RX
connect UNO pin 9 Tx to RS232 TX
connect UNO 5V and GND to the RS232 module
does the HCM375 compass have a 9pin D-type connector which can plug into the RS232-TTL module
@jim-p@horace
Thankyou I have read that document which you mentioned.
I am using arduino uno (smd version , attaching the image along)
I had used rx,tx pins of compass and arduino but it did'nt work because as everyone mentioned we need to use RS232 and probably send a command in hexadecimal to start operating the compass.
No, HCM375 does'nt come with a 9 pin D-type connector , however I used one to connect it and make it work on it's own software, which worked perfectly fine. (also attaching the pin configuration of compass)
@jim-p
I connected all pins in the way you mentioned, however this only worked when I simultaneously used compass's 'Rion' software along with the arduino. But it didnot worked when I separately used only arduino and compass with the connections mentioned above.
@horace
Thankyou for loopback test code.
I have tried and obtained the output shown below. I tried to enter few characters on serial monitor they were sent but never displayed. Is my output shown correct ? connections are
RS232(vcc-5v)arduino
RS232(gnd-gnd)arduino
RS232(RX-8)arduino
RS232(TX-9)arduino
did you try connecting pins 8 and 9 of the UNO to do a loopback test? did t work OK?
when the RS232-TTL module is connected to the UNO try connecting pins 2 and 3 of the D-type connector - this should form a loopback test to check the RS232-TTL module is working
@horace Can you please make connections more clear.
like what's the sequence of connecting all pins.
RS232(vcc-5v)arduino
RS232(gnd-gnd)arduino
RS232(RX-8)arduino
RS232(TX-9)arduino
and use 2,3 pins of D-type to connect with which pins ?
First you should only have the Uno and compass connected, nothing else should be connected to RXD, TXD
Second what software are you using on the Uno to communicate with the compass?
connect D-type pins 2 and 3 together - the transmitted signal is fed back to the receiver to form a loopback
characters entered on the serial monitor are transmitted over RS232 and received back to be displayed
@jim-p
I should connect uno and compass only with 5v and GND right ?
Secondly I am not using and software to communicate with compass however as @horace and you mentioned I will need to use rs232 module for communication.
Connect as I show in post #8 using the HW-044 converter, Vcc is 5V.
Only connect the Uno and compass, nothing else.
What software are you using on the UNO?