GPS multi-unit SORACOM Edition data is sent to AWS Lambda via SORACOM Funk, and location information is notified using LINE Notify. Location information is a link on Google Maps. The language used is Python.
Below, quoted from Official Site
GPS multi-unit SORACOM Edition is a device that can use LTE-M communication, which is a cellular LPWA, with built-in four sensors of "location information (GPS)", "temperature", "humidity", and "acceleration" and a rechargeable battery. is.
See below for more information. What is (Official) GPS Multiunit SORACOM Edition Play with GPS multi-unit SORACOM Edition
It is a service that can directly execute the function of the cloud service. This time, we'll run AWS Lambda.
See below What is (Official) SORACOM Funk I tried using SORACOM Funk.
Below, from Official Site
Receive notifications from web services on LINE When you link with the web service, you will receive a notification from the official account "LINE Notify" provided by LINE. It can be linked with multiple services, and even groups can receive notifications.
See below Send a message to LINE with Python (LINE Notify)
The settings for SORACOM, AWS Lambda, and LINE Notify are omitted.
The following to AWS Lambda. Python 3.6 The time is also notified.
lambda_function.py
import os
import requests
import datetime
def lambda_handler(event, context):
lat = event['lat'] #latitude
lon = event['lon'] #longitude
#Get the current date and time(Japan time)
now = datetime.datetime.now(datetime.timezone(datetime.timedelta(hours=9)))
#When location information cannot be obtained
if lat == None or lon == None:
msg = now.strftime('%Y-%m-%d') + " " + now.strftime('%H:%M:%S') + " " + "Could not get location information"
line_notify(msg)
return
#View on Google Maps
mapurl = "https://maps.google.co.jp/maps?q=" + str(lat) + "," + str(lon) #for google map
msg = now.strftime('%Y-%m-%d') + " " + now.strftime('%H:%M:%S') + " " + "You are here" + " " + mapurl
line_notify(msg)
#Notify LINE Notify
def line_notify(msg):
url = "https://notify-api.line.me/api/notify"
headers = {"Authorization" : "Bearer "+ "<Set LINE TOKEN>"}
data = {"message" : msg}
s3 = requests.Session()
r3 = s3.post(url, data=data, headers=headers)
Recommended Posts