Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

cakraawijaya/Bot-Telegram-based-GPS-monitoring-using-UART-communication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open Source Love License: MIT GitHub last commit Project1 Project2 Type

Bot-Telegram-based-GPS-monitoring-using-UART-communication

Theft of goods is rampant in Indonesia today because it is first influenced by economic factors, then the lack of awareness from the local community in protecting their personal belongings, thus creating opportunities for thieves to be able to act. Therefore, this project was created as an effort to improve the security of goods in close proximity. In this case, the author tries to use the UART protocol on the Arduino and Wemos side. This project has been implemented and took approximately 1 month. There are 2 types of development boards used. Arduino Pro Micro is used to hold the coordinate data obtained from the sensor, then send the coordinate data to Wemos D1 Mini using UART communication protocol: Hardware Serial. While the Wemos D1 Mini is used to accommodate coordinate data from the Arduino Pro Micro using the UART communication protocol: Software Serial. Furthermore, the raw data that has been received is processed into useful information, then sent to the Telegram Bot. This Telegram bot can respond to users if there is interaction in it. The benefit of making this project is none other than to add insight. The result of this project is that the coordinates of personal items can be monitored at any time easily and quickly only through Telegram Bot, so that existing items will not be easily stolen. However, if the item is out of the router's range, it can be completely lost. To overcome this shortcoming, you can add a GSM module that comes with a SIM card in future research.



Project Requirements

Part Description
Development Board • Arduino Pro Micro Leonardo ATMEGA32U4
• Wemos D1 Mini
Code Editor Arduino IDE
Application Support Telegram Bot
Driver CH340 USB Driver
Communications Protocol • Universal Asynchronous Receiver-Transmitter (UART)
• MTProto
IoT Architecture 3 Layer
Programming Language C/C++
Arduino Library • SoftwareSerial (default)
• TinyGPS++
• CTBot
• ArduinoJson
Sensor GPS NEO6MV2 (x1)
Other Components • Micro USB cable - USB type A (x1)
• Jumper cable (1 set)
• Li-ion battery 18650 5V (x1)
• 1-Slot battery holder (x1)
• Micro USB cable - 2 pin JST (x1)



Download & Install

  1. Arduino IDE

    https://bit.ly/ArduinoIDE_Installer
    

  2. CH340 USB Driver

    https://bit.ly/CH340_USB_Driver
    



Project Designs

Block Diagram Pictorial Diagram
block-diagram pictorial-diagram
Wiring
wiring



Basic Knowledge

Basically, a device can be communicated with other devices either wirelessly or by cable. Communication between commonly used hardware is Serial Communication. It can be known that there are three types of Serial Communication, which include: UART (Universal Asynchronous Receiver-Transmitter), SPI (Serial Peripheral Interface), and I2C (Inter Integrated Circuit). Serial UART communication allows each device to act as a master or slave in a limited way. Master is the primary device that has full authority over the control of the Slave, while the Slave is the secondary device that is under the authority of the Master device. There are two kinds of UART Serial Communication, namely Hardware Serial and Software Serial. Hardware serial communication can be done by connecting the TX and RX pins crosswise on each development board, for example: RX-TX, then TX-RX. The TX pin is for sending data, while the RX pin is for receiving data. Serial Software Communication is more or less the same as Serial Hardware Communication in terms of cabling, but there are differences in terms of coding. By using this Serial Software you can overcome the constraints of the limitations of RX and TX pins on the development board. To communicate with this Serial Software is quite easy, namely by using certain Digital Pins as a substitute for TX pins and RX pins.

The Arduino Pro Micro has several pins that can support Software Serial which include :

Pin Name Support
8 RX and TX
9 RX and TX
10 RX and TX
16 RX and TX
14 RX and TX
15 RX and TX
Other Digital pins TX only


The Wemos D1 Mini has several pins that can support Software Serial which include :

