Project tutorial
Safe City: A Device to Keep You Safe

Safe City: A Device to Keep You Safe © GPL3+

The device will keep you safe. Just have to click a button and your precise location will be shared.

  • 7,917 views
  • 0 comments
  • 24 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

This protection device will keep you safe by just pressing a button. If you are in Danger, just press the button and your location will be shared on any website you select in code. By the use of Infineon DPS310 pressure sensor, altitude of person in building can also be detected for precise location.

Imagine a situation like GTA Vice city where you see the place in the city with red spot but you can't see the the floor number or altitude so that you can have the exact location. The same thing might happen to rescue team and thus this device is necessary.

The Device will run on 9 V Battery. It is handy device. You can make enclosure and keep the circuit in it. The steps are as follows....

Step 1: Power Supply

Here we will use 9v Battery for power supply. We will need 7805 Voltage Regulator IC to get 9V. Then from 7805 IC, feed it to arduino.

Step 2: Connecting ESP266 and powering it

Connect the Arduino’s 3v3 (3.3V) output to ESP8266. The ESP8266 works with 3.3V and not 5V, so this is necessary.

Step 3: Connect RX and TX

Connect the RXD pin of the Arduino to the RX pin of the ESP8266.Connect the TXD pin of the Arduino to the TX pin of the ESP. When we want two things to talk to each other over serial, we connect the TX pin of one to the RX of the other (send goes to receive and the opposite). Here we do not have the Arduino talk to the ESP8266 though, our computer is talking to it via the Arduino.

Step 4: GND and RST

Connect the RES or RESET pin, When you ground the reset pin, the Arduino works as a dumb USB to serial connector, which is what we want to talk to the ESP8266.

Step 5: Button

Finally add a button at power supply.

Step 6: In Arduino IDE

In the Arduino IDE, you don’t need to choose a board, as we’re not uploading anything to the ESP8266. Just choose the right port in the Tools menu and go to ToolsSerial Monitor. Then simply set your baud rate to 115200 (the default ESP8266 firmware uses it) and your line endings to Both NL & CR.And since we talked about the CH_PD pin, remember that if you want to flash the ESP8266 you should connect the GPIO0 pin.

Step 7: Connecting DPS310

We are doing I2C connection here as per the circuit Diagram.

Step 8: Installing Infineon DPS310 Libraries

Link: https://github.com/Infineon/DPS310-Pressure-SensorTo install the DPS310 pressure sensor library in the Arduino IDE, please go now to Sketch > Include Library > Add .ZIP Library... in the Arduino IDE and navigate to the downloaded .ZIP file of this repository. The library will be installed in your Arduino sketch folder in libraries and you can select as well as include this one to your project under Sketch > Include Library> IFX_DPS310.

Step 9: Arduino Libraries to Communicate with Google Maps

Link: https://github.com/witnessmenow/arduino-google-maps-api

Cons of this idea:

The sensor logs the measurement from ground level as it is a pressure sensor. We might have to create programs and algorithms for different cities.

Thanks!

Code

Untitled fileC/C++
#include "SoftwareSerial.h"
String ssid ="yourSSID";

String password="yourPassword";

SoftwareSerial esp(6, 7);// RX, TX

String data;

String server = "yourServer"; // www.example.com

String uri = "yourURI";// our example is /esppost.php

int DHpin = 8;//sensor pin

byte dat [5];

String pressure;

void setup() {

pinMode (DHpin, OUTPUT);

esp.begin(9600);

Serial.begin(9600);

reset();

connectWifi();

}

//reset the esp8266 module

void reset() {

esp.println("AT+RST");

delay(1000);

if(esp.find("OK") ) Serial.println("Module Reset");

}

//connect to your wifi network

void connectWifi() {

String cmd = "AT+CWJAP=\"" +ssid+"\",\"" + password + "\"";

esp.println(cmd);

delay(4000);

if(esp.find("OK")) {

Serial.println("Connected!");

}

else {

connectWifi();

Serial.println("Cannot connect to wifi"); }

}

byte read_data () {

byte data;

for (int i = 0; i < 8; i ++) {

if (digitalRead (DHpin) == LOW) {

while (digitalRead (DHpin) == LOW); // wait for 50us

delayMicroseconds (30); // determine the duration of the high level to determine the data is '0 'or '1'

if (digitalRead (DHpin) == HIGH)

data |= (1 << (7-i)); // high front and low in the post

while (digitalRead (DHpin) == HIGH);

// data '1 ', wait for the next one receiver

}

} return data; }

void start_test () {

digitalWrite (DHpin, LOW); // bus down, send start signal

delay (30); // delay greater than 18ms, so DHT11 start signal can be detected

digitalWrite (DHpin, HIGH);

delayMicroseconds (40); // Wait for DPS response

pinMode (DHpin, INPUT);

while (digitalRead (DHpin) == HIGH);

delayMicroseconds (80);

// DPS response, pulled the bus 80us

if (digitalRead (DHpin) == LOW);

delayMicroseconds (80);

// DPS 80us after the bus pulled to start sending data

for (int i = 0; i < 4; i ++)

// receive temperature and humidity data, the parity bit is not considered

dat[i] = read_data ();

pinMode (DHpin, OUTPUT);

digitalWrite (DHpin, HIGH);

// send data once after releasing the bus, wait for the host to open the next Start signal

}

void loop () {

start_test ();

// convert the bit data to string form
pressure = String(dat[0]);

data = "PRESSURE" +pressure;// data sent must be under this form //name1=value1&name2=value2.

httppost();

delay(1000);

}

void httppost () {

esp.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");//start a TCP connection.

if( esp.find("OK")) {

Serial.println("TCP connection ready");

} delay(1000);

String postRequest =

"POST " + uri + " HTTP/1.0\r\n" +

"Host: " + server + "\r\n" +

"Accept: *" + "/" + "*\r\n" +

"Content-Length: " + data.length() + "\r\n" +

"Content-Type: application/x-www-form-urlencoded\r\n" +

"\r\n" + data;

String sendCmd = "AT+CIPSEND=";//determine the number of caracters to be sent.

esp.print(sendCmd);

esp.println(postRequest.length() );

delay(500);

if(esp.find(">")) { Serial.println("Sending.."); esp.print(postRequest);

if( esp.find("SEND OK")) { Serial.println("Packet sent");

while (esp.available()) {

String tmpResp = esp.readString();

Serial.println(tmpResp);

}

// close the connection

esp.println("AT+CIPCLOSE");

}

}}

Schematics

To connect DPS310
Capture wfkuclkyah
capture_final1_7bSyH8X6ub.JPG
Capture final1 7bsyh8x6ub

Comments

Similar projects you might like

Safe Home Smart Home: Safety Device For Every Family Member

Project tutorial by Patel Darshil

  • 4,744 views
  • 0 comments
  • 11 respects

Traffic Monitor- Monitors traffic on the Go

Project tutorial by Patel Darshil

  • 3,732 views
  • 0 comments
  • 8 respects

Hot Air Balloon or Weather Satellite Navigation System

Project tutorial by Patel Darshil

  • 1,758 views
  • 0 comments
  • 14 respects

Easy IOT Water Leakage Indicator

Project tutorial by Patel Darshil

  • 9,186 views
  • 2 comments
  • 13 respects

IOT Humidity And Temperature Display

Project tutorial by Patel Darshil

  • 5,871 views
  • 0 comments
  • 16 respects
Add projectSign up / Login