Kutluhan Aktar
Published © CC BY

WhatsApp Notification Station

Send temperature, humidity and movement information as WhatsApp messages to your phone every half-minute through a webhook via Twilio API.

ExpertFull instructions provided4 hours27,640
WhatsApp Notification Station

Things used in this project

Hardware components

SparkFun Solder-able Breadboard - Mini
SparkFun Solder-able Breadboard - Mini
Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
Jumper Wires
DIYables Jumper Wires

Software apps and online services

Twilio API for WhatsApp
Twilio API for WhatsApp
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)


Read more

Custom parts and enclosures

Fritzing File




Source Code(NodeMCU)

        //     WhatsApp Notification Station       //
       //             (via Twilio)                //
      //          ---------------------          //
     //             NodeMCU (ESP-12E)           //           
    //            by Kutluhan Aktar            // 
   //                                         //

// By only subscribing to TheAmplituhedron, you will be able get your data packets from NodeMCU, or any other device that can make an HTTP GET Request, to your phone as WhatsApp messages via Twilio through TheAmplituhedron.
// You will need a Twilio account to get WhatsApp messages automatically from the webhook.
// Then, you can use the webhook including the Twilio WhatsApp API by defining these five paranaters below.
// Note: Do not use the plus sign(+) when entering the phone numbers if you are using the webhook application or source code provied by TheAmplituhedron.
// Note: You will also need your unique hedron to connect the webhook application(WhatsApp WebHook).
// Parameters:
// 1) Twilio Account SID
// 2) Twilio Account AUTH TOKEN
// 3) Message Body
// 4) From: Dedicated Business Phone Number
// 5) To: Your Verified Phone Number
// Click the links below for more information about Twilio.
// https://www.twilio.com/whatsapp
// https://www.theamplituhedron.com/dashboard/WhatsApp-Web-Hook/
// As a reminder, my website has SSL protection so that you need to identify your NodeMCU connection by entering TheAmplituhedron FingerPrint or ThumbPrint.
// You can learn about it more from the link below.
// https://www.theamplituhedron.com/projects/WhatsApp-Notification-Station/
// In this project turorial, I decided to use an HC-SR04 Ultrasonic Sensor, and a DHT11 Temperature and Humidity as data providers.
// To detect any tresspasser trespasser, I used the ultrasonic sensor which triggers the notification message: "Someone is trespassing!"
// Every half minute, the board send a message body to the webhook that transmits it to your phone as a WhatsApp message via Twilio.
// I created a free webhook application for TheAmplituhedron subscribers and used it in this project. But, if you do not want to use this service,
// you can copy the source code from the link on the top.
// Connections
// NodeMCU (ESP-12E) :           
//                                DHT11 Temperature and Humidity Sensor Module
// D2  --------------------------- Data
//                                HC-SR04 Ultrasonic Sensor
// D4  --------------------------- Trig
// D5  --------------------------- Echo

// Include required libraries to send data to a website, in this case TheAmplituhedron.com.
#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>

// Include DHT master library to elicit information from DHT11 Temperture and Humidity Sensor.
#include "DHT.h"

// Define DHT object.
DHT dht;

// Define your WIFI settings.
const char *ssid = "";
const char *password = "";

// Create data holders to send data packets.
String temperature, humidity;
String fingerprint, WebHook, HEDRON, id, token, message, from, to, trespass;

// Define HC-SR04 pins and measurements to detect any movement.
#define trig D4
#define echo D5
long duration, distance;

void setup() {
  // Start DHT object at digital pin 2.
  // Initiate HC-SR04 pins.
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  // Wait until connected.

  // It is just for assuring connection is alive.
  // This mode allows NodeMCU to connect any WiFi directly.
  // Connect NodeMCU to your WiFi.
  WiFi.begin(ssid, password);
  Serial.print("Try to connect to WiFi. Please wait! ");
  // Halt the code until connected to WiFi.
  while (WiFi.status() != WL_CONNECTED) {
  // If connection is successful, turn control led(if used) on and write WiFi SSID to serial monitor along with assigned IPAddress.
  Serial.print("Connection is successful!");
  Serial.print("Connected WiFi SSID : ");
  Serial.println("Connected IPAddress : ");

void loop() {
  // Get tenperature and humidity from DHT11. And, detect any tresspasser.

  // Enter the fingerprint.
  fingerprint = "46 3c 5c 2c 67 11 cd 88 b7 e9 76 74 41 34 48 bd bc a5 b9 cf";

  // Enter your hedron provided by TheAmplituhedron, Twilio Account Information, and phone numbers.
  HEDRON = "TheAmplituhedron_Hedron";
  id= "Twilio_SID";
  token = "Twilio_Token";
  from = "14151234567"; // Enter numbers.
  to = "14081234567";

  // Create message,use %0A to start a new line.
  message = "Status:+Data+Obtained++%0A%0ATemperature:+" + temperature + "C%0A%0AHumidity:+" + humidity + "%%0A%0AMovement:+" + trespass + "%0A%0AWaiting...";

  // Create the webhook path.
  WebHook = "https://www.theamplituhedron.com/dashboard/WhatsApp-Web-Hook/" + HEDRON + ".php?id=" + id + "&token=" + token + "&body=" + message + "&from=" + from + "&to=" + to;
  // Create HTTP object to make a request.
  HTTPClient http;
  // Send a request. 
  http.begin(WebHook, fingerprint);
  int httpCode = http.GET();           
  String payload = http.getString();    
  if(httpCode == 200){ Serial.println("\n Message Sent Successfully..."); }else{ Serial.println("\n Not Working! Error Code: " + httpCode); }
  // End HTTP Get Request.
  // Send data packets every half minute to the webhook.

  void collectData(){
      // Wait until DHT11 Temperature and Humidity Sensor became ready.
      // Get temperature and humidity. 
      humidity = dht.getHumidity();
      temperature = dht.getTemperature();

      // Detect any movement by using the trigger pin.
      digitalWrite(trig, LOW);
      digitalWrite(trig, HIGH);
      digitalWrite(trig, HIGH);
      duration = pulseIn(echo, HIGH);
      distance = (duration / 2) / 29.1;
      if(distance < 8){ trespass = "No+movement+detected!"; }else{ trespass = "Someone+is+trespassing!"; }

      // Dump data packets.
      String data = "\n Tempature: " + temperature + "\n Humidity: " + humidity + "\n Movement: " + trespass + "\n";

WebHook Source Code


require_once '/path/to/vendor/autoload.php'; 
use Twilio\Rest\Client; 

if(isset($_GET["id"]) && isset($_GET["token"]) && isset($_GET["body"]) && isset($_GET["from"]) && isset($_GET["to"])){
	$sid    = $_GET["id"]; 
    $token  = $_GET["token"];  
    $twilio = new Client($sid, $token);
	$to = $_GET['to'];
	$from = $_GET['from'];
	$body = $_GET['body'];
	$message = $twilio->messages 
                               "from" => "whatsapp:+".$from,       
                               "body" => $body
    echo 'Message Send...';				  
	echo "There is no request yet! Copy this link(webhook) and make an HTTP Get Request from your device.";



Kutluhan Aktar

Kutluhan Aktar

71 projects • 244 followers
Self-Taught Full-Stack Developer | @EdgeImpulse Ambassador | Maker | Physics Enthusiast