Open 12V Door with Telegram

Hi!

I was thinking in made a project of a door control sistem but based in telegram. My idea would be something like make a bot/group of telegram in which only the auhorized people could open a door in a restringed time (like office hours) sending a message. I found information about garage doors like this but it´s for raspberry and I don´t know how to adapt it to my idea.

I will apreciate any type of help!

Thanks in advance!

The Instructables website is just too tedious to study for quick information.

Please provide a synopsis of it here.

How does the Telegram system work. What is needed to receive a Telegram message.
(I always thought telegrams were short messages on a piece of paper delivered to your home by a telegram boy - and thus much faster than the post)

Post a link to the datasheet for the door control system you plan to use.

Can you do your project with an RPi?
Or maybe you could receive the messages with the RPi and use it to control an Arduino to work the door control system.

…R

You mean this telegram? https://en.wikipedia.org/wiki/Telegram_(software)

Or a telegraph? |500x351

I assume, the OP is talking about an app called Telegram, which is similar to whatsapp.

How do you intercept messages coming to Telegram? Does telegram client provide any way to read a message from a different app?

As far as I know, I could find api for Telegram in JAVA (Processing ) and python... The message is not easily intercepted due to the encryption.. As a stand alone project using Just Arduino... I believe its not possible.. I might be wrong though.

There is an api for arduino here and about the raspberry I found this installation that looks easy but the problem that I found is that in this other tutorial says that could be made with lua (I don´t know anything about coding in lua):ç

Read this tutorial, we use this configuration as start point.

To intercept a new incoming message we create a file action.lua

"Lua is a powerful, fast, lightweight, embeddable scripting language.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping." From http://www.lua.org.

About the door opener my idea will be something like this (sorry about paint) in attachments

Thanks in advance

I don't know anything about the Zero or MKR1000 - maybe you should ask the Moderator to move your Thread to one of those specialized sections of the Forum.

...R

Any ideas?

As you posted, there is a Telegram library for Arduino (copied from your post: https://create.arduino.cc/projecthub/Arduino_Genuino/telegram-bot-library-ced4d4)

What is the issue using it? It's just a plain Arduino code, nothing to deal with Lua.

sarouje: As you posted, there is a Telegram library for Arduino (copied from your post: https://create.arduino.cc/projecthub/Arduino_Genuino/telegram-bot-library-ced4d4)

What is the issue using it? It's just a plain Arduino code, nothing to deal with Lua.

Ok, I think it´s a good start point but what about the 12v output? Thanks in advance

JPX97: Ok, I think it´s a good start point but what about the 12v output? Thanks in advance

What you mean by 12v output? You mean to power Arduino? if then can you use a wall adapter that can provide 12v, 1A

Sorry for the delay, I finally make it work but I would like to put a time restriction (8am to 9pm) and a week restriction (monday to friday) but I´m a bit confused about how to make this possible my code until now:

#include <WiFi101.h>
#include <SPI.h>
#include <TelegramBot.h>

// Initialize Wifi connection to the router
char ssid[] = "xxxx";             // your network SSID (name)
char pass[] = "yyyyy";           // your network key

// Initialize Telegram BOT

const char* BotToken = "*****";
const char* BotName = "****";
const char* BotUsername = "****";

WiFiSSLClient client;
TelegramBot bot (BotToken, BotName, BotUsername, client);

const int relayPin = 12;  // the number of the relay pin


void setup() {

  Serial.begin(115200);
  while (!Serial) {}
  delay(3000);


  // attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  while (WiFi.begin(ssid, pass) != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");

  bot.begin();
  pinMode(relayPin, OUTPUT); //set digital pin RELAY OUTPUT

}

void loop() {

  message m = bot.getUpdates(); // Read new messages

  if ( m.text.equals("Open")) {
    digitalWrite(relayPin, HIGH);
    delay(3500);
    digitalWrite(relayPin, LOW);
    Serial.println("message received");
    bot.sendMessage(m.chat_id, "The door is opened");
  }
}

I think it should connect to a “spanish” time server and with the time put another if() and with the week another if()

Any help?

Thanks in advance

JPX97: I think it should connect to a "spanish" time server and with the time put another if() and with the week another if()

This Arduino time class allows you to set the current time, and can also tell you what day of the week it. I think it should be pretty useful for your purposes: http://playground.arduino.cc/Code/Time

michaelsm: This Arduino time class allows you to set the current time, and can also tell you what day of the week it. I think it should be pretty useful for your purposes: http://playground.arduino.cc/Code/Time

I saw it but I don´t really see how to configure the local and real time from npc and make the if()

I know that I´m a bit lost and noob but I don´t see how to make it work

Another thing, at this moment my circuit would be something like this |386x500

It would be like a short version of this project . I think it should work but with the Arduino MKR1000 that use 3.3V and without the 9V battery I feel a bit confused.

Thanks in advance

you better power the relays from an external supply, some times relay draw more current and might damage the Arduino GPIO.

Unless your telegram messages contain a timestamp (from your code it doesnt) you will need some kind of real time clock module see here for a rundown on the most common ones.

What code you need to read will depend on which RTC chip you choose.

sarouje: you better power the relays from an external supply, some times relay draw more current and might damage the Arduino GPIO.

What about this? |500x253

The 9V battery would be connected to the VIN and (with the relay) to the ground. Would this work or would burn the arduino?

And about this:

rw950431: Unless your telegram messages contain a timestamp (from your code it doesnt) you will need some kind of real time clock module see here for a rundown on the most common ones.

What code you need to read will depend on which RTC chip you choose.

I´m really really lost about this. I thought that with a internet connection would be possible something like call to the server, see if the time match and open the gate and start again.

Thanks for the help

I guess you could use an internet service like http://www.timeapi.org/ to read the current time. Or maybe include the NTPClient software.

Its a shame that your telegram bot messages dont come with a timestamp that you can use.

But you need to be aware that the telegram bot requires HTTPS communication which the standard arduinos arent capable of. Hence the article refers to the less-common MKR1000 and Zero models.