Controlling Servos by MPU 6050 Acc/Gyro via Wireless Medium

I am building a Project “Controlling Servos by MPU 6050 Acc/Gyro via Wireless Medium”. Wireless medium for now i am using 433 MHZ RF Transmitter/ Receiver Module.
I am able to establish connection bw Servos and MPU6050 through a Wired Connection but Need Help in Establishing Connection through a Wirelesss Meduim.

Need Help in Coding For the Transmitter and Receiver. I Understand only the basics of the coding and Hence could not Start the Coding.

Please Help with the Coding or Guide how to Establish Connection through a Wirelesss Meduim.
Thank you

We will need more details about your setup to be able to help. How did you manage to connect the Servos to the MPU6050? Are you using a microcontroller such as an Arduino? If you have pictures, that would help.

For the wireless link, will you be using second microcontroller? You will likely need one for the transmitted and the receiver.

If you have any RobotShop part numbers, please share them because it will give us more information about what parts you are using. Or if not, we would need some datasheets or pictures…

Hope this helps,

i am Using Two Arduino Boards, ill share the code from which i controlled servos with the Help of MPU6050.

#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050.h"
#include  <Servo.h>

MPU6050 mpu;

int16_t ax, ay, az;
int16_t gx, gy, gz;

Servo Xservo;
Servo Yservo;

int valX;
int prevValX;
int valY;
int prevValY;

void setup()
{
  Wire.begin();
  Serial.begin(38400);

  Serial.println("Initialize MPU");
  mpu.initialize();
  Serial.println(mpu.testConnection() ? "Connected" : "Connection failed");
  Xservo.attach(A0);
  Yservo.attach(A1);
}

void loop()
{
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

  valX = map(ax, 17000, -17000, 119, 179);
  if (valX != prevValX)
  {
    Xservo.write(valX);
    prevValX = valX;
  }

  valY = map(ay, -17000, 17000, 119, 179);
  if (valY != prevValY)
  {
    Yservo.write(valY);
    prevValY = valY;
  }
  delay(90);
}

dropbox.com/sm/create/IMAG0308.jpg

dropbox.com/sm/create/IMAG0308.jpg

here is the image of the products i am using
2 Arduinos
1 MPU6050
433 MHZ RF TX/RX

Code for 433 MHZ RF TX/RX

Code for Transmitter

[code]#include <VirtualWire.h>
void setup()
{
vw_set_ptt_inverted(true); // Required by the RF module
vw_setup(2000); // bps connection speed
vw_set_tx_pin(3); // Arduino pin to connect the receiver data pin
}

void loop()
{
//Message to send:
const char *msg = “Hello World”;
vw_send((uint8_t *)msg, strlen(msg));

vw_wait_tx(); // We wait to finish sending the message
delay(200); // We wait to send the message again
}
[/code]

Code for Receiver

[code]
#include <VirtualWire.h>

void setup()
{
Serial.begin(9600); // Configure the serial connection to the computer
vw_set_ptt_inverted(true); // Required by the RF module
vw_setup(2000); // bps connection speed
vw_set_rx_pin(3); // Arduino pin to connect the receiver data pin
vw_rx_start(); // Start the receiver
}

void loop()
{

uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // We check if we have received data
{
int i;
// Message with proper check
for (i = 0; i < buflen; i++)
{
Serial.write(buf); // The received data is stored in the buffer
// and sent through the serial port to the computer
}
Serial.println();

}
}
[/code]*

i am not able to intrigate both the codes in one…MPU 6050 Controlling Servos via 433 MHZ RF…or can be with any for eg XBee.

Need Help with the Coding part.

thank you*

Hmm, your Dropbox image link doesn’t seem to be valid… Can you try posting it again using the share link?

Have you tested these two code samples with your transmitter and receiver? And do they work like you need?

If so, you should be able to integrate your original code with the transmitter code by replace the servo write function calls with something like this (for X):


 if (valX != prevValX)
 {
   const char *msg = "xx0";
   msg[1] = valX;
   vw_send((uint8_t *)msg, strlen(msg));
   vw_wait_tx();    // We wait to finish sending the message
   prevValX = valX;
 }

And do the same for Y.

You will then need to modify your receiver code to distinguish between “xx” and “yy”, and then send the next value to the right servo.