Things used in this project

Hardware components:
Ardgen 101
Arduino 101 & Genuino 101
×1
SparkFun Flex Sensor
×2
Adafruit industries ada1536 image
Buzzer
×1
Mfr 25frf52 10k sml
Resistor 10k ohm
×2
Software apps and online services:
Blynk logo avatars
Blynk
Ide web
Arduino IDE

Schematics

Fritzing Diagram
flex_uKCczB7QHe.fzz

Code

Arduino101CodeArduino
/*This code file is related to the "Structure Analyzer" which
 * is a device to maintain the standards and levels of many
 * types of structures.
 * Developed by Tharindu Suraj. 14/03/2017
 */

#define BLYNK_PRINT Serial
#define flex1 A0
#define flex2 A1          //Define flex sensor and buzzer pins
#define buzzer 3

#include "CurieIMU.h"
#include <BlynkSimpleCurieBLE.h>
#include <CurieBLE.h>
#include <Wire.h>
#include <EEPROM.h>
#include <SPI.h>

char auth[] = "**************";          //Blynk Authorization Code

WidgetTerminal terminal(V2);
BLEPeripheral  blePeripheral;

int m_flx1,m_flx2,m_x,m_y,m_z; //values saved in memory
int flx1, flx2,x,y,z; //Current readings

void values(){
  for(int i=0;i<100;i++){
    flx1 = analogRead(flex1);        //Get raw readings from sensors
    flx2 = analogRead(flex2);
    x = CurieIMU.readAccelerometer(X_AXIS)/100;
    y = CurieIMU.readAccelerometer(Y_AXIS)/100;
    z = CurieIMU.readAccelerometer(Z_AXIS)/100;
    delay(2);
    }
    flx1=flx1/100;
    flx2=flx2/100;
    x = x/100;   //Get the average values of the readings
    y = y/100;
    z = z/100;
}

void setup(){
  //pinMode(3,OUTPUT);
  pinMode(flex1,INPUT);
  pinMode(flex2,INPUT);          //Setting the sensor pin modes
  
  Serial.begin(9600);

  blePeripheral.setLocalName("Arduino101Blynk");
  blePeripheral.setDeviceName("Arduino101Blynk");
  blePeripheral.setAppearance(384);
  Blynk.begin(auth, blePeripheral);
  blePeripheral.begin();

  m_flx1 = EEPROM.read(0);
  m_flx2 = EEPROM.read(1);
  m_x = EEPROM.read(2);        //Read pre saved sensor values from EEPROM
  m_y = EEPROM.read(3);
  m_z = EEPROM.read(4);
  
}


void loop(){
  Blynk.run();
  blePeripheral.poll();

  values();

  if(abs(flex1-m_flx1)>10 or abs(flex2-m_flx2)>10){
    terminal.println("Over Bend");
   tone(buzzer, 1000); 
  }

  if(abs(x-m_x)>15 or abs(y-m_y)>15 or abs(z-m_z)>15){
    terminal.println("Over Inclined");
 tone(buzzer, 1000);  
  }

   tone(buzzer, 0);  
  }
  
/*VO indicates the calibration mode. In this mode the values of sensors
 * are saved in the EEPROM
 */
BLYNK_WRITE(V0){
  int pinValue = param.asInt();

  if (pinValue == 1){
   values();
   EEPROM.write(0,flx1);
   EEPROM.write(1,flx2);    
   EEPROM.write(2,x);  
   EEPROM.write(3,y);  
   EEPROM.write(4,z);
   terminal.print("Calibration Succesful");
  }                             
}

/*We can request current deviation values 
 * by pressing the button V1
 */

BLYNK_WRITE(V1){  
   int pinValue = param.asInt();

   if (pinValue == 1){                                                  
        values();
        terminal.print("X angle deviation- ");
        terminal.print(abs(x-m_x));
        terminal.println();
        terminal.print("Y angle deviation- ");
        terminal.print(abs(y-m_y));
        terminal.println();
        terminal.print("Z angle deviation- ");
        terminal.print(abs(z-m_z));
        terminal.println();
        terminal.print("Flex 1 deviation- ");
        terminal.print(abs(flx1-m_flx1));
        terminal.println();
        terminal.print("Flex 2 deviation- ");
        terminal.print(abs(flx2-m_flx2));
        terminal.println();
           }
      }
  
BLYNK_WRITE(V2){                                                   
         
      }

Credits

1185269 600539309969110 1497221537 n wibtqfvbgc
Tharindu Suraj
1 project • 4 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog