ESP8266 Intergration with circuit - newbie help please

Hello. I have successfully created a fall detection project whereby a 3 -axis accelerometer can detect a human fall occurring, in the event that the fall is true, the LED lights.

I would like to add an element whereby the is a sms or email notification sent alongside the LED lighting. I was planning on using the ESP8266 module to do this along with using the ‘If This Then That system’. However I am unsure how to wire and code the ESP8266 module. I have attached the code currently working and also an image of the circuit in its current state (the ESP8266 module is also shown in the image although it is not wired in)

Any help would be really apricated. This is a really important project.

#include "Wire.h"
const int MPU_addr=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
float ax=0, ay=0, az=0, gx=0, gy=0, gz=0;

//int data[STORE_SIZE][5]; //array for saving past data
//byte currentIndex=0; //stores current data array index (0-255)
boolean fall = false; //stores if a fall has occurred
boolean trigger1=false; //stores if first trigger (lower threshold) has occurred
boolean trigger2=false; //stores if second trigger (upper threshold) has occurred
boolean trigger3=false; //stores if third trigger (orientation change) has occurred

byte trigger1count=0; //stores the counts past since trigger 1 was set true
byte trigger2count=0; //stores the counts past since trigger 2 was set true
byte trigger3count=0; //stores the counts past since trigger 3 was set true
int angleChange=0;

void setup(){
 Wire.write(0x6B);  // PWR_MGMT_1 register
 Wire.write(0);     // set to zero (wakes up the MPU-6050)

 pinMode(11, OUTPUT);
 digitalWrite(11, LOW);
void loop(){

 //2050, 77, 1947 are values for calibration of accelerometer
 // values may be different for you
 ax = (AcX-2050)/16384.00;
 ay = (AcY-77)/16384.00;
 az = (AcZ-1947)/16384.00;

 //270, 351, 136 for gyroscope
 gx = (GyX+270)/131.07;
 gy = (GyY-351)/131.07;
 gz = (GyZ+136)/131.07;

 // calculating Amplitute vactor for 3 axis
 float Raw_AM = pow(pow(ax,2)+pow(ay,2)+pow(az,2),0.5);
 int AM = Raw_AM * 10;  // as values are within 0 to 1, I multiplied 
                        // it by for using if else conditions 


 if (trigger3==true){
    if (trigger3count>=10){ 
       angleChange = pow(pow(gx,2)+pow(gy,2)+pow(gz,2),0.5);
       if ((angleChange>=0) && (angleChange<=10)){ //if orientation changes remains between 0-10 degrees
           fall=true; trigger3=false; trigger3count=0;
       else{ //user regained normal orientation
          trigger3=false; trigger3count=0;
          Serial.println("TRIGGER 3 DEACTIVATED");
 if (fall==true){ //in event of a fall detection
   Serial.println("FALL DETECTED");
   digitalWrite(11, HIGH);
   digitalWrite(11, LOW);
  // exit(1);
 if (trigger2count>=6){ //allow 0.5s for orientation change
   trigger2=false; trigger2count=0;
   Serial.println("TRIGGER 2 DECACTIVATED");
 if (trigger1count>=6){ //allow 0.5s for AM to break upper threshold
   trigger1=false; trigger1count=0;
   Serial.println("TRIGGER 1 DECACTIVATED");
 if (trigger2==true){
   angleChange = pow(pow(gx,2)+pow(gy,2)+pow(gz,2),0.5); Serial.println(angleChange);
   if (angleChange>=30 && angleChange<=400){ //if orientation changes by between 80-100 degrees
     trigger3=true; trigger2=false; trigger2count=0;
     Serial.println("TRIGGER 3 ACTIVATED");
 if (trigger1==true){
   if (AM>=12){ //if AM breaks upper threshold (3g)
     Serial.println("TRIGGER 2 ACTIVATED");
     trigger1=false; trigger1count=0;
 if (AM<=2 && trigger2==false){ //if AM breaks lower threshold (0.4g)
   Serial.println("TRIGGER 1 ACTIVATED");
//It appears that delay is needed in order not to clog the port

void mpu_read(){
 Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
 Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers<<8|;  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)<<8|;  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)<<8|;  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)<<8|;  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)<<8|;  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)<<8|;  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)<<8|;  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)

ESP8266 is an IC. Which module with the ESP8266 do you actually have?

Using the ESP8266 module with the Arduino is no trivial task. I would even suggest using an all-in-module Wemos D1 that has wifi built in.


Okay thanks. I think I have an older version, I’ve attached the data sheet for the module I have.

ESP8266-01S Modul Datablatt.pdf (827 KB)

You have the ESP-01S which is the smallest module with the ESP8266. The Arduino Uno communicates with it via AT commands. You would need to use SoftwareSerial library.

Again. My suggestion is to use which you can program with Arduino IDE. zoomkat who knows a lot about the Arduino writes that it is very easy to use.