Altitude using BMP180

This project make Altitude measuring using BMP180 pressure sensor convert pressure to be altitude.

GY-68 Module

GY-68 BMP180 Digital Barometric Pressure Sensor Board Module for for RC Drone FPV Racing Multi Rotor

Wiring

 

Hardware connections:

– (GND) to GND
+ (VDD) to 3.3V

(WARNING: do not connect + to 5V or the sensor will be damaged!)

You will also need to connect the I2C pins (SCL and SDA) to your
Arduino. The pins are different on different Arduinos:

Any Arduino pins labeled: SDA SCL
Uno, Redboard, Pro: A4 A5
Mega2560, Due: 20 21
Leonardo: 2 3

 

Code

 

Load SFE BMP180 Library  link  :  https://drive.google.com/file/d/1QoBl_1UGxN0x1gEmGAnUGPopdML4bjRN/view?usp=sharing

/* SFE_BMP180 altitude example sketch

This sketch shows how to use the Bosch BMP180 pressure sensor
as an altimiter.
https://www.sparkfun.com/products/11824

Like most pressure sensors, the BMP180 measures absolute pressure.
Since absolute pressure varies with altitude, you can use the pressure
to determine your altitude.

Because pressure also varies with weather, you must first take a pressure
reading at a known baseline altitude. Then you can measure variations
from that pressure





Hardware connections:

- (GND) to GND
+ (VDD) to 3.3V

(WARNING: do not connect + to 5V or the sensor will be damaged!)

You will also need to connect the I2C pins (SCL and SDA) to your
Arduino. The pins are different on different Arduinos:

Any Arduino pins labeled: SDA SCL
Uno, Redboard, Pro: A4 A5
Mega2560, Due: 20 21
Leonardo: 2 3

Leave the IO (VDDIO) pin unconnected. This pin is for connecting
the BMP180 to systems with lower logic levels such as 1.8V

Have fun! -Your friends at SparkFun.

The SFE_BMP180 library uses floating-point equations developed by the
Weather Station Data Logger project: http://wmrx00.sourceforge.net/

Our example code uses the "beerware" license. You can do anything
you like with this code. No really, anything. If you find it useful,
buy me a beer someday.

V10 Mike Grusin, SparkFun Electronics 10/24/2013
V1.1.2 Updates for Arduino 1.6.4 5/2015
*/

// Your sketch must #include this library, and the Wire library.
// (Wire is a standard library included with Arduino.):

#include <SFE_BMP180.h>
#include <Wire.h>

// You will need to create an SFE_BMP180 object, here called "pressure":

SFE_BMP180 pressure;

double baseline; // baseline pressure

void setup()
{
Serial.begin(9600);
Serial.println("REBOOT");

// Initialize the sensor (it is important to get calibration values stored on the device).

if (pressure.begin())
Serial.println("BMP180 init success");
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.

Serial.println("BMP180 init fail (disconnected?)\n\n");
while(1); // Pause forever.
}

// Get the baseline pressure:

baseline = getPressure();

Serial.print("baseline pressure: ");
Serial.print(baseline);
Serial.println(" mb");
}

void loop()
{
double a,P;

// Get a new pressure reading:

P = getPressure();

// Show the relative altitude difference between
// the new reading and the baseline reading:

a = pressure.altitude(P,baseline);

Serial.print("relative altitude: ");
if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
Serial.print(a,1);
Serial.print(" meters, ");
if (a >= 0.0) Serial.print(" "); // add a space for positive numbers
Serial.print(a*3.28084,0);
Serial.println(" feet");

delay(500);
}

