Hi everyone! Ever been on a trip away from the city and realized that your phone doesn't have a signal so you can't use its GPS? Ever gone hiking and the traditional compass and gps doesn't really do it for you, well I've got just what you need an all in one GPS and compass IoT-enabled device that will never leave hanging or lost for that matter. The device I'm talking about is the Sony Spresense, small, compact with a powerful processor. The following will project demonstrate to you how to use the GPS onboard the microcontroller and with a few calculations will be able to find our heading. Before I begin I'd like to thank the good folks at Sony for providing us with the code for the GPS and the audio because if you look at Arduino code I've provided it's a mixture of these two code for geofencing purposes plus the LCD I2C code for the screen and the code to calculate the heading. Just a heads up in the code I've removed all coordinates so you can place your own coordinates and for personal reasons also. Before we begin a few words about geofencing. Geo-fencing (geofencing) is a feature in a software program that uses the global positioning system (GPS) or radio frequency identification (RFID) to define geographical boundaries.
Geo-fencing allow an administrator to set up triggers so when a device enters (or exits) the boundaries defined by the administrator, an alert is issued. Many geo-fencing applications incorporate Google Earth, allowing administrators to define boundaries on top of a satelliteview of a specific geographical area. Other applications define boundaries by longitude and latitude or through user-created and Web-based maps.
Geofence virtual barriers can be active or passive. Active geofences require an end user to opt-in to location services and a mobile app to be open. Passive geofences are always on; they rely on Wi-Fi and cellular data instead of GPS or RFID and work in the background.
Step 1: (Setup)
To setup your spresense board for use with arduino follow these instructions https://developer.sony.com/develop/spresense/developer-tools/get-started-using-arduino-ide/set-up-the-arduino-ide
Step 2: (Hardware Connections)
For this project in regards for hardware were going to use only an LCD I2C although depending on the project you can add on any other sensor you'd like. As for connecting your LCD I2C the wiring connections are the following:
LCD VCC => SPRESENCE 5vdc
LCD GND => SPRESENCE GND
LCD SDA => D14
LCD SCL => D15
You'll also have to download the following library for the LCD I2C https://playground.arduino.cc/Code/LCDi2c
Step 3: (Upload The Code)
Our final step will be to upload the code onto the board. Now within the code you'll also find the math formula to calculate your bearing.
A few pictures depicting what you'll see in the Serial Monitor and a video showing it in action.
An interesting piece of code we can add onto the one I've already provided can be Morse Code. Say your lost or stranded on and island in the middle of the ocean you can
hit a panic button on the Sony Spresence and once it picks up your GPS coordinates it can convert them to led pulses. In the code I've provided you input your longitude manually
and it translates it to Morse Code. Ofcourse you can work with the code as you please and translate the coordinates that you recieve into Morse Code directly.