-
1Step 1
Solder the electrodragon ESP8266 SMD Adapter Board R2, step up converters, and battery.
-
2Step 2
Connect rx & tx pins from GPS and GSM module to choosen pins on ESP. I recommend using 12, 13, 4 and 5 for this purpose.
Connect 16 to RST and pull up CH_P0 and 0.
Pins 14 and 15 (and one more in the future) will be used for controlling gps and gsm modules via transistors.
-
3Step 3
Edit the sketch by providing your network details, phone number, API hostname, port and customize your json as you want.
-
4Step 4
Setup the api on your raspberry pi or VPS. (I will provide one server for community usage). Remember to install all the dependencies.
sudo apt-get update; sudo apt-get install gem; sudo apt-get install rubygems; sudo gem install ruby-full; sudo gem install rubygems-update;sudo gem install sinatra; sudo gem install base64; sudo gem install json; sudo gem install mysql; sudo gem install digest;sudo gem install securerandom;
-
5Step 5
- Create database..
mysql -u root -p
CREATE DATABASE myservice;
..and tables:
CREATE TABLE `locations` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `pet_id` int(11) NOT NULL, `date` datetime NOT NULL, `location` varchar(60) NOT NULL DEFAULT '', `battery` float NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8;
CREATE TABLE `pets` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `pet_id` int(11) NOT NULL, `newest_location` varchar(60) NOT NULL DEFAULT '', `battery` float NOT NULL, `status` longtext NOT NULL, `date` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -
6Step 6
- Now run it :)
sudo ruby api.rb -o 0.0.0.0
-
7Step 7
Now connect your esp by usb cable and open the serial monitor.
You should see the output like this:
WIFI LOOP STARTS WiFi not connected! Checking next.. WiFi connected IP address: 192.168.2.XX FLAG: 0Device should push status Connecting to yourhostname.ddns.net POST /pettracker HTTP/1.1 Host: yourhostname.ddns.net Connection: close Content-Type: application/json Content-Length: 54 {"battery":"3.18","location":"#SSID","id":"0"} long sleep mode
And if you want to check the gps and gsm functionality just put the wrong password to your wifi network and code will run gps and gsm.
You should get text message with direct link to google/apple maps with a pin on it like me :)
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.