- 1. Arduino Uno
2. Cytron Wifi Shield
3. MPU6050
mpu6050 coding: https://github.com/Tockn/MPU6050_tockn
the task is simple, MPU gives data to Arduino, Arduino sends to Blynk through Wifi Shield. but if it try to use shield and MPU together, the shield seems to unable to retrieve any readings from the MPU. but the shield do connected to Blynk.
here is my code:
- CODE: SELECT_ALL_CODE
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SoftwareSerial.h>
#include <MPU6050_tockn.h>
#include <Wire.h>
char auth[] = "1oMINWmxjv0acmBUFB_TmGkbUlTEG9Jz";
char ssid[] = "SALTECH";
char pass[] = "soleh123";
SoftwareSerial EspSerial(2, 3); // RX, TX
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
MPU6050 mpu6050(Wire);
long timer = 0;
BlynkTimer timero;
void mpu() {
mpu6050.update();
int accx = mpu6050.getAccX();
int accy = mpu6050.getAccY();
int accz = mpu6050.getAccZ();
Blynk.virtualWrite(V5, accx);
Blynk.virtualWrite(V6, accy);
Blynk.virtualWrite(V7, accy);
}
void setup() {
Serial.begin(9600);
Wire.begin();
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
mpu6050.begin();
mpu6050.calcGyroOffsets(true);
timero.setInterval(1000L, mpu);
}
void loop() {
Blynk.run();
timero.run();
}
can anyone point out solutions?