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.

  • 5,729 views
  • 4 comments
  • 23 respects

Components and supplies

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

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("Starting...");
       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 = Serial.read();
               data = 1;
               if (incomingByte == 48) { // if it recevies a 0
                 digitalWrite(12, LOW); //turn off the magnet
                 Serial.print("0");
                 delay(100);
               }else if (incomingByte == 49) { //if it recieves a 1
                 digitalWrite(12, HIGH); //turn on the magnet
                 Serial.print("1");
                 delay(100);
               }else{
                 Serial.print("?");
               }
       //clean things up        
       }else{
         if (data == 1){
           digitalWrite(12, LOW);
           Serial.println("");
           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:

https://github.com/Infineon/Assets/releases/download/current/package_infineon_index.json

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 the.zip file. Then, go to Sketch > Include Library > Add.ZIP Library...

Select the.zip 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
 mag3DSensor.begin();
 mag3DSensor.enableTemp();
 pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
 // get sensor info
 mag3DSensor.updateData();
  //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
 delay(50);
}

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!

Code

Schematics

Schematic
Magnet schematic vink4oj8gj

Comments

Author

989e70d7 954a 4867 b63c 7c9fccce072d krdh24yp00
Tomi Chen
  • 2 projects
  • 17 followers

Published on

June 11, 2018

Members who respect this project

PhotoDefault%db%b2%db%b0%db%b1%db%b6%db%b0%db%b9%db%b0%db%b3 %db%b2%db%b0%db%b3%db%b7%db%b1%db%b4ErospeterImg013 3wk6r3an541012043DefaultPhoto

and 14 others

See similar projects
you might like

Similar projects you might like

Arduino to VGA - Wireless Data Receiver

Project showcase by antiElectron

  • 2,594 views
  • 0 comments
  • 14 respects

20bps Digital Data Wireless Transceiver (Laser)

Project tutorial by Achindra Bhatnagar

  • 2,276 views
  • 1 comment
  • 9 respects

RGB Infinity Mirror with 3D Magnetic Sensor

Project tutorial by Abdullah Sadiq

  • 2,744 views
  • 2 comments
  • 11 respects

Temperature and Humidity Data Logger

Project tutorial by Wimpie van den Berg

  • 23,407 views
  • 2 comments
  • 22 respects

The Magnetic Field and RGB Tester

Project tutorial by Kutluhan Aktar

  • 3,530 views
  • 0 comments
  • 14 respects

Wireless Keyboard from TV Remote

Project tutorial by Amal Mathew

  • 3,885 views
  • 2 comments
  • 15 respects
Add projectSign up / Login