double getPressure()
{
char status;
double T,P,p0,a;

// You must first get a temperature measurement to perform a pressure reading.

// Start a temperature measurement:
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.

status = pressure.startTemperature();
if (status != 0)
{
// Wait for the measurement to complete:

delay(status);

// Retrieve the completed temperature measurement:
// Note that the measurement is stored in the variable T.
// Use '&T' to provide the address of T to the function.
// Function returns 1 if successful, 0 if failure.

status = pressure.getTemperature(T);
if (status != 0)
{
// Start a pressure measurement:
// The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.

status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);

// Retrieve the completed pressure measurement:
// Note that the measurement is stored in the variable P.
// Use '&P' to provide the address of P.
// Note also that the function requires the previous temperature measurement (T).
// (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
// Function returns 1 if successful, 0 if failure.

status = pressure.getPressure(P,T);
if (status != 0)
{
return(P);
}
else Serial.println("error retrieving pressure measurement\n");
}
else Serial.println("error starting pressure measurement\n");
}
else Serial.println("error retrieving temperature measurement\n");
}
else Serial.println("error starting temperature measurement\n");
}




MIT Inventor application control robot using WiFi

 

VDO

 

Code

#include <ESP8266WiFi.h>

/* define port */
WiFiClient client;
WiFiServer server(80);

/* WIFI settings */
const char* ssid = "your wifi";
const char* password = "wifi password";

/* connect WiFi*/

/* data received from application */
String  data =""; 

/* define L298N or L293D motor control pins */
int leftMotorForward = 2;     /* GPIO2(D4) -> IN3   */
int rightMotorForward = 15;   /* GPIO15(D8) -> IN1  */
int leftMotorBackward = 0;    /* GPIO0(D3) -> IN4   */
int rightMotorBackward = 13;  /* GPIO13(D7) -> IN2  */


/* define L298N or L293D enable pins */
int rightMotorENB = 14; /* GPIO14(D5) -> Motor-A Enable */
int leftMotorENB = 12;  /* GPIO12(D6) -> Motor-B Enable */

void setup()
{

  Serial.begin(9600);
  
  /* initialize motor control pins as output */
  pinMode(leftMotorForward, OUTPUT);
  pinMode(rightMotorForward, OUTPUT); 
  pinMode(leftMotorBackward, OUTPUT);  
  pinMode(rightMotorBackward, OUTPUT);

  /* initialize motor enable pins as output */
  pinMode(leftMotorENB, OUTPUT); 
  pinMode(rightMotorENB, OUTPUT);

  /* start server communication */
  connectWiFi();
  server.begin();
}

void loop()
{
    /* If the server available, run the "checkClient" function */  
    client = server.available();
    if (!client) return; 
    data = checkClient ();

/************************ Run function according to incoming data from application *************************/

    /* If the incoming data is "forward", run the "MotorForward" function */
    if (data == "forward") MotorForward();
    /* If the incoming data is "backward", run the "MotorBackward" function */
    else if (data == "backward") MotorBackward();
    /* If the incoming data is "left", run the "TurnLeft" function */
    else if (data == "left") TurnLeft();
    /* If the incoming data is "right", run the "TurnRight" function */
    else if (data == "right") TurnRight();
    /* If the incoming data is "stop", run the "MotorStop" function */
    else if (data == "stop") MotorStop();

    Serial.println(data);
} 

/********************************************* FORWARD *****************************************************/
void MotorForward(void)   
{
  digitalWrite(leftMotorENB,HIGH);
  digitalWrite(rightMotorENB,HIGH);
  digitalWrite(leftMotorForward,HIGH);
  digitalWrite(rightMotorForward,HIGH);
  digitalWrite(leftMotorBackward,LOW);
  digitalWrite(rightMotorBackward,LOW);
}

/********************************************* BACKWARD *****************************************************/
void MotorBackward(void)   
{
  digitalWrite(leftMotorENB,HIGH);
  digitalWrite(rightMotorENB,HIGH);
  digitalWrite(leftMotorBackward,HIGH);
  digitalWrite(rightMotorBackward,HIGH);
  digitalWrite(leftMotorForward,LOW);
  digitalWrite(rightMotorForward,LOW);
}

/********************************************* TURN LEFT *****************************************************/
void TurnLeft(void)   
{
  digitalWrite(leftMotorENB,HIGH);
  digitalWrite(rightMotorENB,HIGH); 
  digitalWrite(leftMotorForward,LOW);
  digitalWrite(rightMotorForward,HIGH);
  digitalWrite(rightMotorBackward,LOW);
  digitalWrite(leftMotorBackward,HIGH);  
}

