Introduction: Build a Learning Assistant With ESP32 to Improve Study Habits
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.
Supplies
Those all the components are needed for our kit:
Hardware Components:
- ESP32 Microcontroller
- IR Remote and Receiver
- Adafruit NeoPixel LED Strip (12 LEDs)
- Single LED
- DHT22 Temperature Sensor
- Power Supply
Software Components:
- Arduino IDE
- Blynk App
- MAKE (Integromat)
Step 1: Set Up the Circuit - Assemble the Hardware
Wiring Everything Together:
- 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.
- Hook Up the Single LED: Connect this LED to pin 2 on the ESP32. It will light up during study mode.
- Set Up the IR Receiver: This part receives signals from the remote. Connect it to pin 34.
- Attach the IR Sender: This part sends out signals, like to turn off your TV during study time. Connect it to pin 12.
- Connect the Temperature Sensor: This sensor monitors the room’s temperature. connects to pin 16.
Step 2: Set Up the Blynk App
- Download Blynk:
- Option 1: Using the Mobile App - You can find it on the App Store or Google Play.
- Option 2: Using the Blynk Web Dashboard - go to blynk.
- Create a New Project: Select ESP32 as the device and WiFi as the connection type.
- Add Widgets:
- 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.
- 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).
- 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.
- 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.
- 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.
Step 3: Set Up Google Sheets and Telegram Bot
Create a New Google Sheet:
- Go to Google Sheets and log in to your account (or create a new one)
- click on "+" to create a new spreadsheet.
- Name your sheet something like "Study Log."
- Label the columns as - A1: "Date" , A2: "Start Time" , A3: "Mode" , A4: "End Time".
Create Your Telegram Bot:
- Download Telegram app and sign in - or log in if you have an account.
- Search for "BotFather" (this is the official bot to create new bots).
- Start a chat with BotFather and type /newbot. Follow the instructions to name your bot and get your API token.
- Save the token, as you'll need it to connect the bot to MAKE.
- Click on the link to you bot and Press "Start", then send some message - "hello".
- 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).
- You’ll see a JSON response that includes your Chat ID. It usually appears under the "chat":{"id":section.
- Save the Chat ID, as you'll need it when setting up the Telegram bot module in MAKE.
Step 4: Set Up the Make.com
- 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
Step 5: Modifying the Code
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.
- Download the Arduino IDE if you haven’t already.
- Install the Necessary Libraries: Blynk, Adafruit NeoPixel (for the LED strip), IRremote (for the remote control), DHT (for the temperature sensor), and WiFi.
- Open the Arduino IDE and paste in the modified code provided in the attached file.
- Replace the Placeholder Values:
- Wi-Fi Credentials: Replace "Your_SSID" with your actual Wi-Fi network name and "Your_Password" with your Wi-Fi password.
- 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.
- 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.
Attachments
Step 6: Upload the Code
- Connect your ESP32 to your computer using a USB cable.
- Select the correct ESP32 board and port in the Arduino IDE.
- Click “Upload” to transfer the code to your ESP32.
Step 7: Testing
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.
Step 8: Reviewing Your Study Sessions
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.
Step 9: 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.
Step 10: 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!