Reads HMC5883 3-axis compass via I2C and updates EZ-Script variables on demand; polled control offers periodic heading data, for connected sensors.
How to add the HMC5883 Compass robot skill
- Load the most recent release of ARC (Get ARC).
- Press the Project tab from the top menu bar in ARC.
- Press Add Robot Skill from the button ribbon bar in ARC.
- Choose the I2C category tab.
- Press the HMC5883 Compass icon to add the robot skill to your project.
Don't have a robot yet?
Follow the Getting Started Guide to build a robot and use the HMC5883 Compass robot skill.
How to use the HMC5883 Compass robot skill
What this skill does: The HMC5883 is a 3‑axis digital compass sensor that communicates using I2C. This ARC Skill reads the sensor and writes the compass values into EZ-Script variables so your project can use them.
Before You Start (Beginner Checklist)
- Hardware: An EZ-B v4 and an HMC5883 (EZ-Bit) compass module.
- Wiring: The compass must be connected to the EZ-B’s I2C port.
- ARC project: Add the HMC5883 Skill to your ARC project.
- Important: If the sensor is not connected correctly and you try to communicate with it, the EZ-B v4 can lock up. Double-check wiring before running any script.
How This Skill Works
This Skill does not continuously read the sensor by itself. Instead, you request a reading whenever you want one.
-
Initialize the sensor (required): You must run
Initonce after the Skill loads (or once when your project starts). -
Request readings: Each time you want new compass data, call
RunOnce. The Skill will query the sensor and then update its EZ-Script variables.
Tip for beginners: Think of
Init as “wake up and configure the sensor” and RunOnce as “take a reading now.”
Example: Update the Compass Every 100 ms
The script below initializes the HMC5883, then loops forever and requests a new reading every 100 milliseconds.
Make sure you do all of the following first:
- Add the HMC5883 Skill to your ARC project.
- Connect the HMC5883 module to the EZ-B’s I2C port.
- Create/open an EZ-Script control and paste in the script.
- Confirm the control name in the script matches your Skill’s name exactly (including spaces).
ControlCommand("HMC5883 ", Init)
:loop
ControlCommand("HMC5883 ", RunOnce)
sleep(100)
goto(loop)
What this script is doing
ControlCommand("HMC5883 ", Init)initializes the compass sensor (do this once).:loopcreates a label for the loop.ControlCommand("HMC5883 ", RunOnce)requests one fresh sensor reading and updates the variables.sleep(100)waits 100 ms to avoid spamming the I2C bus.goto(loop)repeats the process forever until you stop the script.
Common Problems (Quick Fixes)
- EZ-B locks up when running the script: Usually means the sensor is not detected on I2C (loose cable, wrong port, incorrect wiring, or no power). Power down, re-check wiring, then try again.
-
No data changes: Confirm you ran
Initfirst, then callRunOncerepeatedly (the Skill does not auto-refresh). -
Control name mismatch: The name in
ControlCommand("HMC5883 ", ...)must match the Skill’s control name in ARC exactly.
Note: Synthiam is not the manufacturer of this third‑party hardware device, and EZ-Robot is not responsible for the operation of third‑party devices. For wiring details, calibration, specifications, and operational behavior of the HMC5883 module itself, refer to the manufacturer’s documentation.
