MP3 speech files for use in clock projects

In recent post I’ve posted about Using Text to Speech online tools to create audio files for Arduino projects and Batch processing files with Audacity. I have a couple of projects that use speech alerts and one of those is a speaking clock. It announces the time at the press of a button, but more helpfully announces the hour, when it is time to get up and when to have morning tea and lunch.

While I don’t think the Arduino code is in a fit state to share I’ve uploaded the audio files to Github for anyone to use in their projects. There are two versions of of the files:

  1. French Celine created with Online Tone Generator. These are the files I am currently using in my clock.
  2. British Amy created with TTSMP3. An alternative set I made to test TTSMP3

I use French Celine in my project. Here are a couple of examples of what they can do when joined:

French Celine

British Amy

I have uploaded the mp3 files to my Github for anyone to freely use. They are available here. This is a list of the files:

000 zero.mp3
001 one.mp3
002 two.mp3
003 three.mp3
004 four.mp3
005 five.mp3
006 six.mp3
007 seven.mp3
008 eight.mp3
009 nine.mp3
010 ten.mp3
011 eleven.mp3
012 twelve.mp3
013 thirteen.mp3
014 fourteen.mp3
015 fifteen.mp3
016 sixteen.mp3
017 seventeen.mp3
018 eighteen.mp3
019 nineteen.mp3
020 twenty.mp3
021 twenty one.mp3
022 twenty two.mp3
023 twenty three.mp3
024 twenty four.mp3
025 twenty five.mp3
026 twenty six.mp3
027 twenty seven.mp3
028 twenty eight.mp3
029 twenty nine.mp3
030 thirty.mp3
031 thirty one.mp3
032 thirty two.mp3
033 thirty three.mp3
034 thirty four.mp3
035 thirty five.mp3
036 thirty six.mp3
037 thirty seven.mp3
038 thirty eight.mp3
039 thirty nine.mp3
040 forty.mp3
041 forty one.mp3
042 forty two.mp3
043 forty three.mp3
044 forty four.mp3
045 forty five.mp3
046 forty six.mp3
047 forty seven.mp3
048 forty eight.mp3
049 forty nine.mp3
050 fifty.mp3
051 fifty one.mp3
052 fifty two.mp3
053 fifty three.mp3
054 fifty four.mp3
055 fifty five.mp3
056 fifty six.mp3
057 fifty seven.mp3
058 fifty eight.mp3
059 fifty nine.mp3
060 sixty.mp3
061 one oclock.mp3
062 two oclock.mp3
063 three oclock.mp3
064 four oclock.mp3
065 five oclock.mp3
066 six oclock.mp3
067 seven oclock.mp3
068 eight oclock.mp3
069 nine oclock.mp3
070 ten oclock.mp3
071 eleven oclock.mp3
072 twelve oclock.mp3
073 noon.mp3
074 twelve noon.mp3
075 midnight.mp3
076 the time is.mp3
077 it is.mp3
078 it is time to wake up.mp3
079 it is morning tea time.mp3
080 it is lunch time.mp3
081 am.mp3
082 pm.mp3
083 I was sleeping.mp3
084 good morning.mp3
085 good day.mp3
086 good afternoon.mp3
087 good evening.mp3
088 at the third stoke.mp3
089 beep beep beep.mp3
090 exactly.mp3
092 its time to do something.mp3
094 or there abouts.mp3
095 precisely.mp3

Batch processing files with Audacity

In my last post Using Text to Speech online tools to create audio files for Arduino projects I had some info about online text to audio sites I have been using to create audio alert files for projects. The files produced by seemed to have a lower audio level than I expected. I found I could run all the files through a batch process in Audacity to normalize them. I spent a lot more time trying to find out how to do it so I’m making this quick post so I have the info for next time.

I was running Audacity 2.1.3 which is now an old version. The terminology and location of the feature changed in 2.3.0. Essentially the pre 2.3 version seems to call it ‘chains’ whereas it became ‘macros’ in 2.3. I’ll include info for both as I made notes for the older versions first.

The relevant info is available on the Audacitiy site.

There are two parts to the process

  1. Create a chain/macro with the processes that will be run during the batch process. This only needs to be set up once.
  2. Select files and run the task.

