Prerequisites

Hardware and Supplies 

Software Requirements 

Watch The Video

Let's start by seeing our Pomodoro Bot in action!

Set Up Your Raspberry Pi

The Raspberry Pi boots from a USB flash drive (or microSD card). You need to install Raspberry Pi OS on a USB flash drive that you will use with your Pi. For more details about alternative methods of setting up your Raspberry Pi, refer to the Viam docs.

Install Raspberry Pi OS

  1. Connect the USB flash drive (or microSD card) to your computer.
  2. Download the Raspberry Pi Imager and launch it.
  3. Click CHOOSE DEVICE. Select your model of Pi, which is Raspberry Pi 5.
  4. Click CHOOSE OS. Select Raspberry Pi OS (64-bit) from the menu.
  5. Click CHOOSE STORAGE. From the list of devices, select the USB flash drive you intend to use in your Raspberry Pi.
  6. Configure your Raspberry Pi for remote access. Click Next. When prompted to apply OS customization settings, select EDIT SETTINGS.
  7. Check Set hostname and enter the name you would like to access the Pi by in that field, for example, raspberrypi.
  8. Select the checkbox for Set username and password and set a username (for example, your first name) that you will use to log into the Pi. If you skip this step, the default username will be pi (not recommended for security reasons). And specify a password.
  9. Connect your Pi to Wi-Fi so that you can run viam-server wirelessly. Check Configure wireless LAN and enter your wireless network credentials. SSID is your Wi-Fi network name, and password is the network password. Change the section Wireless LAN country to where your router is currently being operated.
  10. Select the SERVICES tab, check Enable SSH, and select Use password authentication.
    Be sure that you remember the hostname and username you set, as you will need this when you SSH into your Pi.
  11. Save your updates, and confirm YES to apply OS customization settings. Confirm YES to erase data on the USB flash drive. You may also be prompted by your operating system to enter an administrator password. After granting permissions to the Imager, it will begin writing and then verifying the Linux installation to the USB flash drive.
  12. Remove the USB flash drive from your computer when the installation is complete.

Connect with SSH

  1. Place the USB flash drive into your Raspberry Pi and boot the Pi by plugging it in to an outlet. A red LED will turn on to indicate that the Pi is connected to power. Make sure you are using a 5V 5A (25W) power supply. USB boot is disabled by default when connected to a 3A power supply, so adequate amperage is required for the optimal performance of your Raspberry Pi 5.
  2. Once the Pi is started, connect to it with SSH. From a command line terminal window, enter the following command. The text in <> should be replaced (including the < and > symbols themselves) with the user and hostname you configured when you set up your Pi. 
    ssh <USERNAME>@<HOSTNAME>.local
  3. If you are prompted “Are you sure you want to continue connecting?”, type “yes” and hit enter. Then, enter the password for your username. You should be greeted by a login message and a command prompt.
  4. Update your Raspberry Pi to ensure all the latest packages are installed 
    sudo apt update 
    sudo apt upgrade

Enable communication protocols

  1. Launch the Pi configuration tool by running the following command
    sudo raspi-config
  2. Use your keyboard to select Interface Options, and press return.
  3. Enable the relevant protocols to support our hardware. Since you are using a sensor that communicates over the I2C, enable I2C.
  4. Confirm the options to enable I2C interface. And reboot the Pi when you're finished.

Configure Your Machine

Create Your Machine

  1. In the Viam app under the LOCATIONS tab, create a machine by typing in a name and clicking Add machine
  2. Click View setup instructions.
  3. Install viam-server on the Raspberry Pi device that you want to use to communicate with and control your Pomodoro Bot. Select the Linux / Aarch64 platform for the Raspberry Pi, and leave your installation method as viam-agent.
  4. Use the viam-agent to download and install viam-server on your Raspberry Pi. Follow the instructions to run the command provided in the setup instructions from the SSH prompt of your Raspberry Pi.
    The setup page will indicate when the machine is successfully connected.

