This project demonstrates the use of an ESP8266 microcontroller to generate Time-based One-Time Passwords (TOTP) and validate them through a Python application using MQTT protocol. The ESP8266 acts as an OTP generator, while the Python application handles the validation of these OTPs. To configure the totp you'll need two things 1] secret key(in our case its the mac id of the esp) 2] Current time (which we get throught the ntp) The secret key can be in base32 or Hex ,as per your need you use any one of them As I needed the code to identify the macID of the esp itself I have written the code as per my need, you can manually add the hmac key(secret key) by editing the code slightly.
The main components of this project are:
- ESP8266 Microcontroller: Configured to generate TOTP.
- Python Application: Subscribes to MQTT topics and validates OTPs.
- MQTT Broker: Facilitates communication between the ESP8266 and the Python application.
- TOTP Generation: Uses the ESP8266 to generate time-based OTPs.
- MQTT Communication: Sends and receives OTPs through MQTT.
- Python Validation: Validates the received OTPs using a Python script.
- Secure and Reliable: Ensures secure and reliable OTP validation.
- ESP8266 Microcontroller
- ESP8266 WiFi library
- TOTP library from Luca Dentella
- PubSubClient library for MQTT connection
- Any python application
paho-mqtt
Python library- MQTT Broker (e.g., MQTTX)
-
Hardware Requirements:
- ESP8266 microcontroller
- USB cable to connect ESP8266 to the computer
-
Software Requirements:
- Arduino IDE
- ESP8266 Board package for Arduino
-
Installation:
- Install the ESP8266 board package in Arduino IDE.
- Install necessary libraries for TOTP generation and MQTT communication(for totp library use luca dentella and for mqtt library use PubSubClient).
-
Code:
- They are provided above in txt format.
- MQTT BROKER
- Install any MQTT broker (I have used MQTTX)
- Use Proper username
- Proper Password
- Broker server ID
- And use the proper topic
-
Dependencies:
- Install
paho-mqtt
library:pip install paho-mqtt
- Install
-
Code: Uploaded above in txt format.
- Power on the ESP8266 and ensure it connects to your Wi-Fi network.
- Ensure your MQTT broker is running and accessible.
- Run the Python application to start listening for OTPs.
- The ESP8266 will publish OTPs to the specified MQTT topic.
- The Python application will validate the received OTPs and log the results.
- esp8266-code/: Contains the Arduino sketch for the ESP8266.
- python-app/: Contains the Python application for OTP validation.
For any inquiries or support, please contact dhruvsavla03@gmail.com.