/********************************************* TURN RIGHT *****************************************************/
void TurnRight(void)   
{
  digitalWrite(leftMotorENB,HIGH);
  digitalWrite(rightMotorENB,HIGH);
  digitalWrite(leftMotorForward,HIGH);
  digitalWrite(rightMotorForward,LOW);
  digitalWrite(rightMotorBackward,HIGH);
  digitalWrite(leftMotorBackward,LOW);
}

/********************************************* STOP *****************************************************/
void MotorStop(void)   
{
  digitalWrite(leftMotorENB,LOW);
  digitalWrite(rightMotorENB,LOW);
  digitalWrite(leftMotorForward,LOW);
  digitalWrite(leftMotorBackward,LOW);
  digitalWrite(rightMotorForward,LOW);
  digitalWrite(rightMotorBackward,LOW);
}

/********************************** RECEIVE DATA FROM the APP ******************************************/
String checkClient (void)
{
  while(!client.available()) delay(1); 
  String request = client.readStringUntil('\r');
  request.remove(0, 5);
  request.remove(request.length()-9,9);
  return request;
}

void connectWiFi()
{
  Serial.println("Connecting to WIFI");
  WiFi.begin(ssid, password);
  while ((!(WiFi.status() == WL_CONNECTED)))
  {
    delay(300);
    Serial.print("..");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("NodeMCU Local IP is : ");
  Serial.print((WiFi.localIP()));
}




GSM SIM900 Module Control relay

Wiring all same previous blog just add relay module

Connect 4 Relays module to Arduino Board

Wiring

4 Relays module     to       Board Arduino

Vcc                                     5 Volt

IN1                                     Pin 4

IN2                                     Pin 5

IN3                                     Pin 6

IN4                                     Pin 7

GND                                   GND

Concept

Idea

Send sms

a1  relay  IN1 on

a?  relay  IN1 off

b1  relay  IN2 on

b?  relay  IN2 off

c1  relay  IN3 on

c?  relay  IN3 off

d1  relay  IN4 on

d?  relay  IN4 off

x1  All relay  on

x?  All relay  off

Library

https://drive.google.com/open?id=1MwINDk0QBViC31dtLt47_aGRQZvwQkhq

VDO

 

Code

#include "SIM900.h"

#include <SoftwareSerial.h>

//If not used, is better to exclude the HTTP library,

//for RAM saving.

//If your sketch reboots itself proprably you have finished,

//your memory available.

//#include "inetGSM.h"

//If you want to use the Arduino functions to manage SMS, uncomment the lines below.

#include "sms.h"

SMSGSM sms;

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino

//www.open-electronics.org

//this code is based on the example of Arduino Labs.

//Simple sketch to send and receive SMS.

int numdata;

boolean started=false;

char smsbuffer[160];

char n[20];

void setup()

{

  pinMode(4, OUTPUT);

  pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);

  pinMode(7, OUTPUT);

  digitalWrite(4, HIGH);

  digitalWrite(5, HIGH);

  digitalWrite(6, HIGH);

  digitalWrite(7, HIGH);

     //Serial connection.

     Serial.begin(9600);

     Serial.println("GSM Shield testing.");

     //Start configuration of shield with baudrate.

     //For http uses is raccomanded to use 4800 or slower.

     if (gsm.begin(2400)) {

          Serial.println("\nstatus=READY");

          started=true;

     } else Serial.println("\nstatus=IDLE");

     

     if(started) {

          //Enable this two lines if you want to send an SMS.

          if (sms.SendSMS("your phone number", "GSM SmartHome"))

          Serial.println("\nSMS sent OK");

     }

};

void loop()

