Project tutorial
Wireless Magnetic Data Transfer

Wireless Magnetic Data Transfer © GPL3+

Using a 3D magnetic sensor and an electromagnet, this project enables you to transfer data via magnetic fields.

  • 26 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
3d 2go neu.jpg 1780796916
Infineon 3D Magnetic Sensor 2Go
Buy an electromagnet, or you can make one with magnet wire and an iron bolt like I did.
Relay Module (Generic)
11026 02
Jumper wires (generic)

Apps and online services

About this project

If you want to send data wirelessly, you have a plethora of options to choose from. From WiFi to BLE to LoRa radio, there's one for every occasion. However, if you want a solution that does not use radio waves, then this is the project for you!

Step 1: Wire the Arduino

Wire up the Arduino according to this schematic.

The input pin on the relay or relay module goes to pin 12 on the Arduino.

The electromagnet and the electromagnet power supply connects to the normally open contacts on the relay or relay module.

Step 2: Program the Arduino

Open up the Arduino IDE. If you don't have it, download it here. Copy/paste this code into the IDE, or download the code file here. Plug your Arduino into your computer, and make sure you have the correct board/port selected.

Tools > Board > Arduino/Genuino Uno

Tools > Port

Compile and upload the code.

int incomingByte = 0;   // for incoming serial data
int data = 0;
void setup() {
       Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
       pinMode(12, OUTPUT);
       Serial.println("Send a string of binary digits");
// main section
void loop() {
       // send data only when you receive data:
       if (Serial.available() > 0) {
               // read the incoming byte:
               incomingByte =;
               data = 1;
               if (incomingByte == 48) { // if it recevies a 0
                 digitalWrite(12, LOW); //turn off the magnet
               }else if (incomingByte == 49) { //if it recieves a 1
                 digitalWrite(12, HIGH); //turn on the magnet
       //clean things up        
         if (data == 1){
           digitalWrite(12, LOW);
           data = 0;

After the code successfully compiles and uploads, open up the Serial Monitor. Now, if you send a string of 1's and 0's, then you should hear your relay clicking.

Step 3: Install the GUI

Install the GUI for the 2GO 3D Magnetic Sensor here. Scroll to the bottom and find where it says "Free Download". Then download the GUI zip file. Follow the instructions to complete the installation. Besides the GUI, they will also install a USB driver.

Keep in mind that the software will only work on Windows, so if you are on a Mac, like me, then get a Windows computer or run a Windows virtual machine.

Step 4: Test the Setup!

Connect the 2GO sensor to your computer. Open up the GUI. Link it, then select "Fast Mode". You should start seeing sensor data immediately.

On the Arduino side of things, open up the Serial Monitor. Power the electromagnet, then send some 1's and 0's in the Serial Monitor. The relay should start clicking and you should see little pulses in the sensor GUI.

You now have a working project, but let's make it do something!

Step 5: Configure the IDE

To program the 2GO with the Arduino IDE, you will need to add it as a board first. In the IDE, go to File > Preferences > Additional Boards Manager URLs and paste in this link:

Then, go to Tools > Board > Boards Manager and search for 'XMC'. Click on it and then click Install.

You will also need to add the library to access the sensor. Go to Infineon's Github page and download file. Then, go to Sketch > Include Library > Add.ZIP Library...

Select file you downloaded earlier and click Choose.

Now, if you go to Sketch > Include Library and scroll down, you should see the TLE493D_W2B6 Library.

Step 6: Program the 2GO

Copy/paste the code into the IDE, or download the 3D_Sensor sketch here.

You can adjust the sensitivity in the 'sens' constant depending on if you have magnets nearby. To increase the sensitivity, decrease the 'sens' constant.

// set stuff up
#include <Tle493d_w2b6.h>
Tle493d_w2b6 mag3DSensor = Tle493d_w2b6();
// adjust sensitivity
const int sens = 1;
void setup() {
 // more setup
void loop() {
 // get sensor info
  //check if there's a magnet 
  if (abs(mag3DSensor.getX()) > sens || abs(mag3DSensor.getY()) > sens || abs(mag3DSensor.getZ()) > sens ) {
   //turn on the light
   digitalWrite(LED_BUILTIN, HIGH);
 } else {
   //turn off the light
   digitalWrite(LED_BUILTIN, LOW);
 // don't spam, kids

Step 7: Test the Whole Thing!

Place your electromagnet somewhere near the sensor. Connect the 2GO to power and the Arduino to your computer. Open up the Serial Monitor and send some 1's and 0's. The LED on the 2GO should light up and blink depending on what you sent. If it doesn't light up, try putting the electromagnet closer to the sensor. If that doesn't work, try adjusting the sensitivity. If it lights up but doesn't turn off, adjust the sensitivity. Also try unplugging it and plugging it back in.

Congrats! You're all done!

Going Further

This project is fairly simple and can be built on with other features. Add a button to the Arduino for a completely headless setup. Try connecting other things, like speakers. Wouldn't it be cool to stream music with a magnet? The possibilities are endless!



Magnet schematic vink4oj8gj


Similar projects you might like

Wireless Data Transmission using LIGHT. DIY Li-Fi

Project tutorial by Saad Saif

  • 6 respects

Data Transfer Using LED Light (Li-Fi)

Project tutorial by saadsaif0333

  • 5 respects

Arduino to VGA - Wireless Data Receiver

Project showcase by antiElectron

  • 18 respects

20bps Digital Data Wireless Transceiver (Laser)

Project tutorial by Achindra Bhatnagar

  • 1 comment
  • 13 respects
Add projectSign up / Login