Pin Name Support
D0 TX only
D1 RX and TX
D2 RX and TX
D3 RX and TX
D4 RX and TX
D5 RX and TX
D6 RX and TX
D7 RX and TX
D8 RX and TX

Wemos D1 Mini Pinout Reference : Click Here



Arduino IDE Setup

  1. Open the Arduino IDE first, then open the project by clicking File -> Open :

    APmicro_gpstracker.ino

    WD1mini_bot.ino


  2. Fill in the Additional Board Manager URLs in Arduino IDE

    Click File -> Preferences -> enter the Boards Manager Url by copying the following link :

    http://arduino.esp8266.com/stable/package_esp8266com_index.json
    

  3. Board Setup in Arduino IDE

    i

    How to setup the Arduino Pro Micro board

    Click Tools -> Board -> Arduino AVR Boards -> Arduino Micro


    ii

    How to setup the Wemos D1 Mini board

    • Click Tools section -> Board -> Boards Manager -> Install esp8266.

    • Then click Tools -> Board -> ESP8266 Boards -> Wemos D1 Mini.


  4. Change the Board Speed in Arduino IDE

    i

    How to change the speed of Arduino Pro Micro board

    Click Tools -> Upload Speed -> 9600


    ii

    How to change the speed of Wemos D1 Mini board

    Click Tools -> Upload Speed -> 115200


  5. Install Library in Arduino IDE

    Download all the library zip files. Then paste it in the: C:\Users\Computer_Username\Documents\Arduino\libraries


  6. Port Setup in Arduino IDE

    Click Port -> Choose according to your device port (you can see in device manager)


  7. Change the WiFi Name, WiFi Password, and so on according to what you are currently using.

  8. Before uploading the program please click: Verify.

  9. If there is no error in the program code, then please click: Upload.

  10. If there is still a problem when uploading the program, then try checking the driver / port / others section.



Telegram Bot Setup

  1. Open @BotFather.

  2. Type /newbot.

  3. Type the desired bot name, for example: personalgps_bot.

  4. Type the desired bot username, for example: personalgps_bot.

  5. Also do it for bot image settings, bot descriptions, and so on according to your needs.

  6. Copy your telegram bot API token -> then paste it into the #define botToken "YOUR_API_BOT_TOKEN" section.

    For example :

    #define botToken "2006772150:AAE6Fdjk3KbiySkzV6CLbd6ClJDzgTfJ5y0"


Get Started

  1. Download and extract this repository.

  2. Make sure you have the necessary electronic components.

  3. Make sure your components are designed according to the diagram.

  4. Configure your device according to the settings above.

  5. Please enjoy [Done].



Demonstration of Application

Via Telegram: @personalgps_bot



Highlights

GPS Device
gps_device
Telegram Bot
telegram_bot1 telegram_bot2



Component Testing

You can download the component test file via the following link: Click Here



Appreciation

If this work is useful to you, then support this work as a form of appreciation to the author by clicking the ⭐Star button at the top of the repository.



Disclaimer

This application is my own work and is not the result of plagiarism from other people's research or work, except those related to third party services which include: libraries, frameworks, and so on.



LICENSE

MIT License - Copyright © 2024 - Devan C. M. Wijaya, S.Kom

Permission is hereby granted without charge to any person obtaining a copy of this software and the software-related documentation files to deal in them without restriction, including without limitation the right to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons receiving the Software to be furnished therewith on the following terms:

The above copyright notice and this permission notice must accompany all copies or substantial portions of the Software.

IN ANY EVENT, THE AUTHOR OR COPYRIGHT HOLDER HEREIN RETAINS FULL OWNERSHIP RIGHTS. THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, THEREFORE IF ANY DAMAGE, LOSS, OR OTHERWISE ARISES FROM THE USE OR OTHER DEALINGS IN THE SOFTWARE, THE AUTHOR OR COPYRIGHT HOLDER SHALL NOT BE LIABLE, AS THE USE OF THE SOFTWARE IS NOT COMPELLED AT ALL, SO THE RISK IS YOUR OWN.