{

     if(started) {

      

          //Read if there are messages on SIM card and print them.

          if(gsm.readSMS(smsbuffer, 160, n, 20)) {

            

               Serial.println(n);  //Print out phone number

               Serial.println(smsbuffer); // Text 

              char* ptr = smsbuffer;

  while ( strlen(ptr) >= 2 ) {

    if ( ptr[0] == 'a' ) {

      if ( ptr[1] == '1' )

        digitalWrite(4, LOW);

      else

        digitalWrite(4, HIGH);

    }

    if ( ptr[0] == 'b' ) {

      if ( ptr[1] == '1' )

        digitalWrite(5, LOW);

      else

        digitalWrite(5, HIGH);

    }

     if ( ptr[0] == 'c' ) {

      if ( ptr[1] == '1' )

        digitalWrite(6, LOW);

      else

        digitalWrite(6, HIGH);

    }

    if ( ptr[0] == 'd' ) {

      if ( ptr[1] == '1' )

        digitalWrite(7, LOW );

      else

        digitalWrite(7, HIGH);

    }

     if ( ptr[0] == 'x') {

      if ( ptr[1] == '1'){

        digitalWrite(4,LOW);

        digitalWrite(5,LOW);

        digitalWrite(6,LOW);

        digitalWrite(7,LOW);}

         

     else

     {

        digitalWrite(4,HIGH);

        digitalWrite(5,HIGH);

        digitalWrite(6,HIGH);

        digitalWrite(7,HIGH);

      }

     }

    

  

    ptr += 2;

  }

          }

          delay(1000);

     }

};

GSM sim900 + GPS real time location No wifi

This project will explain how to read GPS send to serial pin RX,TX of arduino  then GSM  connect software serial send location to your phone .

This project you can apply to security your car ,home security .

Image result for googlemap

Wiring

GPS to Arduino Nano

TX >>> RX

RX>>> TX

GSM to Nano

TX >>> pin7

RX>>> pin8

Make sure all ground common .


Click detail GSM Sim 900 :  https://goo.gl/MZjRei

GPS module : https://goo.gl/Yokhsb



Code


#include <TinyGPS.h>

#include <SoftwareSerial.h>
SoftwareSerial Gsm(7, 8);
char phone_no[] = "0843XXXXXX"; //replace with phone no. to get sms
TinyGPS gps;  //Creates a new instance of the TinyGPS object

void setup()

{

  Serial.begin(9600);
  Gsm.begin(9600);  

}

void loop()




{

  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values

  for (unsigned long start = millis(); millis() - start < 1000;)

  {

    while (Serial.available())

    {
      char c = Serial.read();
      Serial.print(c);
      if (gps.encode(c))
        newData = true;  

    }

  }

  if (newData)      //If newData is true
  {
    float flat, flon;
    unsigned long age;
    gps.f_get_position(&flat, &flon, &age);
    Gsm.print("AT+CMGF=1\r");
    delay(400);
    Gsm.print("AT+CMGS=\"");
    Gsm.print(phone_no);
    Gsm.println("\"");

    delay(300);
    Gsm.print("http://maps.google.com/maps?q=loc:");
   // Gsm.print("Latitude = ");
    Gsm.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
    //Gsm.print(" Longitude = ");
    Gsm.print(",");
    Gsm.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
    delay(200);
    Gsm.println((char)26); // End AT command with a ^Z, ASCII code 26
    delay(200);
    Gsm.println();
    delay(20000);
  }

  Serial.println(failed);
 // if (chars == 0)
   // Serial.println("** No characters received from GPS: check wiring **");
}





VDO

Build mini CNC step by step Using Arduino UNO + Shield CNC + A4988 stepping motor drive

Hard ware

 

 

Hardware list

1. 2x old CD-Rom

2.Arduino UNO

3. CNC Shield

4. A4988 stepping motor drive

5. Wire

Step

1.Add grbl-mi to Arduino sketch
  เพิ่ม โปรแกรม grbl-mi ลงใน โปรแกรม Arduino

2.Add MI Inkscape Extension
 เพิ่่ม MI Inkscape Extension ลงในโปรแกรม Inkscape

3.Inkscape in attach no need install.
โปรแกรม Inkscape ใช้ได้เลยโดยไม่ต้อง Install

4.UGCS for run CNC
โปรแกรม UGCS สำหรับควบคุม CNC

Add grbl Library

Add MI Inkscape Extension

 

Link Software

All Program :   https://drive.google.com/open?id=1i1WOzN0RH0kaNp0T9LAvTxPWyOmxiTWC

UGCShttps://drive.google.com/open?id=1iiPgCxtbIL0MtxZL0zQ0YwOxZVu45r80

VDO