Build a Learning Assistant With ESP32 to Improve Study Habits

by Rotem Peled in Circuits > Arduino

101 Views, 3 Favorites, 0 Comments

Build a Learning Assistant With ESP32 to Improve Study Habits

cover.jpg

Do you find it difficult to sit and study? Do you find yourself on your cell phone 10 minutes after you started studying? Do you learn better with other people?

If the answer is yes, then this is the Instructable for you.

This Instructable guides you in creating a learning assistant system using an ESP32 microcontroller. The system manages study and break times, visualizes time remaining via an LED strip, and integrates with Blynk and MAKE (Integromat) for remote control and automation. This system is ideal for students or professionals aiming to enhance productivity during study sessions.


Video Demonstration:

Watch the video below to see the system in action.

https://www.youtube.com/watch?v=hZPbO357Cxw

Supplies

61o2ZUzB4XL._AC_UF894,1000_QL80_.jpg
Screenshot 2024-08-13 at 10.59.20.png
Screenshot 2024-08-14 at 18.03.58.png
Screenshot 2024-08-14 at 18.01.13.png
Screenshot 2024-08-13 at 10.57.10.png

Those all the components are needed for our kit:

Hardware Components:

  1. ESP32 Microcontroller
  2. IR Remote and Receiver
  3. Adafruit NeoPixel LED Strip (12 LEDs)
  4. Single LED
  5. DHT22 Temperature Sensor
  6. Power Supply

Software Components:

  • Arduino IDE
  • Blynk App
  • MAKE (Integromat)

Set Up the Circuit - Assemble the Hardware

1.jpg

Wiring Everything Together:

  1. Connect the LED Strip to the ESP32: The LED strip has a pin labeled “DIN” (Data Input), Connect this to pin 26 on the ESP32.
  2. Hook Up the Single LED: Connect this LED to pin 2 on the ESP32. It will light up during study mode.
  3. Set Up the IR Receiver: This part receives signals from the remote. Connect it to pin 34.
  4. Attach the IR Sender: This part sends out signals, like to turn off your TV during study time. Connect it to pin 12.
  5. Connect the Temperature Sensor: This sensor monitors the room’s temperature. connects to pin 16.

Set Up the Blynk App

F83ARFFLZTV3QB9.png
Screenshot 2024-08-14 at 18.11.47.png
  1. Download Blynk:
  2. Option 1: Using the Mobile App - You can find it on the App Store or Google Play.
  3. Option 2: Using the Blynk Web Dashboard - go to blynk.
  4. Create a New Project: Select ESP32 as the device and WiFi as the connection type.
  5. Add Widgets:
  6. Add a Gauge widget and link it to virtual pin V0. Define the units to "Celsius" of "Fahrenheit". It will show the current room temperature.
  7. Add a Label widget and link it to virtual pin V1. Define the "Data Type" to "String". This will display the current mode (Standby, Study, or Break).
  8. Add a Label widget and link it to virtual pin V2. Define the units to "minutes". This will show the remaining time for the current mode.
  9. Add a Label widget and link it to virtual pin V4. Define the units to "minutes". This will track the total study time in minutes.
  10. Add a Label widget and link it to virtual pin V3. Define the units to "minutes". This will track the total break time in minutes.

Set Up Google Sheets and Telegram Bot

Screenshot 2024-08-12 at 15.31.14.png
IMG_9700.PNG
IMG_9698.PNG

Create a New Google Sheet:

  1. Go to Google Sheets and log in to your account (or create a new one)
  2. click on "+" to create a new spreadsheet.
  3. Name your sheet something like "Study Log."
  4. Label the columns as - A1: "Date" , A2: "Start Time" , A3: "Mode" , A4: "End Time".