Add your Raspberry Pi

  1. In the Viam app, find the CONFIGURE tab. It's time to configure your hardware.
  2. Click the + icon in the left-hand menu and select Component.
  3. Select board, and find the pi5 module. This adds the module for working with the Raspberry Pi 5's GPIO pins.
  4. Notice adding this module adds the board hardware component called PI5. The collapsible card on the right corresponds to the part listed in the left sidebar.
  5. Click Save in the top right to save and apply your configuration changes. If any problems occur, check under the LOGS tab to see what might be going wrong.

Integrate Google Calendar

Now let's set up your Pomodoro Bot to work with Google Calendar, so you can stay on top of your schedule without losing focus. Once integrated, your bot will automatically sync with your calendar to manage events and reminders.

Set Up a Google Cloud Project

1. Go to the Google Cloud Console.
2. Create a new project specifically for this integration.

3. Once the project is ready: 

Create a Service Account

  1. In the Google Cloud Console, navigate to IAM & Admin > Service Accounts.
  2. Set up a new service account: 

To transfer this file from your PC to Raspberry Pi, you can use SCP command in the following format 
Using hostname 

#Format: scp service-account-file.json username@hostname.local:/path/on/raspberrypi 
scp pomodorobot-service-account-file.json pi@raspberrypi.local:/home/pi/

Using IP Address 

#Format: scp service-account-file-name.json username@ip-address-of-raspberrypi:/path/on/raspberrypi 
scp pomodorobot-service-account-file.json pi@192.168.1.4:/home/pi/

Share Your Calendar with the Service Account

1. Open Google Calendar.

2. Select the calendar you want to use.

3. In Settings and Sharing, find the Share with specific people section:

Connect Your Calendar to the Pomodoro Bot

1. Open the Viam app and go to the CONFIGURE tab.
2. Add the Calendar module, and provide:

3. Save your changes to complete the setup.

Test the Integration

1. Create a test event in Google Calendar: 

2. Go back to the Viam app and open the Control* tab.

3. Use the given command in the DO COMMAND interface to check for upcoming calendar events. 

{ "get_events": { "max_results": 10 } }  

If everything is working correctly, you should see your test event ("Test Meeting") listed in the results. This confirms that your Pomodoro Bot is successfully linked to your Google Calendar.

Integrate ENS160 Air Quality Sensor

Let's integrate the ENS160 air quality sensor with your Pomodoro Bot to monitor indoor air quality effectively. The ENS160 sensor tracks VOCs (volatile organic compounds), eCO2 (equivalent carbon dioxide), and provides an Air Quality Index (AQI) – vital for maintaining an optimal workspace environment.

Hardware Setup

Power Connections:

I2C Communication: 

Ensure all connections are secure and double-check your wiring to avoid any issues.

Software Integration

  1. Open the Viam app. 
  2. Navigate to the CONFIGURE tab. 
  3. Add a new component for the ENS160 sensor.
  4. Click "Save" and wait for the component to finish setup.
  1. Switch to the Control tab in the Viam app.
  2. Observe the live data feed from the ENS160 sensor, including real-time air quality metrics such as VOC levels, eCO2 values, and AQI.

Integrate TEMT6000 Ambient Light Sensor

Enhance your Pomodoro Bot by integrating the TEMT6000 ambient light sensor, which monitors light levels to help optimize workspace lighting for improved productivity. With this sensor, your bot can detect ambient light intensity and make adjustments as necessary to create a comfortable and efficient working environment.

Hardware Setup

1. Components:

2. Connections:

TEMT6000 to ADS1115: 

ADS1115 to Raspberry Pi: 

Software Integration

  1. Open the Viam application. 
  2. Navigate to the CONFIGURE tab. 
  3. Add the TEMT6000 sensor as a new component, specifying its ADC channel.
  4. Click "Save" and wait for the component to finish setup.
  1. Switch to the Control tab in the Viam app. 
  2. Observe the live data feed from the TEMT6000 sensor.
  3. Adjust the lighting around the sensor and verify that the readings update in real time.

Integrate a 4-Inch HDMI Capacitive Touch Display

Adding a display to your Pomodoro Bot elevates it from a functional productivity tool to an interactive and engaging companion. With a screen, your bot can visually communicate, provide intuitive feedback, and motivate you with friendly reminders or fun animations.

