Introduction: Magnetic Field of view Measurement Using HMC5883 and Particle Photon

The HMC5883 is a appendage compass designed for David Low-field magnetic perception. This gimmick has a wide magnetic flux range of +/-8 Oe and an output signal rate of 160 Hertz. The HMC5883 sensor includes automatic degaussing strap drivers, offset cancellation, and a 12-piece ADC that enables 1° to 2° compass heading accuracy. All I²C Miniskirt Modules are designed to operate at 5VDC.

In this tutorial, we are going to explain the detailed on the job of HMC5883 with particle photon. Particle photon is a board which facilitates sending and receiving data from the internet site, that is encouraging the most basic feature of Internet Of Things(IoT).

Step 1: Ironware Required:

The materials that we need for accomplishing our goal includes the following hardware components:

1. HMC5883

2. Particle Photon

3. I2C Cable television service

4. I2C Shield for Particle Photon

Step 2: Hardware Hookup:

The ironware assemblage part in essence explains the wiring connections needful 'tween the sensor and the particle photon. Ensuring correct connections is the basic requisite while working on some arrangement for the coveted turnout. So, the necessity connections are as follows:

The HMC5883 will beat up I2C . Here is the example wiring plot, demonstrating how to wire up each interface of the sensing element.

Proscribed-of-the-boxful, the board is configured for an I2C interface, in and of itself we urge using this hookup if you'rhenium otherwise agnostic. Totally you need is four wires!

Only iv connections are required Vcc, Gnd, SCL and SDA pins and these are connected with the facilitate of I2C cable.

These connections are demonstrated in the pictures above.

Step 3: Encode to Measuring stick Magnetic Flying field Volume:

Let's start with the particle cipher now.

While using the sensor module with the Arduino, we let in application.h and spark_wiring_i2c.h library. "application.h" and spark_wiring_i2c.h subroutine library contains the functions which facilitate the i2c communication between the sensor and the particle.

The entire particle code is given below for the convenience of the user:

<p>#include<application.h></p><p>#include<spark_wiring_i2c.h></p><p> // HMC5883 I2C address is 0x1E(30)</p><p>#define Addr 0x1E int xMag = 0, yMag =  0, zMag = 0;</p><p>void frame-up()</p><p>{    </p><p>// Set variable    </p><p>Particle.unsettled("i2cdevice", "HMC5883");    </p><p>Particle.variable("xMag", xMag);    </p><p>Particle.versatile("yMag", yMag);    </p><p>Particle.variable("zMag", zMag);      </p><p>// Format I2C communication As Overlord    </p><p>Wire.begin();    </p><p>// Initialise Serial Communication, set baud = 9600    </p><p>Serial.begin(9600);        </p><p>// Start I2C Transmission    </p><p>Wire.beginTransmission(Addr);    </p><p>// Select configure register A    </p><p>Wire.write(0x00);    </p><p>// Set normal measurement configuration, data output rank = 0.75Hz    </p><p>Wire.write out(0x60);    </p><p>// Stop I2C Transmission system    </p><p>Electrify.endTransmission();        </p><p>// Start I2C Transmission    </p><p>Wire.beginTransmission(Addr);    </p><p>// Select Mode register    </p><p>Wire.pen(0x02);    </p><p>// Set continuous measurement    </p><p>Wire.write(0x00);    </p><p>// Stop I2C Transmission    </p><p>Wire.endTransmission();    </p><p>delay(300);</p><p>}    </p><p>void loop()</p><p>{    </p><p>unsigned int data[6];    </p><p>// Start I2C Transmission    </p><p>Wire.beginTransmission(Addr);    </p><p>// Select data register    </p><p>Wire.write(0x03);    </p><p>// Occlusive I2C Transmission    </p><p>Electrify.endTransmission();</p><p>// Request 6 bytes of information    </p><p>Wire.requestFrom(Addr, 6);</p><p>// Read 6 bytes of data    </p><p>// xMag msb, xMag lsb, zMag msb, zMag lsb, yMag msb, yMag lsb    </p><p>if(Wire.available() == 6)    </p><p>{        </p><p>information[0] = Wire.read();        </p><p>data[1] = Wire.read();        </p><p>data[2] = Telegram.read();        </p><p>data[3] = Electrify.read();        </p><p>information[4] = Telegram.read();        </p><p>data[5] = Wire.read();   </p><p>}    </p><p>delay(300);          </p><p>// Change the data     </p><p>xMag = ((data[0] * 256) + information[1]);    </p><p>if(xMag > 32767)    </p><p>{        </p><p>xMag -= 65536;    </p><p>}    </p><p>zMag = ((data[2] * 256) + data[3]);    </p><p>if(zMag > 32767)    </p><p>{        </p><p>zMag -= 65536;    </p><p>}    </p><p>yMag = ((data[4] * 256) + data[5]);    </p><p>if(yMag > 32767)    </p><p>{        </p><p>yMag -= 65536;    </p><p>}        </p><p>// Output data to dashboard    </p><p>Particle.print("Flux in X-Axis : ", String(xMag));    </p><p>delay(1000);    </p><p>Subatomic particle.publish("Magnetised Area in Y-Axis : ", Drawing string(yMag));    </p><p>holdup(1000);    </p><p>Particle.publish("Magnetic Field in Z-Axis : ", Bowed stringed instrument(zMag));    </p><p>delay(1000);</p><p>}</p>

Particle.protean() function creates the variables to store the output of the sensor and Spec.publish() officiate displays the output on the splashboard of the site.

The sensing element end product is shown in the motion picture to a higher place for your cite.

Abuse 4: Applications:

HMC5883 is a surface-mount, multi-chipping module intentional for low-field magnetic detection with a digital port for applications such equally low cost compassing and magnetometry. Its one and only to two grade high level accuracy and precision enables Pedestrian Navigation and LBS Applications.

Be the First to Share

Recommendations

  • Anything Goes Contest 2022

    Anything Goes Contest 2022