ESP8266 mini sends SMS when door opens

Поділитися
Вставка
  • Опубліковано 1 жов 2024

КОМЕНТАРІ • 70

  • @ViktorKjartansson
    @ViktorKjartansson  4 роки тому +3

    Hi, here is the code: OpenDetector.ino
    #include
    #include
    #include "credentials.h"
    int switchRead=D1;
    bool hasSentMessage = false;
    void setup() {
    Serial.begin(115200);
    pinMode(LED_BUILTIN, OUTPUT);
    pinMode(switchRead, INPUT_PULLUP);
    connectWifi();
    }
    void loop() {
    if (digitalRead(switchRead) == HIGH) {
    digitalWrite(LED_BUILTIN, LOW);
    Serial.println("Door Open");
    if (!hasSentMessage) {
    sendMessage();
    }
    } else {
    Serial.println("Door Closed");
    hasSentMessage = false;
    }
    digitalWrite(LED_BUILTIN, HIGH);
    delay(1000);
    }
    void connectWifi() {
    WiFi.mode(WIFI_STA);
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
    Serial.println("connecting");
    while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
    }
    Serial.print("connected: ");
    Serial.println(WiFi.localIP());
    digitalWrite(LED_BUILTIN, HIGH);
    }
    void sendMessage() {
    Serial.println("sendMessage");
    HTTPClient http;
    http.begin(String("api.plivo.com/v1/Account/") + AUTH_ID + String("/Message/"), FINGERPRINT);
    http.addHeader("Content-Type", "application/json");
    http.addHeader("Authorization", "Basic " + AUTH_TOKEN);
    String postMessage = String("{\"src\":\"") + FROM_TELEPHONE + String("\",\"dst\":\"") + TO_TELEPHONE + String("\",\"text\":\"Main door is OPEN!\"}");
    Serial.println(postMessage);
    auto httpCode = http.POST(postMessage);
    if (httpCode < 0) {
    Serial.printf("POST failed, error: %s
    ", http.errorToString(httpCode).c_str());
    }
    Serial.println(httpCode);
    http.writeToStream(&Serial);
    http.end();
    hasSentMessage = true;
    }

  • @blazetechnb
    @blazetechnb 3 роки тому +1

    Thank you so much Sir Viktor.
    One question. How to use that PLIVO??How do i get the code for that??Again,thank you so much!

  • @mikeharmon8733
    @mikeharmon8733 4 роки тому +1

    I'm sorry but where is this code posted?
    At the beginning of your video you post where to buy everything but I do not see a reference to the code anywhere.
    If I missed that part of the video then I apologize in advance.
    Also, I would recommend NOT putting your hand in the way of your object of discussion, it's distracting.
    Great video otherwise.

    • @ViktorKjartansson
      @ViktorKjartansson  4 роки тому

      Thanks for your comment - I agree hands are borgin :-)

  • @ViktorKjartansson
    @ViktorKjartansson  4 роки тому

    And here is the credentials.h - you must put your credentials here
    #define WIFI_SSID "YourWIFIName"
    #define WIFI_PASSWORD "YourWIFIPassword"
    #define AUTH_ID String("MAZ123456789012345OT")
    #define AUTH_ID_TOKEN String("MWZlNzI3Y2Qx1234567891234567892MDcx");
    #define AUTH_TOKEN String("TUFaMTIzNDU2Nzg5MDEyMzQ1T1Q6TVdabE56STNZMlF4MTIzNDU2Nzg5MTIzNDU2Nzg5Mk1EY3g=")
    #define FROM_TELEPHONE String("+12019999999")
    #define TO_TELEPHONE String("+4791999999")
    #define FINGERPRINT String("11:68:5A:34:9A:28:0D:91:9E:CC:8F:99:59:0A:D4:4A:FF:C5:50:6A")

  • @xfarsys
    @xfarsys 6 років тому +2

    you should check 10:48 and, thanks for the video

  • @ibrahimyusuf2442
    @ibrahimyusuf2442 2 роки тому +1

    Thanks Viktor for the time you spent on this project. I got it working in the end but I had to use "esp8266 by esp8266 community v.2.4.2" the exact version you've used. Version 3.x did not work but perhaps I have to give it a go again as there were few minor typos that I had to deal with after that. Will update this in due course. Let me know what later version(s) you've tried since. I am sure you moved on and do some other funky stuff, but hey...Thanks once again.

    • @ViktorKjartansson
      @ViktorKjartansson  2 роки тому

      You're welcome Ibrahim - have to make more videos 🙂

  • @ericrandall3539
    @ericrandall3539 4 роки тому

    Just some helpful advice - many people watch UA-cam on their phones. You can’t read a thing because your text is SO small. The screen is over half who’re space with some microscopic text. Zoom to what you’re doing.

  • @paulcowley3786
    @paulcowley3786 4 роки тому +1

    Just the project im looking for, could you please share the code. Thankx.

  • @RezaAlFath
    @RezaAlFath 4 роки тому +1

    where is the code?

    • @panconkisu
      @panconkisu 2 роки тому

      2 years later but
      #include
      #include
      #include "credentials.h"
      int switchRead=D1;
      bool hasSentMessage = false;
      void setup() {
      Serial.begin(115200);
      pinMode(LED_BUILTIN, OUTPUT);
      pinMode(switchRead, INPUT_PULLUP);
      connectWifi();
      }
      void loop() {
      if (digitalRead(switchRead) == HIGH) {
      digitalWrite(LED_BUILTIN, LOW);
      Serial.println("Door Open");
      if (!hasSentMessage) {
      sendMessage();
      }
      } else {
      Serial.println("Door Closed");
      hasSentMessage = false;
      }
      digitalWrite(LED_BUILTIN, HIGH);
      delay(1000);
      }
      void connectWifi() {
      WiFi.mode(WIFI_STA);
      WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
      Serial.println("connecting");
      while (WiFi.status() != WL_CONNECTED) {
      Serial.print(".");
      delay(500);
      }
      Serial.print("connected: ");
      Serial.println(WiFi.localIP());
      digitalWrite(LED_BUILTIN, HIGH);
      }
      void sendMessage() {
      Serial.println("sendMessage");
      HTTPClient http;
      http.begin(String("api.plivo.com/v1/Account/") + AUTH_ID + String("/Message/"), FINGERPRINT);
      http.addHeader("Content-Type", "application/json");
      http.addHeader("Authorization", "Basic " + AUTH_TOKEN);
      String postMessage = String("{\"src\":\"") + FROM_TELEPHONE + String("\",\"dst\":\"") + TO_TELEPHONE + String("\",\"text\":\"Main door is OPEN!\"}");
      Serial.println(postMessage);
      auto httpCode = http.POST(postMessage);
      if (httpCode < 0) {
      Serial.printf("POST failed, error: %s
      ", http.errorToString(httpCode).c_str());
      }
      Serial.println(httpCode);
      http.writeToStream(&Serial);
      http.end();
      hasSentMessage = true;
      }

  • @raymerritt788
    @raymerritt788 3 роки тому +1

    I'm a novice, well, I really have no clue on how to build what I want. Was wondering if you could give me some advice or even help me build this little project, if possible. I'd be more than happy to pay you for your time. I'm looking to build a very small or very slim wireless/ wifi window sensor. The smallest possible that's activated by a very small magnet. I need the activation to send a signal straight to my cell phone through my home router (without having to manipulate the settings on my router). I can download "homeassistant" or "mylife" or run a small simple phone app. The intent here is not to adjust any setting on my router. I'd like to get at least 75 - 150ft signal to my router. I have a 3d printer and can make a housing for the battery and board...just wondering if this is possible? Any advice would be much appreciated. Thank you for your help.

    • @ViktorKjartansson
      @ViktorKjartansson  3 роки тому

      If you buy these two very small things:
      SonOff bridge: www.banggood.com/SONOFF-ZBBridge-Smart-Zigbee3_0-Bridge-with-4-SNZB-Sensors-APP-Wireless-Remote-Controller-Smart-Home-Bridge-Work-with-Alexa-Google-Home-Voice-Control-p-1730291.html?rmmds=search&cur_warehouse=CN
      and
      SonOff window detector: www.banggood.com/SONOFF-DW2-Wi-Fi-Wireless-Door-or-Window-Sensor-No-Gateway-Required-Support-to-Check-History-Record-on-APP-p-1674773.html?rmmds=detail-left-hotproducts__4&cur_warehouse=CN
      And install the eWeLink app you get push notifications any time window is open/closed.

    • @raymerritt788
      @raymerritt788 3 роки тому

      Ty Victor. But I want the device to send the signal straight to home router......not Alexa....not googke asstant....straight to my router then to my cell through an app. Also, needs to be smaller than a match box and thin as possible. Great suggestion though..ty

    • @ViktorKjartansson
      @ViktorKjartansson  3 роки тому

      @@raymerritt788 Yes, the bridge is connected directly to your router via WIFI and the app is ready eWeLink

  • @junaidhkv4153
    @junaidhkv4153 3 роки тому

    Can you give the magnetic switch
    Product link for buy

  • @sedanurkocal5190
    @sedanurkocal5190 Рік тому

    Hi sir. So we can use normal esp8266 for this project, right?

  • @paulcowley3786
    @paulcowley3786 4 роки тому

    sorry Viktor, i see no code,please help. Thankx

  • @yawarsaeed6499
    @yawarsaeed6499 4 роки тому +1

    Thanks for sharing such an Awesome project. Can you please share the code for the same.
    Awaiting your earliest response.

    • @ViktorKjartansson
      @ViktorKjartansson  3 роки тому +4

      Hi, here is the code: OpenDetector.ino
      #include
      #include
      #include "credentials.h"
      int switchRead=D1;
      bool hasSentMessage = false;
      void setup() {
      Serial.begin(115200);
      pinMode(LED_BUILTIN, OUTPUT);
      pinMode(switchRead, INPUT_PULLUP);
      connectWifi();
      }
      void loop() {
      if (digitalRead(switchRead) == HIGH) {
      digitalWrite(LED_BUILTIN, LOW);
      Serial.println("Door Open");
      if (!hasSentMessage) {
      sendMessage();
      }
      } else {
      Serial.println("Door Closed");
      hasSentMessage = false;
      }
      digitalWrite(LED_BUILTIN, HIGH);
      delay(1000);
      }
      void connectWifi() {
      WiFi.mode(WIFI_STA);
      WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
      Serial.println("connecting");
      while (WiFi.status() != WL_CONNECTED) {
      Serial.print(".");
      delay(500);
      }
      Serial.print("connected: ");
      Serial.println(WiFi.localIP());
      digitalWrite(LED_BUILTIN, HIGH);
      }
      void sendMessage() {
      Serial.println("sendMessage");
      HTTPClient http;
      http.begin(String("api.plivo.com/v1/Account/") + AUTH_ID + String("/Message/"), FINGERPRINT);
      http.addHeader("Content-Type", "application/json");
      http.addHeader("Authorization", "Basic " + AUTH_TOKEN);
      String postMessage = String("{\"src\":\"") + FROM_TELEPHONE + String("\",\"dst\":\"") + TO_TELEPHONE + String("\",\"text\":\"Main door is OPEN!\"}");
      Serial.println(postMessage);
      auto httpCode = http.POST(postMessage);
      if (httpCode < 0) {
      Serial.printf("POST failed, error: %s
      ", http.errorToString(httpCode).c_str());
      }
      Serial.println(httpCode);
      http.writeToStream(&Serial);
      http.end();
      hasSentMessage = true;
      }

    • @jamesbrown2163
      @jamesbrown2163 3 роки тому

      @@ViktorKjartansson Thanks Viktor, you're a good man.

  • @arniep740
    @arniep740 4 роки тому +1

    Is the code available somewhere? Thanks.

    • @ViktorKjartansson
      @ViktorKjartansson  4 роки тому

      Yes, here in comments

    • @arniep740
      @arniep740 4 роки тому

      @@ViktorKjartansson I don't see your code anywhere in the comments. Do you have a link to it?

  • @PrKJTECH
    @PrKJTECH 5 років тому +1

    In India where should I get this bro.

  • @n1kkri
    @n1kkri 3 роки тому +1

    Has anyone developed a simple add on current sensor that detects current flow in the door bell wires when the doorbell button is pressed. When it senses the current it will send either a email or text message. Sort of a poor man DIY Ring Door bell for those that already have a camera looking at their front door.

    • @ViktorKjartansson
      @ViktorKjartansson  3 роки тому

      Yes, now you can buy such buttons and put them instead of your doorbell - then they send (via zigbee or RF) signal to main station which can then send the signal to MQTT server which anybody can listen too - then you get the signal you can send sms/email/push or do what you want.
      www.banggood.com/5pcs-SONOFF-SNZB-01-ZB-Wireless-Switch-Mini-Size-Link-ZB-Bridge-with-WiFi-Devices-Make-Them-Smarter-via-eWeLink-APP-IFTTT-p-1741713.html?rmmds=search&cur_warehouse=CN

    • @n1kkri
      @n1kkri 3 роки тому

      @@ViktorKjartansson What's the total cost to do this project with ZB Bridge (I have no experience with this) vs. buying a Ring 3 currently selling for $139 sale ? I was hoping for a simpler approach. Add device to doorbell chime with connection either using a small current probe onto one of the wires, or small reed switch placed near the chime solenoid or other method. The device connects to my wifi and sends either email or text without requiring any additional fees.

    • @n1kkri
      @n1kkri 3 роки тому

      @@ViktorKjartansson I was looking for a product already built and cheap. Current probe goes on a wire and when it senses a change in current flow it will send a text message. Not something to replace doorbell button.

    • @n1kkri
      @n1kkri 3 роки тому

      @@ViktorKjartansson I am not familar with ZB devices but I believe they rely on additional hardware to send text message. I am looking for a simple stand alone device.

    • @n1kkri
      @n1kkri 3 роки тому

      I just tried following your steps to load the software for adruino. I don't have a board yet but thought I could learn
      how you load in a file into the program to look at it. I got lost at 7:16 (Open Detector) where do I find that?

  • @frodemolland6249
    @frodemolland6249 5 років тому +1

    Hi, possible to use this to get notification when garage door is open?

  • @Animace
    @Animace 4 роки тому

    Hello, I have used your approach; however, I get 400 Bad Request answer from PLIVO. Do you have an idea what might be wrong? Can you help me out, please?

    • @ViktorKjartansson
      @ViktorKjartansson  4 роки тому

      Hi, you have to use https not http when you send to PLIVO

  • @stevenoltay
    @stevenoltay 4 роки тому

    Why have you not shared the code?....

  • @Dark-uh6sc
    @Dark-uh6sc 2 роки тому

    SMS?

  • @MrBobWareham
    @MrBobWareham 4 роки тому

    Sounds like you are so bored with what you are doing so disinterested

  • @MaxGoddur
    @MaxGoddur 5 років тому

    Is there a method for sending an SMS text message without using third-party websites as in IFTTT or the one you used. Would like to keep the message sent and received within the LAN.

    • @captainahab8444
      @captainahab8444 3 місяці тому

      There is. Use an email server to send the text message. You can send text messages from any email

  • @SergioPendola
    @SergioPendola 3 роки тому

    Sketch, program?

    • @panconkisu
      @panconkisu 2 роки тому

      1 year late but
      #include
      #include
      #include "credentials.h"
      int switchRead=D1;
      bool hasSentMessage = false;
      void setup() {
      Serial.begin(115200);
      pinMode(LED_BUILTIN, OUTPUT);
      pinMode(switchRead, INPUT_PULLUP);
      connectWifi();
      }
      void loop() {
      if (digitalRead(switchRead) == HIGH) {
      digitalWrite(LED_BUILTIN, LOW);
      Serial.println("Door Open");
      if (!hasSentMessage) {
      sendMessage();
      }
      } else {
      Serial.println("Door Closed");
      hasSentMessage = false;
      }
      digitalWrite(LED_BUILTIN, HIGH);
      delay(1000);
      }
      void connectWifi() {
      WiFi.mode(WIFI_STA);
      WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
      Serial.println("connecting");
      while (WiFi.status() != WL_CONNECTED) {
      Serial.print(".");
      delay(500);
      }
      Serial.print("connected: ");
      Serial.println(WiFi.localIP());
      digitalWrite(LED_BUILTIN, HIGH);
      }
      void sendMessage() {
      Serial.println("sendMessage");
      HTTPClient http;
      http.begin(String("api.plivo.com/v1/Account/") + AUTH_ID + String("/Message/"), FINGERPRINT);
      http.addHeader("Content-Type", "application/json");
      http.addHeader("Authorization", "Basic " + AUTH_TOKEN);
      String postMessage = String("{\"src\":\"") + FROM_TELEPHONE + String("\",\"dst\":\"") + TO_TELEPHONE + String("\",\"text\":\"Main door is OPEN!\"}");
      Serial.println(postMessage);
      auto httpCode = http.POST(postMessage);
      if (httpCode < 0) {
      Serial.printf("POST failed, error: %s
      ", http.errorToString(httpCode).c_str());
      }
      Serial.println(httpCode);
      http.writeToStream(&Serial);
      http.end();
      hasSentMessage = true;
      }

  • @anandkeskar6338
    @anandkeskar6338 3 роки тому

    Thank you so much 😊

  • @ahmedayachi2036
    @ahmedayachi2036 4 роки тому +2

    Thanks for this video, the code please :)

  • @kochunkit6871
    @kochunkit6871 3 роки тому

    Can you give me code?

    • @panconkisu
      @panconkisu 2 роки тому

      #include
      #include
      #include "credentials.h"
      int switchRead=D1;
      bool hasSentMessage = false;
      void setup() {
      Serial.begin(115200);
      pinMode(LED_BUILTIN, OUTPUT);
      pinMode(switchRead, INPUT_PULLUP);
      connectWifi();
      }
      void loop() {
      if (digitalRead(switchRead) == HIGH) {
      digitalWrite(LED_BUILTIN, LOW);
      Serial.println("Door Open");
      if (!hasSentMessage) {
      sendMessage();
      }
      } else {
      Serial.println("Door Closed");
      hasSentMessage = false;
      }
      digitalWrite(LED_BUILTIN, HIGH);
      delay(1000);
      }
      void connectWifi() {
      WiFi.mode(WIFI_STA);
      WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
      Serial.println("connecting");
      while (WiFi.status() != WL_CONNECTED) {
      Serial.print(".");
      delay(500);
      }
      Serial.print("connected: ");
      Serial.println(WiFi.localIP());
      digitalWrite(LED_BUILTIN, HIGH);
      }
      void sendMessage() {
      Serial.println("sendMessage");
      HTTPClient http;
      http.begin(String("api.plivo.com/v1/Account/") + AUTH_ID + String("/Message/"), FINGERPRINT);
      http.addHeader("Content-Type", "application/json");
      http.addHeader("Authorization", "Basic " + AUTH_TOKEN);
      String postMessage = String("{\"src\":\"") + FROM_TELEPHONE + String("\",\"dst\":\"") + TO_TELEPHONE + String("\",\"text\":\"Main door is OPEN!\"}");
      Serial.println(postMessage);
      auto httpCode = http.POST(postMessage);
      if (httpCode < 0) {
      Serial.printf("POST failed, error: %s
      ", http.errorToString(httpCode).c_str());
      }
      Serial.println(httpCode);
      http.writeToStream(&Serial);
      http.end();
      hasSentMessage = true;
      }

  • @michaelcarroll4832
    @michaelcarroll4832 3 роки тому

    Hi Viktor; What is the name of the USB cable to the ESP 8266 called? Where can I purchase it? Thanks;Mike

    • @ViktorKjartansson
      @ViktorKjartansson  3 роки тому +1

      Hi, its called micro usb cable like here
      www.amazon.com/XIAE-Braided-Charging-Aluminum-More-Black/dp/B088GVSFWZ/ref=sr_1_3?crid=C02G6TONBCI8&dchild=1&keywords=micro+usb+cable&qid=1620957998&sprefix=micro+usb%2Caps%2C243&sr=8-3

    • @michaelcarroll4832
      @michaelcarroll4832 3 роки тому

      @@ViktorKjartansson Thank you for your reply. I appreciate your response and your video.

    • @michaelcarroll4832
      @michaelcarroll4832 3 роки тому

      @@ViktorKjartansson Do you have videos on the ESP32? What manufacture (Please send a link) do you recommend for development and what you have used ? There are so many cb out there. !! Do you prefer the ESP 8266 or ESP 32?
      Thanks again for your responses. !! :)

    • @ViktorKjartansson
      @ViktorKjartansson  3 роки тому

      @@michaelcarroll4832 Hi, the ESP32 is little more powerful so i would recommend it

  • @brfilmservice91
    @brfilmservice91 6 років тому

    sniðugt..

  • @root8able
    @root8able 4 роки тому

    why do you need a breadboard? can't you connect it directly?

  • @nguyenchuong986
    @nguyenchuong986 3 роки тому

    can it work with ESP32 Camera??

  • @Dark-uh6sc
    @Dark-uh6sc 2 роки тому

    Cod?

    • @panconkisu
      @panconkisu 2 роки тому

      6 months late but
      #include
      #include
      #include "credentials.h"
      int switchRead=D1;
      bool hasSentMessage = false;
      void setup() {
      Serial.begin(115200);
      pinMode(LED_BUILTIN, OUTPUT);
      pinMode(switchRead, INPUT_PULLUP);
      connectWifi();
      }
      void loop() {
      if (digitalRead(switchRead) == HIGH) {
      digitalWrite(LED_BUILTIN, LOW);
      Serial.println("Door Open");
      if (!hasSentMessage) {
      sendMessage();
      }
      } else {
      Serial.println("Door Closed");
      hasSentMessage = false;
      }
      digitalWrite(LED_BUILTIN, HIGH);
      delay(1000);
      }
      void connectWifi() {
      WiFi.mode(WIFI_STA);
      WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
      Serial.println("connecting");
      while (WiFi.status() != WL_CONNECTED) {
      Serial.print(".");
      delay(500);
      }
      Serial.print("connected: ");
      Serial.println(WiFi.localIP());
      digitalWrite(LED_BUILTIN, HIGH);
      }
      void sendMessage() {
      Serial.println("sendMessage");
      HTTPClient http;
      http.begin(String("api.plivo.com/v1/Account/") + AUTH_ID + String("/Message/"), FINGERPRINT);
      http.addHeader("Content-Type", "application/json");
      http.addHeader("Authorization", "Basic " + AUTH_TOKEN);
      String postMessage = String("{\"src\":\"") + FROM_TELEPHONE + String("\",\"dst\":\"") + TO_TELEPHONE + String("\",\"text\":\"Main door is OPEN!\"}");
      Serial.println(postMessage);
      auto httpCode = http.POST(postMessage);
      if (httpCode < 0) {
      Serial.printf("POST failed, error: %s
      ", http.errorToString(httpCode).c_str());
      }
      Serial.println(httpCode);
      http.writeToStream(&Serial);
      http.end();
      hasSentMessage = true;
      }

  • @miratechsolutions5777
    @miratechsolutions5777 4 роки тому

    What was the total cost at the end (prices sum of of all elemennts)?

  • @WMCLComputers
    @WMCLComputers 5 років тому

    @
    Viktor Kjartansson There is in the second line an #include that is never shown in the tutorial who do we get that file or code?