Components and supplies
Infrared Obstacle Sensor
SparkFun Triple Axis Accelerometer and Gyro Breakout - MPU-6050
Arduino Uno
Breadboard (generic)
Grove - Round Force Sensor (FSR402)
ESP8266 ESP-01
SparkFun Logic Level Converter - Bi-Directional
resister 3.3k ohm
Tools and machines
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Soldering iron (generic)
Solder Wire, Lead Free
10 Pc. Jumper Wire Kit, 5 cm Long
Apps and platforms
Arduino IDE
Blynk
Project description
Code
Arduino Coding
c_cpp
1#define BLYNK_PRINT Serial 2#include <ESP8266_Lib.h> 3#include <BlynkSimpleShieldEsp8266.h> 4#include <Wire.h> 5 6char auth[] = "jaSb-TjpYDLncLborLVE7IMo7A2xBl8i"; // enter your authentication token from your email 7char ssid[] = "AndroidAP"; // enter your wifi name 8char pass[] = "mzfx7476"; // enter your wifi password 9 10#include <SoftwareSerial.h> 11SoftwareSerial EspSerial(2, 3); // RX, TX 12 13#define ESP8266_BAUD 9600 // change your ESP8266 baudrate here 14 15ESP8266 wifi(&EspSerial); 16 17const int MPU_addr = 0x68; // I2C address of the MPU-6050 18int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ; 19 20//coding for MPU-6050 21void GetValues() 22{ 23 Wire.beginTransmission(MPU_addr); 24 Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H) 25 Wire.endTransmission(false); 26 Wire.requestFrom(MPU_addr, 14, true); // request a total of 14 registers 27 28 AcX = Wire.read() << 8 | Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L) 29 AcY = Wire.read() << 8 | Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L) 30 AcZ = Wire.read() << 8 | Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L) 31 Tmp = Wire.read() << 8 | Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L) 32 GyX = Wire.read() << 8 | Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L) 33 GyY = Wire.read() << 8 | Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L) 34 GyZ = Wire.read() << 8 | Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L) 35 36 Blynk.virtualWrite(3, AcX/16384.); 37 Blynk.virtualWrite(4, AcY/16384.); 38 Blynk.virtualWrite(5, AcZ/16384.); 39 Blynk.virtualWrite(6, GyX/131.); 40 Blynk.virtualWrite(7, GyY/131.); 41 Blynk.virtualWrite(8, GyZ/131.); 42 Blynk.virtualWrite(9, Tmp/340.+36.53); 43 44} 45 46WidgetLED led1(V1); //register to virtual pin 1 47BlynkTimer timer; // blynk timer delay 48int ir = 7; // declare ir sensor to digital pin 7 49int x = HIGH; // declare variable initally as high 50int fsr = A3; // declare fsr as A3 51int fsrRead; // initialize fsrRead 52// coding for IR Sensor 53void LedWidget() 54{ 55x = digitalRead(ir); 56if(x == LOW) 57{ 58 led1.on(); 59} 60else 61{ 62 led1.off(); 63} 64} 65 66 67 68// Coding for FSR 69void FSR() 70{ 71 fsrRead = analogRead(fsr); 72 Blynk.virtualWrite(V2,fsrRead); 73} 74void setup() 75{ 76 Serial.begin(9600); 77 pinMode(ir,INPUT); 78 EspSerial.begin(ESP8266_BAUD); 79 delay(10); 80 Blynk.begin(auth, wifi, ssid, pass); 81 Wire.begin(); 82 Wire.beginTransmission(MPU_addr); 83 Wire.write(0x6B); // PWR_MGMT_1 register 84 Wire.write(0); // set to zero (wakes up the MPU-6050) 85 Wire.endTransmission(true); 86 timer.setInterval(1000L, LedWidget); 87 timer.setInterval(1000L, FSR); 88 timer.setInterval(200L, GetValues); 89} 90void loop() 91{ 92 Blynk.run(); 93 timer.run(); 94} 95
Arduino Coding
c_cpp
1#define BLYNK_PRINT Serial 2#include <ESP8266_Lib.h> 3#include <BlynkSimpleShieldEsp8266.h> 4#include <Wire.h> 5 6char auth[] = "jaSb-TjpYDLncLborLVE7IMo7A2xBl8i"; // enter your authentication token from your email 7char ssid[] = "AndroidAP"; // enter your wifi name 8char pass[] = "mzfx7476"; // enter your wifi password 9 10#include <SoftwareSerial.h> 11SoftwareSerial EspSerial(2, 3); // RX, TX 12 13#define ESP8266_BAUD 9600 // change your ESP8266 baudrate here 14 15ESP8266 wifi(&EspSerial); 16 17const int MPU_addr = 0x68; // I2C address of the MPU-6050 18int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ; 19 20//coding for MPU-6050 21void GetValues() 22{ 23 Wire.beginTransmission(MPU_addr); 24 Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H) 25 Wire.endTransmission(false); 26 Wire.requestFrom(MPU_addr, 14, true); // request a total of 14 registers 27 28 AcX = Wire.read() << 8 | Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L) 29 AcY = Wire.read() << 8 | Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L) 30 AcZ = Wire.read() << 8 | Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L) 31 Tmp = Wire.read() << 8 | Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L) 32 GyX = Wire.read() << 8 | Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L) 33 GyY = Wire.read() << 8 | Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L) 34 GyZ = Wire.read() << 8 | Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L) 35 36 Blynk.virtualWrite(3, AcX/16384.); 37 Blynk.virtualWrite(4, AcY/16384.); 38 Blynk.virtualWrite(5, AcZ/16384.); 39 Blynk.virtualWrite(6, GyX/131.); 40 Blynk.virtualWrite(7, GyY/131.); 41 Blynk.virtualWrite(8, GyZ/131.); 42 Blynk.virtualWrite(9, Tmp/340.+36.53); 43 44} 45 46WidgetLED led1(V1); //register to virtual pin 1 47BlynkTimer timer; // blynk timer delay 48int ir = 7; // declare ir sensor to digital pin 7 49int x = HIGH; // declare variable initally as high 50int fsr = A3; // declare fsr as A3 51int fsrRead; // initialize fsrRead 52// coding for IR Sensor 53void LedWidget() 54{ 55x = digitalRead(ir); 56if(x == LOW) 57{ 58 led1.on(); 59} 60else 61{ 62 led1.off(); 63} 64} 65 66 67 68// Coding for FSR 69void FSR() 70{ 71 fsrRead = analogRead(fsr); 72 Blynk.virtualWrite(V2,fsrRead); 73} 74void setup() 75{ 76 Serial.begin(9600); 77 pinMode(ir,INPUT); 78 EspSerial.begin(ESP8266_BAUD); 79 delay(10); 80 Blynk.begin(auth, wifi, ssid, pass); 81 Wire.begin(); 82 Wire.beginTransmission(MPU_addr); 83 Wire.write(0x6B); // PWR_MGMT_1 register 84 Wire.write(0); // set to zero (wakes up the MPU-6050) 85 Wire.endTransmission(true); 86 timer.setInterval(1000L, LedWidget); 87 timer.setInterval(1000L, FSR); 88 timer.setInterval(200L, GetValues); 89} 90void loop() 91{ 92 Blynk.run(); 93 timer.run(); 94} 95
Arduino codes
c_cpp
1 2#define BLYNK_PRINT Serial 3#include <ESP8266_Lib.h> 4#include <BlynkSimpleShieldEsp8266.h> 5#include <Wire.h> 6 7char auth[] = "jaSb-TjpYDLncLborLVE7IMo7A2xBl8i"; // enter your authentication token from your email 8char ssid[] = "AndroidAP"; // enter your wifi name 9char pass[] = "mzfx7476"; // enter your wifi password 10 11#include <SoftwareSerial.h> 12SoftwareSerial EspSerial(2, 3); // RX, TX 13 14#define ESP8266_BAUD 9600 // change your ESP8266 baudrate here 15 16ESP8266 wifi(&EspSerial); 17 18const int MPU_addr = 0x68; // I2C address of the MPU-6050 19int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ; 20 21//coding for MPU-6050 22void GetValues() 23{ 24 Wire.beginTransmission(MPU_addr); 25 Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H) 26 Wire.endTransmission(false); 27 Wire.requestFrom(MPU_addr, 14, true); // request a total of 14 registers 28 29 AcX = Wire.read() << 8 | Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L) 30 AcY = Wire.read() << 8 | Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L) 31 AcZ = Wire.read() << 8 | Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L) 32 Tmp = Wire.read() << 8 | Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L) 33 GyX = Wire.read() << 8 | Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L) 34 GyY = Wire.read() << 8 | Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L) 35 GyZ = Wire.read() << 8 | Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L) 36 37 Blynk.virtualWrite(3, AcX/16384.); 38 Blynk.virtualWrite(4, AcY/16384.); 39 Blynk.virtualWrite(5, AcZ/16384.); 40 Blynk.virtualWrite(6, GyX/131.); 41 Blynk.virtualWrite(7, GyY/131.); 42 Blynk.virtualWrite(8, GyZ/131.); 43 Blynk.virtualWrite(9, Tmp/340.+36.53); 44} 45 46WidgetLED led1(V1); //register to virtual pin 1 47BlynkTimer timer; // blynk timer delay 48int ir = 7; // declare ir sensor to digital pin 7 49int x = HIGH; // declare variable initally as high 50int fsr = A3; // declare fsr as A3 51int fsrRead; // initialize fsrRead 52int reset = 8; // declare esp8 to digital pin 8 53 54// coding for IR Sensor 55void LedWidget() 56{ 57x = digitalRead(ir); 58if(x == LOW) 59{ 60 led1.on(); 61 digitalWrite(reset, LOW); 62} 63else 64{ 65 led1.off(); 66} 67} 68 69void FSR() // Coding for FSR 70{ 71 fsrRead = analogRead(fsr); 72 Blynk.virtualWrite(V2,fsrRead); 73} 74void setup() 75{ 76 Serial.begin(9600); 77 pinMode(ir,INPUT); 78 pinMode(reset,OUTPUT); 79 digitalWrite(reset,HIGH); 80 EspSerial.begin(ESP8266_BAUD); 81 delay(10); 82 Blynk.begin(auth, wifi, ssid, pass); 83 Wire.begin(); 84 Wire.beginTransmission(MPU_addr); 85 Wire.write(0x6B); // PWR_MGMT_1 register 86 Wire.write(0); // set to zero (wakes up the MPU-6050) 87 Wire.endTransmission(true); 88 timer.setInterval(1000L, LedWidget); 89 timer.setInterval(1000L, FSR); 90 timer.setInterval(200L, GetValues); 91} 92void loop() 93{ 94 Blynk.run(); 95 timer.run(); 96} 97
Downloadable files
schematic circuit diagram
schematic circuit diagram
schematic circuit diagram
schematic circuit diagram
Comments
Only logged in users can leave comments