There are a lot of other changes that can be included. I’ve also added Mono to one as I found some of my files created another way were stereo and others mono. My project only had a single speaker so I converted them all to mono for consistancy.

Pre 2.3 version

In these versions the batch process is referred to as a chain.

To create a chain

  • Go to File
  • Select Edit chains…
  • Add button
  • Set a name, e.g. Normalize to -0.1dB
  • Insert Normalize – Tweak settings if desired. I didn’t
  • Insert ExportMP3 – This is required otherwise the files are not saved
The chain should look something like this

To use the chain

  • Go to File
  • Select Apply chains…
  • Select the chain, in my case ‘Normalize to -0.1dB’
  • Select Apply to files
  • Browse to the file folder and choose files
  • Select Open
  • Converted files will be placed in a folder called cleaned inside the folder of the selected files

Current version

In later versions it is called a macro.

To create a macro

  • Go to Tools
  • Select Macros…
  • New button
  • Set a name, e.g. Normalize
  • Insert Normalize. There is also an option ‘Normalize (Macro_Normalize)’ that I have not tried

  • Insert Export as MP3 – This is required otherwise the files are not saved

To use the macro

  • Go to Tools
  • Select Macros…
  • Select the macro, in my case Normalize
  • Select Files
  • Browse to the file folder and choose files
  • Select Open
  • Converted files will be placed in a folder called macro-output inside the folder of the selected files

Before and after

Here is a before and after shot. The before is the one at the top.

As always if let me know if you find inaccuracies in my info.

Using Text to Speech online tools to create audio files for Arduino projects

I’ve made a couple of projects that play audio alerts using a dfplayer and MP3 files. One in a clock that plays announcements and the other a countdown timer. When I did those, I used to convert text to speech. I liked the voices but it doesn’t have an option to save the audio as an MP3 file. I ended up using Audacity to record the computers audio. It worked but was very tedious. Since then, I’ve been looking for a simpler way.

The important criteria in a text to speech service for me is:

  • Ability to enter text, listen to the converted audio in the browser and then download it as an mp3 file.
  • Sufficient audio quality.
  • Volume level ok.
  • Suitable lead in and end dead time to allow multiple files to be played in sequence with the  result sounding as a smooth sentence. For example these four files together; “The time is”, “eleven”, “thirty two”, “am”.
  • A suitable voice. They don’t all have the same voices. I prefer some more than others.
  • Free or good value.
  • Ability to change speed, pitch and emphasis a bonus.

Here are a few I’ve looked at.