Features

Hardware Connection

  1. Set the touch switch on the back of the screen to "I2C".
  2. Fix the Raspberry Pi to the screen through the copper posts, and pay attention to aligning the position of the ejector pins.
  3. Connect the HDMI port of the Raspberry Pi to the LCD.
  4. Connect USB-C on Display to USB port on Raspberry Pi to enable touch interactions.

Software Setup

  1. Follow the instructions to Setup Raspberry Pi using Pi Imager.
  2. After the setup is completed, insert the SD card into your computer and open the config.txt file in the root directory of the SD card, and add the following code at the end of the file:
    dtparam=i2c_arm=on
    dtoverlay=waveshare-4dpic-3b
    dtoverlay=waveshare-4dpic-4b
    dtoverlay=waveshare-4dpic-5b
    hdmi_force_hotplug=1
    config_hdmi_boost=10
    hdmi_group=2
    hdmi_mode=87
    hdmi_timings=720 0 100 20 100 720 0 20 8 20 0 0 0 60 0 48000000 6
    start_x=0
    gpu_mem=128
  3. Download the 4inch HDMI LCD (C) DTBO file and extract the 3 dtbo files. Copy these 3 files to the overlays directory (/boot/overlays/).
  4. Save the changes to the config.txt file, eject the SD card safely, and insert it into the Raspberry Pi.
  5. Power on the Raspberry Pi and wait for more than ten seconds to display normally

Integrate Button To Pomodoro Bot

To enhance the functionality of your Pomodoro Bot, you can integrate a push button to allow manual control, such as starting or stopping tasks, resetting timers, or triggering specific actions. Here's how to add a push button:

Hardware Setup

Components Needed:

Wiring:

By adding a push button, you can make your Pomodoro Bot more interactive and user-friendly!

3D Design and Fabrication

Aesthetics and Personality

We envisioned the Pomodoro Bot as more than just a functional tool. It needed to be visually appealing and possess a unique personality. To achieve this we used Fusion 360, to craft a 3D model, carefully balancing aesthetics and practicality. This process involved refining every detail to ensure the bot was both charming and functional.

The final result is a compact and modern 3D-printed bot that is not only a productivity powerhouse but also a delightful desk companion designed to bring a smile to your face while helping you stay focused.

3D Printing Process

After finalizing the design, we brought our concept to life through 3D printing. We utilized the Bambu A1 3D printer to:

This 3D printing step was crucial in transforming the digital design into a tangible, high-quality physical product.

Find the STL Files here.

Assembly

Giving Life To Our Pomodoro Bot

1. Power Up the Raspberry Pi

Once the assembly process is complete, power up your Raspberry Pi. You can do this by connecting the power supply to the Raspberry Pi's power jack.

2. Verify Functionality

After powering up, take a moment to verify that everything is functioning as expected. This may involve checking the Raspberry Pi's LED indicators and ensuring the Waveshare display turns on.

3. Download Source Code

The next step is to download the source code for the Pomodoro Bot application on to your Raspberry Pi. You can download the code from the following GitHub repository:

4. Edit the Source Code (main.py)

  1. Open the downloaded source code and navigate to the Code directory. Locate the file named main.py.
  2. Within main.py, you will need to replace the following placeholders with your own values: 

5. Run the Pomodoro Bot Code

  1. Once you've made the necessary edits to main.py, save the changes.
  2. Back in the Configure tab in the Viam app, add a new Process.
  3. Configure the Process by adding relevant details like Executable, Arguments and Working Directory. 
    • Executable: python3 
    • Arguments: main.py (Python script name) 
    • Working Directory: /home/pi/PomodoroBot/Code (Your working directory)
  4. Save and wait for the process to finish setup.

6. See Your Pomodoro Bot Alive!

If everything is configured correctly, the Pomodoro Bot application should launch and your Raspberry Pi will transform into a functional Pomodoro Bot, ready to help you manage your work sessions and boost your productivity.


This tutorial was originally published on Viam codelabs: Build your own Pomodoro bot with Viam.