Close

Detect Magnetic Field and current direction using MMC2460MT with ESP32 and Node-Red

varul-jainvarul jain wrote 03/06/2019 at 12:34 • 4 min read • Like

MMC2460MT I2C module already uses in Magnetic Compass application. But its also very useful in Industrial application

In this Blogtut we will be focusing on measuring the direction of current in Industrial pump armatures using Magnet sensor(interface with ESP32) and can display the measurement in the Node-Red dashboard

Hardware Required

MMC246xMT

ESP32

Software

Arduino

Node-Red

About MMC2460MT

The modular breakout board using 4mbps I2C transmission between sensor and microcontrollers like ArduinoRaspberry PiEsp8266ESP32 etc. measures the magnetic field in 2 Axis (X axis and Y axis) which measure the magnetic field in gauss units. The Sensor shares its importance especially in the application like Electronic CompassingGPS Navigation AssistMagnetic Field Measurement.

Application

Well, as per mentioned above application we have tested this Sensor with a slightly different way by using the sensor with electric motor Pumps. As the pump Consist of armature coil which the Electromagnetic field effect. As some earlier EMF methods, we know about Right-Hand thumb rule and knowing about the Current and Magnetic field directions.

We can manipulate the parameters according to the requirement and can test the current direction according

Note: When Sensor is not near the Electric Pump Armatures then it will give you a constant garbage value which is not the point to worry.

I2C Code

Mentioned below sample code will help you to test the magnetic effectswhich I have mentioned in application topic but there are more advanced ways to monitor the sensor data which will be useful respective to its applications and physics formulas implemented accordingly.

#include <Wire.h>
#define Addr 0x30
Wire.begin(21,22);
Serial.begin(115200);
setup_wifi(); //We will be using simple Wifi.h library
if(Wire.available() == 4)  {    data[0] = Wire.read();    data[1] = Wire.read();    data[2] = Wire.read();    data[3] = Wire.read();    delay(100);  }
int xMag = ((data[1] * 256) + data[0]);
int yMag = ((data[3] * 256) + data[2]);

Node-Red

As Node-Red is a great platform to monitor your sensor data with the help of sensor dashboard but to work with this application it's better to start with setup tutorial which we have earlier mentioned in Blogtut.

With the help of earlier Blogtut, you will be able to monitor the sensor data through Serial protocol using Serial Node or using MQTT protocol which is very much famous in many IOT platforms nowadays. But to start with the basic setup we should go through Node-Red MQTT node which will surely help you out in understanding the mechanism of MQTT protocol.

Output

Mentioned Below Are the output which you will be able to check out from Debug node as well as through Dashboard

Code


https://github.com/varul29/Node-Red_Tutorial

https://github.com/varul29/MMC2460MT_ESP32_Node-Red

Credits

Node-Red Comunity

NCD Community

Control everything

Like

Discussions