Online Tone Generator (

This is the first one I used. Its:

  • Free.
  • Has a good range of voices; mostly Google, plus a few Microsoft ones I presume are built into my Windows PC. I particularly like Google français.
  • Lots of other audio tools, including; noise generator, sweep generator, DTMF signals.
  • But, no MP3 download.

From Text To Speech (

I briefly looked at this one. It is:

  • Free.
  • Has a 50 000 character limit per file.
  • I’m unable to listen in browser. No play button displays until a file is created and then the player presented appears to use flash and is blocked by my browser. The file can be downloaded and used.
  • MP3 download.
  • Different speed and voices.


This is the one that I am intending to use in my next project. Lots of features, MP3 file output and a fair amount of free usage. It is:

  • Free for 3,000 characters (~375 words) per day.
  • Lots of different voices.
  • Supports speed, pitch and other effects using tags.
  • Multiple voices can be used in the one piece of text by using tags.
  • MP3 file download.

TTSMP3 uses Amazon Polly and comes with quite a few voices and features. Additional effects can be used by using tags in your text. More info about tags is available on this Amazon page.

Here is an example of the voices.

That audio file was created by pasting the text below into the converter. Beware if you do this it will use up most of your daily 3000 word limit.

[speaker:Zeina] Hi, I'm Arabic Zeina
[speaker:Russell] Hi, I'm Russell Australian English Russell
[speaker:Nicole] Hi, I'm Australian English Nicole
[speaker:Camila] Hi, I'm Brazilian Portuguese Camila
[speaker:Ricardo] Hi, I'm Brazilian Portuguese Ricardo
[speaker:Vitória] Hi, I'm Brazilian Portuguese Vitória
[speaker:Emma] Hi, I'm British English Emma
[speaker:Amy] Hi, I'm British English Amy
[speaker:Brian] Hi, I'm British English Brian
[speaker:Chantal] Hi, I'm Canadian French Chantal
[speaker:Enrique] Hi, I'm Castilian Spanish Enrique
[speaker:Lucia] Hi, I'm Castilian Spanish Lucia
[speaker:Conchita] Hi, I'm Castilian Spanish Conchita
[speaker:Zhiyu] Hi, I'm Chinese Mandarin Zhiyu
[speaker:Mads] Hi, I'm Danish Mads
[speaker:Naja] Hi, I'm Danish Naja
[speaker:Ruben] Hi, I'm Dutch Ruben
[speaker:Lotte] Hi, I'm Dutch Lotte
[speaker:Céline] Hi, I'm French Céline
[speaker:Léa] Hi, I'm French Léa
[speaker:Mathieu] Hi, I'm French Mathieu
[speaker:Vicki] Hi, I'm German Vicki
[speaker:Marlene] Hi, I'm German Marlene
[speaker:Hans] Hi, I'm German Hans
[speaker:Karl] Hi, I'm Icelandic Karl
[speaker:Dóra] Hi, I'm Icelandic Dóra
[speaker:Aditi] Hi, I'm Indian English Aditi
[speaker:Raveena] Hi, I'm Indian English Raveena
[speaker:Carla] Hi, I'm Italian Carla
[speaker:Giorgio] Hi, I'm Italian Giorgio
[speaker:Bianca] Hi, I'm Italian Bianca
[speaker:Takumi] Hi, I'm Japanese Takumi
[speaker:Mizuki] Hi, I'm Japanese Mizuki
[speaker:Seoyeon] Hi, I'm Korean Seoyeon
[speaker:Mia] Hi, I'm Mexican Spanish Mia
[speaker:Liv] Hi, I'm Norwegian Liv
[speaker:Ewa] Hi, I'm Polish Ewa
[speaker:Jan] Hi, I'm Polish Jan
[speaker:Maja] Hi, I'm Polish Maja
[speaker:Jacek] Hi, I'm Polish Jacek
[speaker:Inês] Hi, I'm Portuguese Inês
[speaker:Cristiano] Hi, I'm Portuguese Cristiano
[speaker:Carmen] Hi, I'm Romanian Carmen
[speaker:Maxim] Hi, I'm Russian Maxim
[speaker:Tatyana] Hi, I'm Russian Tatyana
[speaker:Astrid] Hi, I'm Swedish Astrid
[speaker:Filiz] Hi, I'm Turkish Filiz
[speaker:Joey] Hi, I'm US English Joey
[speaker:Kimberly] Hi, I'm US English Kimberly
[speaker:Salli] Hi, I'm US English Salli
[speaker:Ivy] Hi, I'm US English Ivy
[speaker:Matthew] Hi, I'm US English Matthew
[speaker:Kendra] Hi, I'm US English Kendra
[speaker:Joanna] Hi, I'm US English Joanna
[speaker:Justin] Hi, I'm US English Justin
[speaker:Miguel] Hi, I'm US Spanish Miguel
[speaker:Lupe] Hi, I'm US Spanish Lupe
[speaker:Penélope] Hi, I'm US Spanish Penélope
[speaker:Gwyneth] Hi, I'm Welsh Gwyneth
[speaker:Geraint] Hi, I'm Welsh English Geraint


Compared with the original audio files that I created by using Audacity to record the PC audio and, had lower volume. I may have had the record level a bit high when I used Audacity so not sure that the ttsmp3 level is too low.

The bit rate is also different, with the Audacity ones higher. That’s probably because I unnecessarily chose a higher bitrate in Audacity. TTSMP3 was 48kbs.

And that affected the file size. The TTSMP3 is much smaller.

Here are a couple of examples for comparison. For each I created four separate files and then joined them together to see how smooth the transition was. The four files were “The time is”, “11”, “32”, “AM”. I had to be a bit creative with the AM for French Celine as it was pronounced as “am”. Voice is Google français. I like this voice. It has added a lot of character to my speaking clock. Voice is French Celine. It was much easier to create and the timing between files is ok, but the voice doesn’t have the same character to the one above in my opinion This is British Amy. This was just for comparison to see how the same text would sound with an English voice.

Do you have other methods? Let me know.

Update 13/4/2021: I have added a post with info about how to increase the audio level in a batch of files Batch processing files with Audacity

Reliably debouncing rotary encoders with Arduino and ESP32

I love those simple cheap rotary encoders as used in the KY-040 modules as a method of getting user input with Arduino and ESP32 projects. The issue of bounce with them is significant and for years I’ve been looking a reliable method of dealing with it. I thought I had it figured out by either using a couple of 100nF capacitors or by using code ignore quick changes but this was not always reliable and sometimes missed legitimate changes when rotating at speed. In forums I read people recommending to use a lookup table, but not me. I persevered with what I knew, at least until my methods didn’t work.

I’ve only recently started using ESP32s. The first time I started using one with an encoder the bouncing was terrible. Turning a single indent resulted in a large number of false increments. I assumed that this was because the ESP32 was so running much faster than the Nanos I’ve been using and triggering on even quicker bounces. I don’t know if that is a possibility, but I now believe that the encoder I was using was extremely noisy. I thought it was time to revisit debouncing. After all a reliable encoder will not necessarily stay reliable forever.

An alternative solution

In some forums I read there was sometimes a comment saying there was a more reliable way. That is to use a table to compare the previous state with the new state and using a lookup table to ignore those changes that are not valid for a legitimate change. I decided to investigate. I came across this page Rotary Encoder : How to use the Keys KY-040 Encoder on the Arduino. I recommend reading it if you want to learn more about it.

I tried the Code For Improved Table Decode and was really surprised just how well it worked without any hardware filtering. There were only two things missing that I wanted. Firstly, it uses polling and I wanted to use interrupts and secondly it has a copyright notice and I respect that. However, I want to use code that I can include in projects that I can place online to share with others. It’s still a great read and I am grateful for Best Microcontroller Projects for providing the resource.

Next I came across code by Oleg Mazurov’s pages Reading rotary encoder on Arduino and Rotary encoder interrupt service routine for AVR micros

I also found these to be very helpful. I found some others had similar code that I believe is based on the code by Oleg. Oleg’s code worked well too, but I couldn’t get it to work on the ESP32 without a couple of changes. It uses port read to read the value of the encoder pins, which I expect is a very efficient thing to do, but didn’t work with the ESP32. Also, the interrupt version uses PROGMEM that also appears to be incompatible with the ESP32, or at least as it is done in the example.

However, you can stop here and use Oleg’s code if you are using a Nano or Uno, or use the version. To get Oleg’s version working on the ESP32 I made these changes.

Port read

Olig’s code reads the ports directly without using Arduino’s digitalRead. I had a go at using digitalRead, which I hoped would allow it to work on the ESP32 and perhaps other microcontrollers. To do that I:

Removed this define


And changed this:

old_AB |= ( ENC_PORT & 0x03 ); // Add current state 

to this to use digitalRead:

if (digitalRead(ENC_A)) old_AB |= 0x02; // Add current state of pin A
if (digitalRead(ENC_B)) old_AB |= 0x01; // Add current state of pin B


I’m not sure why program memory is used instead of SRAM, only that I couldn’t get it to work on the ESP32 so I removed the reference to it making it the same as Oleg’s polling version. So from this:

static const int8_t enc_states [] PROGMEM = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};

To this:

static const int8_t enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};

