Pomodoro timer with ToF sensor in CircuitPython


Yesterday I started working on a fun application using a time of flight sensor.

It looks as if it's going to solve a problem I've had for years.

Pomodoro Technique Like many of my friends I use Pomodoro time management when I'm writing or coding.

The Pomodoro technique uses a timer to you to get up and take a five minute break after 25 minutes at the keyboard. This helps you focus during the 25 minutes of work and the break keeps you healthy and fresh.

The original Italian creator used a kitchen timer shaped like a tomato - hence the name.

I don't have a suitable kitchen timer so I use a web browser to access http://e.ggtimer.com/pomodoro.

That works well if I remember to start the timer whenever I sit down to write or code, and to restart it if I am interrupted. Often I forget, and that's annoying.

A while ago I came up with the idea of automating the Pomodoro.

My first idea used a pressure sensitive cushion on my study chair. I had some fun with this approach but it never worked well. For the last year the project has been sitting in my too hard box waiting for inspiration.

Recently Richard Kirby started experimenting with an inexpensive VL53L0X Time of Flight sensor which measures distance quickly and accurately. Richard runs the Raspberry Pint MeetUp in London, and you can see his project (and many others) on the MeetUp's Facebook page.

I thought I'd try and see if I could detect my presence at my keyboard using the sensor.

My Adafruit sensor arrived a few days ago and I wired it up to an Adafruit Feather m0 Express I had in my parts box. I used the VL53L0X demonstration code in the Adafruit tutorial and it worked well.

I've been writing the CircuitPython software using Nicholas Tollervey's Mu editor. This supports Adafruit boards as well as the micro bit and it's very easy to install on Windows, Linux and OS/X.

Things went well once I had sorted out some minor snags.

My Feather had been sitting in a box since last summer, so the copy of CircuitPython on the board was very out of date. I followed the instructions on the Adafruit website and updated it in a matter of minutes, along with the library bundle. After the update I tried the VL53L0X demonstration code in the Adafruit tutorial.

The Adafruit tutorial suggests that you run the code line by line in the Python REPL. I like that approach: you get immediate feedback. Things went well once I had sorted out some minor snags. These wilonly affect you if you are using Linux.

1. I had not added myself to the dialout group, which you must be in to access the serial port. I ran the necessary command

sudo adduser $USER dialout

but then hit another snag.

2. The REPL showed an AT command!

The Adafruit website explained that there's a piece of software called modem manager which is installed by default in many Linux distros. When you use serial communications it assumes that you're going to be communicating with a modem so it automatically issues an AT modem command.

The last time I used a modem was in the 1990s, so I purged the software from my installation.

After that the REPL worked perfectly and I got the distance sensor running in a matter of minutes.

I've now modified the example code to use the Feather's 3 colour LED to show the distance to the nearest obstacle. Here's a video.



Next I need to add the logic to control the pomodoro timing and to add a buzzer so that the application can alert me when my 5 minute break is up.

I will post here when I have made some progress.

By a happy coincidence I got an email from Mark Barto just as I got the sensor working.

Marc is re-running his annual Digital Making Showcase at the London Communications Centre on the 16th of March. He wanted to know if I had something to show. I'll be taking along the pomodoro application.

I thoroughly enjoyed last year's event. There were lots of interesting things to see and lots of keen makers, young and old.

I'll post details of the meeting once they are published, but in the meantime Marc is on the look-out for more projects to showcase.

If you have a project that you could show, do get in touch with Marc. You can tell him your project details here.

Comments

Popular posts from this blog

Controlling a Raspberry Pi Pico remotely using PySerial

Five steps to connect Jetson Nano and Arduino

Raspberry Pi Pico project 2 - MCP3008