DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • How Can Developers Drive Innovation by Combining IoT and AI?
  • A Deep Dive Into Firmware Over the Air for IoT Devices
  • Patch Management in the Age of IoT: Challenges and Solutions
  • IoT Communication Protocols for Efficient Device Integration

Trending

  • Performance Optimization Techniques for Snowflake on AWS
  • How to Format Articles for DZone
  • Unlocking the Benefits of a Private API in AWS API Gateway
  • Docker Base Images Demystified: A Practical Guide
  1. DZone
  2. Data Engineering
  3. Big Data
  4. Building an IoT Notification System

Building an IoT Notification System

Here's a great way to build your own IoT notification system that sends alerts to multiple devices using an ESP8266, PushingBox, and relatively few lines of code.

By 
Francesco Azzola user avatar
Francesco Azzola
·
Updated Jan. 07, 18 · Tutorial
Likes (9)
Comment
Save
Tweet
Share
28.6K Views

Join the DZone community and get the full member experience.

Join For Free

This article describes how to implement an IoT notification system. A notification is a way we can send alarms or other kinds of information to users. This post details, step by step, how to build an IoT notification system using a few lines of code and integrating existing cloud platforms. The aim is to send a notification to several devices, such as Android, iOS, or a desktop PC. This IoT project uses an ESP8266, but you can use other IoT development boards to test it like the Arduino UNO, MKR1000, other ESPs, and so on.

This is an interesting project because it is possible to further extend, and we can use it in several scenarios where it is necessary to send a notification or an alert:

  • Flood alert
  • Temperature monitoring
  • Air quality alert
  • Alarm systems

And so on. They are just a few examples where it is possible to use this IoT notification project.

The idea that stands at the base of this project is building a general purpose IoT notification system that you can reuse in other scenarios, without writing too much code.

We have covered the notification topic in several other tutorials. For example, we have already described how to send notifications using Google Firebase. Moreover, it is possible to use other IoT development boards to implement a notification system.

IoT Notification Project Overview

Before diving into the project details, it is useful to have an overview of this project and the components that we will use. To make things simple, the aim is to monitor temperature and air pressure and send those readings periodically using a notification message. The project overview is shown below:

IoT notification system

For the sensor, the project uses BMP280 — an I2C sensor. There is a library to use in order to exchange data with this sensor. You can download it from GitHub or import it into your IDE.

The cloud notification system has two components:

  • One that is used by the ESP to trigger the notification (PushingBox)
  • The second is the system that sends the notification to the connected devices (Pushbullet)

PushingBox is an interesting cloud platform that simplifies the process of sending data. It exposes a simple API that our IoT notification system uses to trigger the notification.

It is possible to divide this project into two different steps:

  1. Configuring the notification system
  2. Developing a simple program to read data from the sensor and trigger the notification

Configuring The IoT Notification System

The first step is configuring the notification system so that the ESP program can invoke an API exposed by PushingBox and trigger the process of sending the notification. I suppose you already know the Pushbullet cloud platform and you have already an account. If not, you can register for free and activate your account.

In order to receive the notification, you have to install the Pushbullet app on the device you want to use. You can receive the same notification on different devices at the same time. For example, if you want to receive the notification on your Android smartphone, you have to install the Pushbullet app from the Google Play store. Once your account is ready, you can go to the dashboard and get your API key (settings menu item):

iot notification pushbullet

This is the API key we will use later in the project. Now it is time to configure PushingBox in order to receive the notification call from the ESP and trigger the notification. If you do not have one, you have to create a free account. Once you are logged in, in the dashboard, select My Services to add Pushbullet as service:

Internet of things notification system

The next step is creating the scenario, or in other words, the content of the message we want to send:

How to send IoT notification

That’s all. In a few steps, we have configured all the systems that this IoT notification project will use to send the notification. Save the deviceID because we will use it later.

Implementing The Notification Using ESP (Or Arduino)

The last step is implementing the sketch that reads the temperature and the pressure from the sensor and triggers the notification. This is quite simple because we can use a library that simplifies our work.

The connection schema is shown below:

IoT notification using ESP8266

In the first step, let us read the sensor data:

#include <ESP8266WiFi.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>

//BMP280
Adafruit_BMP280 bme;

void setup() {
    Serial.begin(115200);
    Serial.println("Setup...");

    if (!bme.begin()) {
        Serial.println("Could not find a valid BMP280 sensor, check wiring!");
        while (1);
    }
}


Now in the loop method, we can read the data:

float temp = bme.readTemperature();
float pressure = bme.readPressure();


Finally, we can focus on the last part of this project — connecting to the PushingBox API. Add the following lines at the beginning:

// Pushingbox API
char *api_server = "api.pushingbox.com";
char *deviceId = "v10BAFBDA2376E5E";


And add the following method, which connects to the PushingBox API:

void sendNotification(float temp, float pressure) {
    Serial.println("Sending notification to " + String(api_server));
    if (client.connect(api_server, 80)) {
        Serial.println("Connected to the server");

        String message = "devid=" + String(deviceId) +
            "&temp=" + String(temp) +
            "&press=" + String(pressure) +
            "\r\n\r\n";

        client.print("POST /pushingbox HTTP/1.1\n");
        client.print("Host: api.pushingbox.com\n");
        client.print("Connection: close\n");
        client.print("Content-Type: application/x-www-form-urlencoded\n");
        client.print("Content-Length: ");
        client.print(message.length());
        client.print("\n\n");
        client.print(message);
    }
    client.stop();
    Serial.println("Notification sent!");
}


Notice that, in the code above, the sketch sends three different parameters:

  • deviceId (as specified in the configuration step)
  • temperature(temp)
  • pressure (press)

The last two parameters will be used by the notification system in the message template to replace the $temp$ and $press$ with the current values measured by the sensor.

It is time to test this IoT notification project. Just upload the sketch into your ESP and wait for the notification that should arrive in a few seconds. The final result is shown below in case you use the Pushbullet Chrome extension:

IoT push notification from arduino

While if you enabled the smartphone notification, you will get:

IoT android notification

Summary

At the end of this tutorial, you, hopefully, gained the knowledge of how to develop an IoT notification systems that sends messages to several devices using a few lines of code. As stated above, this IoT notification tutorial can be further extended, and we can use it in several scenarios.

Notification system IoT

Published at DZone with permission of Francesco Azzola, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How Can Developers Drive Innovation by Combining IoT and AI?
  • A Deep Dive Into Firmware Over the Air for IoT Devices
  • Patch Management in the Age of IoT: Challenges and Solutions
  • IoT Communication Protocols for Efficient Device Integration

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!