Changed versions

I confess to not fully understanding the code, so I can’t be sure that there are not issues with it. I have made some other tweaks too, but those are mainly just the addition of comments. These are the two versions that I am currently using.

Polling version

/* Based on Oleg Mazurov's code for Reading rotary encoder on Arduino, here and here

   This example does not use the port read method. Tested with Nano and ESP32

   Encoder | ESP32 |  Nano
     A     |  D5   |  Nano D2
     B     |  D21  |  Nano D3
     GND   |  GND  |  GND

// Define rotary encoder pins
#define ENC_A 21
#define ENC_B 5

volatile int counter = 0;

void setup() {

  // Set encoder pins

  // Start the serial monitor to show output
  Serial.begin(115200); // Change to 9600 for Nano, 115200 for ESP32
  delay(500);           // Wait for serial to start  

void loop() {
  static int lastCounter = 0;

  // If count has changed print the new value to serial
  if(counter != lastCounter){
    lastCounter = counter;

void read_encoder() {
  // Encoder routine. Updates counter if they are valid
  // and if rotated a full indent
  static uint8_t old_AB = 3;  // Lookup table index
  static int8_t encval = 0;   // Encoder value  
  static const int8_t enc_states[]  = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0}; // Lookup table

  old_AB <<=2;  // Remember previous state  

  if (digitalRead(ENC_A)) old_AB |= 0x02; // Add current state of pin A
  if (digitalRead(ENC_B)) old_AB |= 0x01; // Add current state of pin B
  encval += enc_states[( old_AB & 0x0f )];

  // Update counter if encoder has rotated a full indent, that is at least 4 steps
  if( encval > 3 ) {        // Four steps forward
    counter++;              // Increase counter
    encval = 0;
  else if( encval < -3 ) {  // Four steps backwards
   counter--;               // Decrease counter
   encval = 0;

Interrupt version

/* Based on Oleg Mazurov's code for rotary encoder interrupt service routines for AVR micros
   and using interrupts

   This example does not use the port read method. Tested with Nano and ESP32
   both encoder A and B pins must be connected to interrupt enabled pins

   Encoder | ESP32 |  Nano
     A     |  D5   |  Nano D2
     B     |  D21  |  Nano D3
     GND   |  GND  |  GND

// Define rotary encoder pins
#define ENC_A 21
#define ENC_B 5

volatile int counter = 0;

void setup() {

  // Set encoder pins and attach interrupts
  attachInterrupt(digitalPinToInterrupt(ENC_A), read_encoder, CHANGE);
  attachInterrupt(digitalPinToInterrupt(ENC_B), read_encoder, CHANGE);

  // Start the serial monitor to show output
  Serial.begin(115200); // Change to 9600 for Nano, 115200 for ESP32
  delay(500);           // Wait for serial to start  

void loop() {
  static int lastCounter = 0;

  // If count has changed print the new value to serial
  if(counter != lastCounter){
    lastCounter = counter;

void read_encoder() {
  // Encoder interrupt routine for both pins. Updates counter
  // if they are valid and have rotated a full indent
  static uint8_t old_AB = 3;  // Lookup table index
  static int8_t encval = 0;   // Encoder value  
  static const int8_t enc_states[]  = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0}; // Lookup table

  old_AB <<=2;  // Remember previous state

  if (digitalRead(ENC_A)) old_AB |= 0x02; // Add current state of pin A
  if (digitalRead(ENC_B)) old_AB |= 0x01; // Add current state of pin B
  encval += enc_states[( old_AB & 0x0f )];

  // Update counter if encoder has rotated a full indent, that is at least 4 steps
  if( encval > 3 ) {        // Four steps forward
    counter++;              // Increase counter
    encval = 0;
  else if( encval < -3 ) {  // Four steps backwards
   counter--;               // Decrease counter
   encval = 0;

Downsides of this method

While it is working well in tests, I have not used it in a permanent project yet. The only downside I can find so far is that if using interrupts instead of polling it requires two interrupt pins. Other methods I’ve used only need one. I don’t expect this will be an issue of the ESP32 but it may be with the Nano.

Finally, a decent quality prototype breadboard for a reasonable cost

Getting decent quality prototype breadboards for a reasonable cost is something that has eluded me for years. I think I have finally found a reliable source. Those advertised on eBay or at least the cheaper ones seem that I have previously purchased too often have poor metal connectors inside. It can be difficult to insert pins in and if the pin is thick the contacts don’t completely spring back. I have not found a way to determine which of these are ok as just looking at the breadboard doesn’t seem to be reliable method.

The new ones I’ve got are BB830 by BusBoard. I found out about them by Ben Eaters in this video. Skip to about 1:18 if you want to hear him talk about them.

Ben sells them and has more information about them on his breadboard page, however I must confess I got them from Mouser as I am outside of the US and was preparing an order with Mouser anyway. Here is a shot of a bread board fastened to a cheese board.

The breadboard on the bottom is the new one. Those little ones at the top are just old ones that have been cut.

I’m very happy with them. They cost more than those I’ve previously purchased on eBay but if they don’t work then any price is too much. Also, I want to support producers of decent quality items. So far, I’m very happy with the BusBoard ones.

IR remote control mute button

I recently built a simple one button Arduino based IR remote control to mute our TV and Computer amp. I am quite happy with the results. The idea to use half a stress ball for the mute button I thought was inspired. The timber case built using with the aid of some jigs I made for my old saw bench came out better than expected.

To save power the voltage regulator and the current limiting resistor to the power LED were removed. The other onboard LED was left connected and ended up using it to flash with the IR LED just for diagnostics. As the case doesn’t have a bottom it displays a nice red flash in use. I decided to be a bit naughty and drive the IR LED without a limiting resistor through a transistor to drive it hard and get a bit more range. I thought the quick pulses would mean the LED should probably survive, but I ended up adding the resistor back in.

As is often the case, at least with my projects much time was spent trying to determine what was causing some unexpected behaviour. While it often worked correctly. Sometimes pressing the button didn’t seem to do anything. I used a number of different batteries I had laying around. I eventually discovered the IR LED was staying on, this was with some old batteries. My current assumption is that when the voltage drops too far the processor stops and the LED pin either goes high or it is stopping when it is high. As I don’t have a proper solution, I added the resistor back in series with the IR LED to at least reduce the current flow if it does happen again. With the resistor out I didn’t find the range was improved very much anyway.

The code

The code is fairly simple and is really designed to be able to support multi button remotes. After completing it I read that the TV begone just uses the reset button to wake up the processor, it then sends out it’s codes and then goes back to sleep. That’s an interesting way to do it that never occurred to me. I went with the traditional method of using a button and interrupt.

I mentioned earlier that it was designed to mute both a TV and a computer amp. These are in different rooms. The button simply sends out the mute pulses for one after the other. It could mute both at the same time, but due to location of the amp and TV that doesn’t happen in practice.

The code really needs further work to resolve the case where the LED stays on, but if you are interested you can check it out on my Github garrysblog/IR-Remote-Mute-Button

The circuit

Here is the circuit diagram. I used a PN2222A transistor, but that was because I have a lot of those. I presume it would work with a lot of other types. Other than that it is fairly simple

The case and button

The case was made mostly from a pine timber lining board. Like many of the reasons for my choices I did it this way as another project was to create some jigs to create clean precise 45 degree cuts on an old table saw. I don’t think I could have made it this way without the jigs. While most of the joints were glued using PVA glue the piece that holds in the switch and spring was glued in using hot melt glue to allow a about the right amount of time for jiggling before it hardened.

I needed a couple of thin discs to mount to the top and bottom of the ball that holds the ball. I tried some ply first but my results weren’t great. I had an old circuit board from a project that I abandoned years ago and after scraping off the old tracks found that it works well. See it’s worth hanging on to some things for 20+ years and now it is bringing me joy 🙂

Final results

It has been in use for a couple of months now. It’s still going well but I’m not sure how long the batteries will last. I still don’t haven’t fixed the issue with the LED, but other projects are calling. Maybe one day I’ll come back to it. I hope it gives you some inspiration.

Timber breadboards and serving boards with Arduino

Originally, according to Wikipedia and other articles I’ve read wooden kitchen breadboards were used for electronics, which is where the term started. I’ve started using them too. I had a couple of accidents where they magic smoke was released from a couple of Arduino boards when an Arduino module was bumped and moved over a screwdriver in one case and a piece of metal in another. That smoke can escape pretty quickly. I also got tired of connections coming loose when moving the project between sessions. I thought I would share some of my results as they may help someone.

I started by trying to make my own boards, but found I didn’t really have any suitable timber, but I may come back and look at options later.

I found our local Kmart had suitable items. The first is a beautiful acacia serving board. Originally it had a timber handle. I cut that off as it made it a bit long and awkward. It’s not the easiest timber to cut, but I do have some good tools for that and the results were ok. For this one I attached a 20×4 LCD display, battery holder, rotary encoder and joystick. I tried to include items that wouldn’t plug into the solderless breadboard, but adding all these may have been a mistake. I doubt I will use the joystick, but that’s ok. The dark timber looks great. What I hadn’t expected was how much more pleasing it made working on a project when everything is held together on such a beautiful piece of timber.

Acacia serving board with handle removed

Kmart no longer have the exact same board but they did get these Anko bamboo serving boards. They came in a pack of 3 boards for $6, so the price was right. They are not as beautiful as the first board and they are smaller, but they are made of bamboo which I presume is more environmentally friendly and their size and thickness make them ideal for smaller projects. I made up several with solderless breadboards attached. This one includes a 16×2 LCD display.

Smaller bamboo serving board

I like these LCD displays a lot so I included one on this board. I bought the I2C board and LCDs separately as I didn’t want them pre-soldered together. This allowed me to solder them together with greater distance between the LCD and backpack module. I could then carefully bend the pins so that the LCD sat at a useful angle and the I2 C board was easily accessible for adjusting the contrast and reading the pin connections.

LCD is held down with two screws. The plastic tube spacers are used to get the height at the front correct.

To mount modules to the board I’ve found a couple of different sized plastic tubing. It’s easy to cut to different lengths. There are probably lots of tools to cut it with but I usually use a pair of heavy duty wire strippers, not because it requires a lot of force, but as it has just the right sized cutter that makes it easy to do a neat cut. The tubing can squash a bit so if their lengths are not identical it doesn’t really matter.

Plastic tube and wire strippers

Overall, this has made tinkering much more enjoyable. I’m still looking out for improvements.

Using the DS3231 Real Time Clock alarm with the Adafruit RTClib library

I love the DS3231 RTC module and have used it in a couple of projects without a library using code based on Ralph Bacon’s example. It worked well, but I wanted to use the alarm and working out how to do that was a step too far for me. There doesn’t seem to be a shortage of libraries and I found it challenging to choose one.

I tried the Adafruit RTClib library which I liked but the documentation I looked at didn’t mention support for the alarm, but I found this closed issue in the libraries Github repository Add support for Alarm on DS3231 #94, so it seems it does have support for it. After many hours of twiddling and tweaking here are some notes and example from my experiments of what I believe is correct info. I’m not an expert so let me know if you believe any of it is incorrect or can be improved.

Setting the alarm

This is what I had most trouble with. There are two alarms. The commands to set the alarms time are:
setAlarm1(DateTime, alarm_mode)
setAlarm2(DateTime, alarm_mode)

The alarms can be set to a specific time using DateTime or to a set amount from the current time using TimeSpan. Some formats I used are:

For a specific time use DateTime:
DateTime(Year, Month, Day, Hour, Minute, Second)

For a number of seconds, minutes, hours, etc from the current time:
now + TimeSpan:now + TimeSpan(days, hours, minutes, seconds)

Using unixtime:
now.unixtime() + seconds

The second part of setAlarm is alarm_mode. This sets what needs to match for the alarm to trigger. The modes are:

Alarm modes for alarm 1
DS3231_A1_PerSecond     Once per second
DS3231_A1_Second        When seconds match
DS3231_A1_Minute        When minutes and seconds match
DS3231_A1_Hour          When hours, minutes, and seconds match
DS3231_A1_Date          When date, hours, minutes, and seconds match (day of month)
DS3231_A1_Day           When day, hours, minutes, and seconds match (day of week)

Alarm modes for alarm 2
DS3231_A2_PerMinute     Once per minute (00 seconds of every minute)
DS3231_A2_Minute        When minutes and seconds match
DS3231_A2_Hour          When hours, minutes, and seconds match
DS3231_A2_Date          When date, hours, minutes, and seconds
DS3231_A2_Day           When day, hours, minutes, and seconds match

Alarm 2 is slightly different in that it can’t be set to trigger on anything smaller other than 00 seconds, that is triggering on the minute is the smallest amount.

The trick for me was working out what how the relationship between time and mode. If a suitable mode is not chosen it can (and did) result in unexpected results. For example setting the time for 7:00am the next day, but choosing DS3231_A1_Minute will result in the alarm triggering on the next hour after setting as only minutes and seconds are being used in the mode. Hours and days are ignored.


Set to an explicit time

setAlarm1(DateTime(2020, 6, 25, 15, 34, 0), DS3231_A1_Hour)

The alarm will trigger when seconds, minutes and hours match, resulting in triggering once per day, every day at (15:34:00). The date, month and year are all ignored.

Using TimeSpan or unixtime to set to an amount from the current time

The current time needs to be called before setting the remaining examples as it is needed to calculate the end time. These examples set the alarm to 10 seconds from the current time.

setAlarm1(now + TimeSpan(0, 0, 0, 10), DS3231_A1_Second)
setAlarm1(now.unixtime() + 10, DS3231_A1_Second)

Monitoring the alarm

So now it can be set, how do we know it has activated? There seems to be two ways to do this.

Using alarmFired

alarmFired() will return true if the alarm is firing and will continue to do so for at least some minutes(?) unless it is cleared. However, while the alarm can be cleared, it doesn’t appear that it can be disabled, so it will fire again when the alarm setting criteria is met again. So that needs to be considered in code. Also, I could only see how to do this by polling alarmFired, which if true looks like this method rules it out for use with sleep modes that I want to use.

Using the SQW pin

This SQW pin can be used to output square waves. It can also be used by the alarm. Its output goes low when the alarm is triggered. This opens up the possibility of using it for use with an interrupt so can be used to wake an Arduino from sleep.


My Github repository has a few examples:

Setting an alarm and polling the SQW pin – DS3231-RTClib-Adafruit-Alarm-Poll-SQW.ino

Setting an alarm and polling using alarmFired – DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired.ino

Sending the Arduino to sleep and waking it using the alarm and SQW pin – DS3231-_RTClib-Adafruit-Alarm-Sleep.ino

I hope this is useful and doesn’t have too much incorrect info. Let me know your feedback.

A deceptively simple but not very secure security key

I recently recalled an interesting security key for a building car park at a block of units we stayed at a few years ago. It was a small block of units with maybe 10 – 20 units in the whole complex, probably built in the 1970s. Underneath was a carpark with a roller door to prevent unauthorised access. A small box stood near the entrance with a receptacle for the key.
In other places we have visited we were usually given a remote control to gain access or sometimes a card to insert. This place had a 6.5mm audio plug attached to a key ring to insert in a socket near the door.

The key

I found it particularly curious as the plug only had two connections, that is it was a mono plug. I wondered how they had implemented security with it. I unscrewed it to reveal a deceptively simple circuit… a wire.

With cover removed and circuit revealed

I have to give the creators full marks for simplicity, but not so many for security.

Original Zork source code available

One of the first computer games I played was Zork. It was back in 1981 and on a Dec 20 mainframe. I have a lot of happy memories of Zork so I was interested when Hackaday posted that MIT has released the original source code on Github.

It wasn’t the puzzles that interested me back in 1981. It was the whole concept that a world could be created that the player interacted with all based on text and running on a computer. For me playing the game was more about the features that developers had included, the humour and what responses our random inputs gave.

A couple of friends and I all spent lots of time trying to write our own text adventure games, but none were really completed. We didn’t have our own computers and the trip to the mainframe was a long way for a school students without transport.

I still have some printouts from that time.

Printout of Zork welcome text

While I don’t understand the language that Zork was written in it is interesting to look at the files as they have lots of easy to read text showing descriptions and interactions. Some look familiar but others for things we never thought of trying.

I only vaguely remember this here which appears to be on the matches

You too can make BIG MONEY in the exciting field of
                 PAPER SHUFFLING!
Mr. TAA of Muddle, Mass. says: \"Before I took
this course I used to be a lowly bit twiddler.
Now with what I learned at MIT Tech I feel really
important and can obfuscate and confuse with the best.\"
Mr. MARC had this to say: \"Ten short days ago all I could
look forward to was a dead-end job as a doctor. Now
I have a promising future and make really big Zorkmids.\"

I don’t recall ever lighting the leaves, presumably the ones at the clearing, but it looks like it was an option.

"The leaves burn and the neighbors start to complain."


"The sight of someone carrying a pile of burning leaves so offends
the neighbors that they come over and put you out."

I only remember moving them.

Another image of a printout including the text 'MOVE LEAVES'

If you ever played the game, the code is worth a look. Remember, stay safe, keep your lamp on and don’t get eaten by a grue .

Text including, 'It is pitch black. You are likely to be eaten by a grue'