Create Your Telegram Bot:

  1. Download Telegram app and sign in - or log in if you have an account.
  2. Search for "BotFather" (this is the official bot to create new bots).
  3. Start a chat with BotFather and type /newbot. Follow the instructions to name your bot and get your API token.
  4. Save the token, as you'll need it to connect the bot to MAKE.
  5. Click on the link to you bot and Press "Start", then send some message - "hello".
  6. Open a web browser and go to https://api.telegram.org/bot<YourBotToken>/getUpdates . Replace <YourBotToken> with the API token you received from BotFather (step d).
  7. You’ll see a JSON response that includes your Chat ID. It usually appears under the "chat":{"id":section.
  8. Save the Chat ID, as you'll need it when setting up the Telegram bot module in MAKE.


Set Up the Make.com

Screenshot 2024-08-14 at 18.05.46.png
Screenshot 2024-08-14 at 18.16.26.png
Screenshot 2024-08-14 at 18.20.37.png
Screenshot 2024-08-12 at 15.10.17.png
Screenshot 2024-08-14 at 18.17.25.png
Screenshot 2024-08-14 at 18.19.15.png
Screenshot 2024-08-13 at 11.58.00.png
Screenshot 2024-08-12 at 15.08.47.png
Screenshot 2024-08-14 at 18.13.17.png
  • Go to Make.
  • Log in or create new account if you don't have one.
  • Scenario 1 - Study Mode: Click on "Create a New Scenario".
  • Add Webhook module:
  • Click the "+" button to add a module and search for "Webhook" and select it.
  • Choose "Custom Webhook".
  • Press on the "Add" and name your webhook - "Study mode".
  • Then you will see a unique URL. This URL will be used in your ESP32 code to trigger the scenario.
  • Add Google Sheets module:
  • Click the "+" button after the Webhook module.
  • Search for "Google Sheets" and select "Search Rows"
  • Connect your Google account and select the spreadsheet you created.
  • Set the Sort Order to "Descending" based on the "Row number" to get the latest entry.
  • Set the Limit to "1" to retrieve only the last row.
  • Add Router:
  • Click the "+" button after the Google Sheets module.
  • Search for "Router" module and select it - you will have 2 paths coming out of it.
  • Path 1:
  • Click the "+" button.
  • Search for "Google Sheets" and select "Update a Row"
  • Connect your Google account and select the spreadsheet you created.
  • Set the Row number to the Row number value returned from the "Search Row" module.
  • Add this text to the "End Time" column - {{formatDate(now; "HH:mm")}}
  • Press on the link between the "Router" and the "Update a Row" module
  • Add filter - Condition : add the Row number from the "Search Row" module , choose the Numeric operators: Greater then, then write 0
  • Press on "Add AND rule" - Condition : add the Date from the "Search Row" module , choose the Text operators: Equal to, then write - {{formatDate(now; "DD-MM-YYYY")}}
  • Path 2:
  • Add Telegram Bot module:
  • Click the "+" button after the Webhook module.
  • Search for "Telegram Bot" and select "Send a Text Message".
  • Connect your Telegram account and set the message text to "Start Learning."
  • Add the Chat ID from step 3.
  • Add Spotify module:
  • Add another module by clicking the "+" button after the Telegram module.
  • Search for "Spotify" and select "Start/Resume a User's Playlist."
  • Connect your Spotify account and add the URI of and preferred study playlist.
  • Choose the Device ID you want to hear the music from
  • Add Google Sheets module:
  • Add a new module by clicking the "+" button after the Spotify module
  • Search for "Google Sheets" and select "Add a Row."
  • Connect your Google account, select the spreadsheet you created in step 3.
  • Add this text for the "Date" column - {{formatDate(now; "DD-MM-YYYY")}}
  • Add this text for the "Start Time" column - {{formatDate(now; "HH:mm")}}
  • Add "Study" to the "Mode" column
  • Add this text to the "End Time" column - {{formatDate(addMinutes(now; 45); "HH:mm")}}
  • Scenario 2 - Break Mode: Click on "Create a New Scenario".
  • Add Webhook module:
  • Click the "+" button to add a module and search for "Webhook" and select it.
  • Choose "Custom Webhook".
  • Press on the "Add" and name your webhook - "Break mode".
  • Then you will see a unique URL. This URL will be used in your ESP32 code to trigger the scenario.
  • Add Google Sheets module:
  • Click the "+" button after the Webhook module.
  • Search for "Google Sheets" and select "Search Rows"
  • Connect your Google account and select the spreadsheet you created.
  • Set the Sort Order to "Descending" based on the "Row number" to get the latest entry.
  • Set the Limit to "1" to retrieve only the last row.
  • Add Google Sheets module:
  • Click the "+" button after the google sheets module.
  • Search for "Google Sheets" and select "Update a Row"
  • Connect your Google account and select the spreadsheet you created.
  • Set the Row number to the Row number value returned from the "Search Row" module.
  • Add this text to the "End Time" column - {{formatDate(now; "HH:mm")}}
  • Add Telegram Bot module:
  • Click the "+" button after the second Google Sheets module.
  • Search for "Telegram Bot" and select "Send a Text Message".
  • Connect your Telegram account and set the message text to "It's time for a break!"
  • Add the Chat ID.
  • Add Spotify module:
  • Add another module by clicking the "+" button after the Telegram module.
  • Search for "Spotify" and select "Pause a User's Playback."
  • Connect your Spotify account and Choose the Device ID you picked in the first scenario.
  • Add Google Sheets module:
  • Add a new module by clicking the "+" button after the Spotify module
  • Search for "Google Sheets" and select "Add a Row."
  • Connect your Google account, select the spreadsheet you created.
  • Add this text for the "Date" column - {{formatDate(now; "DD-MM-YYYY")}}
  • Add this text for the "Start Time" column - {{formatDate(now; "HH:mm")}}
  • Add "Break " to the "Mode" column
  • Add this text to the "End Time" column - {{formatDate(addMinutes(now; 45); "HH:mm")}}
  • Add Delay Tools: to send '5' minutes alert before returning to study
  • Click the "+" button after the Google Sheet module
  • Search for "Sleep"
  • Write 300 - equals to 5 minutes
  • Add another Sleep module and write 295.
  • Add Telegram Bot module:
  • Click the "+" button after the second sleep module.
  • Search for "Telegram Bot" and select "Send a Text Message".
  • Connect your Telegram account and set the message text to "you have 5 minutes left for the break!"
  • Add the Chat ID.
  • Activate both scenarios

Modifying the Code

Screenshot 2024-08-12 at 16.05.12.png
Screenshot 2024-08-12 at 16.05.59.png
Screenshot 2024-08-12 at 16.06.34.png

Now that your hardware is set up, and you've configured both the Blynk app and MAKE scenarios, it’s time to program the ESP32. The code will control the study and break cycles, manage the LED strip, and communicate with the Blynk app and MAKE.com.


  1. Download the Arduino IDE if you haven’t already.
  2. Install the Necessary Libraries: Blynk, Adafruit NeoPixel (for the LED strip), IRremote (for the remote control), DHT (for the temperature sensor), and WiFi.
  3. Open the Arduino IDE and paste in the modified code provided in the attached file.
  4. Replace the Placeholder Values:
  5. Wi-Fi Credentials: Replace "Your_SSID" with your actual Wi-Fi network name and "Your_Password" with your Wi-Fi password.
  6. Blynk Credentials: Replace "Your_Template_ID", "Your_Template_Name", and "Your_Auth_Token" with the actual values provided by Blynk when you set up your project.
  7. Webhook URLs: Replace "Your_Study_Mode_Webhook_URL" and "Your_Break_Mode_Webhook_URL" with the actual URLs generated by MAKE (Integromat) for your study and break mode scenarios.


Upload the Code

  1. Connect your ESP32 to your computer using a USB cable.
  2. Select the correct ESP32 board and port in the Arduino IDE.
  3. Click “Upload” to transfer the code to your ESP32.

Testing

2.jpg
3.jpg
IMG_9685.jpg
IMG_9682.jpg
Screenshot 2024-08-11 at 21.29.49.png

Ensure that each component of your learning assistant system is functioning correctly, including the ESP32, Blynk app, LED indicators, and MAKE (Integromat) automations.

  • Press the “OK” button on your remote.
  • Start Study Mode:
  • Expected Results:
  • The LED strip should turn blue, indicating that study mode has started.
  • The Single LED should turn on, indicating active study mode.
  • A Telegram message should be sent to your chat, saying “Start Learning.”
  • Spotify should start playing your selected study playlist.
  • The Blynk app should update to show “STUDY” as the current mode, the timer should begin counting down from 45 minutes, and the LED strip should visually indicate the remaining time.
  • If the TV is "ON" it will be turned off.
  • Check Temperature Control:
  • Allow the system to run for at least 5 minutes.
  • Expected Results:
  • The system should check the temperature every 5 minutes. If the room temperature is above the hot temperature threshold, the AC should turn on. if below the cold temperature threshold, the AC should turn off.
  • The current temperature should be displayed in the Blynk app under the Gauge widget.
  • Switch to Break Mode:
  • After 45 minutes, the system should automatically switch to break mode.
  • Expected Results:
  • The LED strip should turn red, indicating that break mode has started.
  • The Single LED should turn off, indicating that it’s break time.
  • A Telegram message should be sent to your chat, saying “It’s time for a break!”
  • Spotify should pause the music.
  • The Blynk app should update to show “BREAK” as the current mode, the timer should begin counting down from 15 minutes, and the LED strip should visually indicate the remaining time.
  • After 10 minutes a Telegram message should be sent to your chat, saying “You have 5 minutes left for the break!”
  • Manual Mode Switching:
  • Press the “OK” button during break mode.
  • Expected Results:
  • The system should switch back to study mode.


Reviewing Your Study Sessions

Screenshot 2024-08-14 at 18.39.09.png
Screenshot 2024-08-11 at 21.29.49.png

At the end of each day, you can review your study sessions to track your productivity and make improvements.

Google Sheets Log:

  • Open the “Study Log” Google Sheet you set up earlier.
  • You’ll see the start time, end time, date, and mode (Study or Break) for each session logged throughout the day, and you can see how much time you spent studying versus taking breaks and make adjustments to your routine if needed.

Blynk App Summary:

  • In the Blynk app, check the labels for the total study time and break time.
  • Compare these numbers with your goals for the day and see if you met your productivity targets.

Congratulations!!

Congratulations! You’ve successfully built a smart learning assistant system using the ESP32. This project helps you manage your study sessions more effectively by integrating IoT technology with practical automation. Whether you’re preparing for exams or working on projects, this system can keep you focused and balanced.

Enhancements and Future Improvements

Now that you've successfully built and tested your learning assistant system, here are some additional ideas to further enhance and customize your project:

  • Enclosure for ESP32 and Components:
  • Create a custom box or enclosure to house the ESP32, LED strip, and other components. This will not only make your setup look more professional but also protect the electronics and make it more convenient to use.
  • Expand Functionality:
  • Consider adding additional modes like a Lunch Break Mode or Longer Break Mode (using the remote buttons). If you upgrade your MAKE.com account, you can create more complex scenarios to make the system more intelligent and tailored to your needs.
  • Enhance the Blynk Dashboard:
  • Add interactive controls like sliders or buttons to adjust study and break durations directly from the Blynk app, without modifying the code.
  • Personalize the Experience:
  • Customize the motivational messages in the Telegram Bot to keep you engaged. Adjust the Google Sheets data to better reflect your goals and track your progress.
  • Upgrade LED Strip:
  • Use an LED strip with more LEDs for more precise time visualization. You can modify the code to control additional LEDs, enhancing the feedback during study and break sessions.
  • Adjust Study/Break Durations:
  • Feel free to modify the code to change the study and break durations according to your preferences. Whether you prefer longer study periods or shorter breaks, the flexibility is in your hands.
  • Integrate Additional Sensors:
  • Add more sensors like a motion detector, light sensor, or sound sensor. For example, a motion sensor could pause the study timer if you leave your desk, making the system more interactive and responsive.
  • Explore Voice Control:
  • Integrate voice control using Google Assistant or Amazon Alexa, allowing you to start and stop study sessions with voice commands.

These enhancements will help you create a more personalized and effective learning assistant system, with endless possibilities for further development. Experiment with these ideas and make the system truly yours!