https://github.com/PRosenb/ArduinoPushNotification
This project implements a small solution to send push notifications from an Arduino
based ESP32
or ESP8266
to
your Android
device.
It shows how to set up AWS
with the Serverless
framework, contains a small Arduino
sample implementation and the
Android
app that receives the push notification.
AWS
based backend solution- Simple
Lambda
functions written innode.js
- Database configuration using
DynamoDB
API Gateway
configurationAndroid
app written inKotlin
Arduino
example code forESP32
andESP8266
- Good starting point for similar projects
- Install
Serverless
according to their Getting Started guide - Give
Serverless
access to yourAWS
account by following the AWS - Credentials guide- I recommend initially doing Quick Setup in chapter Using AWS Access Keys
- Ignore the note about
self-signed certificate
, we don't need them for this setup
- Clone this repository
- Open a command shell and navigate to your desired directory. The clone command will create a subfolder
ArduinoPushNotification
in it - Execute the git clone command
git clone git@github.com:PRosenb/ArduinoPushNotification.git
- Open a command shell and navigate to your desired directory. The clone command will create a subfolder
- Deploy the
AWS
configuration- Inside of the repository directory structure, navigate to the the directory
serverless
- Don't forget to set the credentials environment variables if you haven't done yet (on Windows use
set
)export AWS_ACCESS_KEY_ID="<your key id>"
export AWS_SECRET_ACCESS_KEY="<your key>"
- Execute the deploy command
serverless deploy
- On success, it will print multiple links of the following type:
https://xxxxx.execute-api.us-east-1.amazonaws.com/v1/xxxx
- One of the links is a
GET
endpoint. That one is the easiest to test the setup with- Copy the
GET
endpoint link and put it in a browser - When it shows
error: "Missing installationId"
, deployment was successful
- Copy the
- From one of the links, copy the part until and including
v1/
, you'll need it later
- Inside of the repository directory structure, navigate to the the directory
- Download and install Android Studio
- Clone this repository if you haven't done it
- Open
Android Studio
- Click Menu
File
->Open...
- Choose the the directory ArduinoPushNotification and open it
- Click Menu
- Open the file
app/build.gradle
and change theapplicationId
to your own - Follow the instructions Add Firebase to your Android project
- use
Option 1
- Follow the guide until
Step 3: Add a Firebase configuration file
including
Add the Firebase Android configuration file to your app:
- Put the file
google-services.json
here:app/google-services.json
- use
- Open the file
app/src/main/java/ch/pete/arduinopushnotification/service/Registration.kt
- Set the variable
SERVER_URL
to your URL from theAWS
setup - Remove the part after
v1/
and ensure it has a trailing/
- Set the variable
- Install the app on your Android device with the
Run
button - Check if it connects to the API correctly by tapping on
Register
- It should do an API call, show a generated
Installation Id
and change the button toUnregister
- It should do an API call, show a generated
- Install PlatformIO IDE for Atom
- Open
Atom
- Click Menu
File
->Open...
and choose the directoryArduinoPushNotificationClient
- Click Menu
- Click the tick icon
Build
on the left to check if it builds - Open the file
src/main/main.cpp
- Set the variable
PUSH_URL
to yourPOST
URL from theAWS
step that ends withsend
- set the variable
INSTALLATION_ID
to the value the app shows asInstallation Id
- Set the variable
- Connect your ESP32 or ESP8266 to your PC via
USB
- Upload the code to it with the arrow icon
Upload
- On success of all steps above it sends a push notification and the app receives it
Enhancements and improvements are welcome.
Arduino Push Notification
Copyright (c) 2019 Peter Rosenberg (https://github.com/PRosenb).
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.