• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Sending notifications with ESP 32

Q&A Forum › Category: ESP32 › Sending notifications with ESP 32
0 Vote Up Vote Down
Austin asked 6 years ago

Good day. I have been following your corse on the ESP 32 I have enjoyed tinkering with it so far. I would like to do a project using the ESP 32 to send notifications to a cellphone. I found one that uses the ESP 8266. Do you have any projects like that? Basically I would like to set up a motion sensor that would text my phone. Or how interchangeable are the 32 and 8266? 
 
Thank you. 

11 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hello, you can use https://ifttt.com to create a custom applet using the Maker Webhooks service. Then, if it receives an HTTP request in a URL, it will send a email or smartphone push notification.
Which project did you follow for the ESP8266? It might be almost the exact same code

0 Vote Up Vote Down
Austin answered 6 years ago

good day. sorry for the late reply. https://github.com/witnessmenow/push-notifications-arduino-esp8266 this is the one I have been working with. I have been having difficulty with it. I think because it is an old code and the libraries don’t match. I think I have it working now. haven’t gotten to test it. Do you have a recommended code? 

0 Vote Up Vote Down
Austin answered 6 years ago

I didn’t get the Telegram bot to work but after reinstalling older libraries, I did get IFTTT to work.  

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

I’ve been using exclusively direct HTTP POST requests to IFTTT (I don’t use libraries), so it usually works regardless of any changes they make…

0 Vote Up Vote Down
Austin answered 6 years ago

I will look into that. the ifttt seems to be working ok. Telegram is not. I can send a message from telegram to the esp 8266, but its not working the other way. I did get an echo bot to work, so I am looking into that. Telegram will be better if I can get it to work both ways. I haven’t seen anything that can be used to control the out put of the esp 8266 from ifttt. 

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

How are you sending the message from Telegram to ESP8266? Can you share how you’re doing it. Exactly, unfortunately you can’t directly control an ESP8266 output or send anything from IFTTT. Thanks

0 Vote Up Vote Down
Austin answered 6 years ago

I’m still working on it. Using Echo bot example from the (universaltelegrambot library). There are a few examples on using it to turn on and off an LED. Progress is slow on this project because I can’t connect it to work WiFi.

0 Vote Up Vote Down
Austin answered 6 years ago

This is what I have been working on. need a telegram bot

/*******************************************************************
* An example of bot that echos back any messages received *
* *
* written by Giacarlo Bacchio (Gianbacchio on Github) *
* adapted by Brian Lough *
*******************************************************************/
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
// Initialize Wifi connection to the router
char ssid[] = "****"; // your network SSID (name)
char password[] = "****"; // your network key
// Initialize Telegram BOT
#define BOTtoken "*********************************" // your Bot Token (Get from Botfather)
WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);
int inPut1 = 14; // motion sensor 
int inputState = 0; // motion sensor
int ledPin1 = 5; //output for lights or gate  /on /off
int Bot_mtbs = 1000; //mean time between scan messages
long Bot_lasttime; //last time messages' scan has been done
bool inputFlag = HIGH; // flag for input loop to keep it from sending a bunch of text
void setup() {
Serial.begin(115200);
pinMode (ledPin1 , OUTPUT); //control something 
pinMode (inPut1 , INPUT);  //send a message
// Set WiFi to station mode and disconnect from an AP if it was Previously
// connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
// Attempt to connect to Wifi network:
Serial.print("Connecting Wifi: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}

void loop() {
inputState = digitalRead (inPut1);

if (inputState == HIGH && inputFlag == HIGH){ //if motion detected and loop has not run
for (int x = 0; x < 1; x++){
//Serial.println ("send text"); 
bot.sendMessage("841056557", "input1 high", ""); //chat id and message to be sent
inputFlag = LOW; //keep loop from running and sending multi text
} }
if (inputState == LOW && inputFlag == LOW){ //input returns low and loop has run once
inputFlag = HIGH; //reset flag after input stops and loop ran once
// if (inputState == HIGH && timming event ){ //use to start checking for message after motion detected reduce the traffic on wifi
if (millis() > Bot_lasttime + Bot_mtbs)

{
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
while(numNewMessages) {
Serial.println("got response");
for (int i=0; i<numNewMessages; i++) {
Serial.print("chat id ");
Serial.println(bot.messages[i].chat_id);
if (bot.messages[i].text == "/on"){ //CHECK INCOMMING MESSAGE then do
// Serial.println("turnn led on");
digitalWrite (ledPin1 , HIGH);
bot.sendMessage("841056557", "LED on", "");}
if (bot.messages[i].text == "/off"){ //CHECK INCOMMING MESSAGE then do
//Serial.println("turnn led off");
digitalWrite (ledPin1 , LOW);
bot.sendMessage("841056557", "LED off", "");}
if (bot.messages[i].text == "/hello"){ //CHECK INCOMMING MESSAGE then do
//Serial.println("turnn led off");
//digitalWrite (ledPin1 , LOW); //play message
bot.sendMessage("841056557", "play message", "");}

// Serial.print("text ");
// Serial.println(bot.messages[i].text);
// bot.sendMessage(bot.messages[i].chat_id, bot.messages[i].text, "");
// bot.sendMessage("########", "youwin", ""); //bot.sendMessage ("chat id", "text","")
// bot.sendMessage(bot.messages[i].chat_id, "youwin", "");
// bot.sendMessage("############", bot.messages[i].text, "");
}
numNewMessages = bot.getUpdates(bot.last_message_received + 1);
}
Bot_lasttime = millis();
}}
}
0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Have you tried using the official Examples of that library for the ESP32?

  • https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot/tree/master/examples/ESP32
0 Vote Up Vote Down
Austin answered 6 years ago

I started there. I had the latest version or the Board installed and it wasn’t working. It’s working now. I’m working on making it work for my situation. Send text on motion. Then I can check camera and then turn on a light or open the front gate. It’s going good so far 

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Sounds good. I haven’t had enough time to try this integration, but it definitely looks interesting and I can see a lot of applications for it.

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.