Fighting Germs

Enter Your Project for a Chance to Win a Thermal Imaging Camera, Germicidal UV Lamp, and a Shopping Cart with Matching Charity Donation!

Submit an EntrySubmit an Entry  Back to homepage
Project14 Home
Monthly Themes
Monthly Theme Poll


Although not directly related to fighting germs or Covid-19 this project is about enhancing well being. During the lockdown we were allowed one outside period of exercise each day. I decided that I would have mine early in the morning and go for a walk before breakfast. Over the duration of the lockdown we have moved from late winter, through spring and almost into summer so the temperature has varied from below 0 C to over 15 C at my preferred walking time of 6.30 am. I prefer to walk while it is cooler so if it is warmer I get up later. As I am retired I no longer pay much attention to the actual time so I go to bed mostly when I feel like it and I want to get about 6 -7 hours sleep. My wife does not share my interest in getting up early so I have to be quiet.


So I decided that what I wanted was a very quiet alarm clock that I could easily activate that would time for an internal of about 6 1/2 hours. I didn't want to worry about setting a specific time for the alarm each night, I just wanted a simple button push to start it. Additionally, if the temperature was warmer it would extend the timing period slightly. I decided that I wanted at least six hours of sleep no matter what time I went to bed. Then if it was colder I would get up earlier (I like the colder mornings) and up to 30 minutes later if warmer. By measuring the temperature and converting to additional minutes (20 C would equate to 20 extra minutes in bed) I would achieve a weather related interval time. Technically this is not an alarm clock as it does not measure the actual time but I just wanted to call it an alarm clock, so I did. I remembered that when I was much younger and still going to school that I had a mechanical wind up alarm clock, with a very loud alarm. I noticed that just before the loud alarm would go off at the selected time, that it would make a quiet 'click' and if you were quick enough you could shoot your hand out of bed and turn off the alarm. I also realised that if you get up at the same time on a regular basis that your body starts to wake up before the alarm goes off and I was almost awake when the clock went 'click'. So this almost awake alarm clock is a homage to that early mechanical alarm clock. It makes a quiet 'tick' which you will hear when you are almost awake. This avoids waking up my wife but also has the added benefit that if I am more deeply asleep that it will not wake me up either, as if I'm that tired I would rather stay in bed asleep. I can always go for a walk a bit later.


I decided that I wanted a big button that I could easily find in the dark to start the timing interval. As I didn't have one I designed one using TinkerCAD and printed it with my 3D printer. It consists of three parts, the base holder which will contain the Nano, a lid to hold the switch, and a spring mounted dome to activate the switch. I couldn't find any suitable springs to I decided to use the spring effect in the small push button switch I had to create that effect instead. I was only using one small push button so needed three balancing screws to hold the dome part level at exactly the correct height above the button switch. The movement of the push button is less than 1 mm so the spacing and levelling is very important.


This is the base part with a slot at the bottom that is exactly the same size as a Nano and which will hold it securely with an interference fit. There is a hold in the side for the USB cable. The holes in the bottom were originally just to save filament but in the end I had to use them to put wires to external components. I originally wanted to get all the components inside this base but I made it too small so had to run external wires to some components.



Below is the lid which is an interference fit onto the top of the base and just contains a fitting for the switch and three holes for the levelling screws.



The third part is the dome that rests on top of the button and is levelled by the three screws. You cannot see very clearly but the dome has three pillars inside that the levelling screws fit into.



I was very pleased with the operation of this dome - button combination as I am not a mechanical engineer as it seems to do the job required quite well.


The base showing the Nano installed and the wiring is shown below. I had planned to avoid messy wires and fit them all inside the base, but I didn't make the base large enough so that didn't happen. Ah well, maybe next time.


The Button


The dome showing the button and three levelling screws is shown below. It is not that clear but you can just about see everything important.


The Dome (Side View)


In order to be able to measure the temperature a separate circuit is required that will be placed outside, well away from the alarm part. The circuit for this is shown below and consists of the Nano, a BMP180 pressure and temperature sensor and an eRIC 4 radio transceiver module ( ). I didn't have time to 3D print a case for this module.


The Temperature and Pressure Circuit Diagram


I originally wanted to use both the temperature and the pressure measurements to alter the additional time period as low pressures typically mean it is raining or generally not very nice, but time ran out before I was able to incorporate that measurement. It would have been good to also measure light levels and rain but I didn't have a sensor for those parameters. Obviously I could have made a connection to the internet and scrapped all these values from web pages but I wanted to use the eRIC 4 radio transceivers as well as the BMP180 sensor module because I had them both.


The circuit diagram for the timer/alarm unit which is fitted into the round button 3D printed part is shown below. This consists of just a Nano, a simple push-to-make switch to start the timing, a small sounder and the other eRIC 4 radio transceiver.


The Alarm Unit


Two programmes are required as there are two separate Nanos. The first Nano containing the temperature sensor is based on the library (Sparkfun) for the BMP180 example amended slightly to only measure temperature. The temperature will usually be in the range 0 C to 34 C and this can be conveniently counted as the additional minutes, so 15 C would mean 15 minutes on top of the six hour time. 20 C would mean 20 extra minutes and so on. If any temperatures were less than 0 C they were converted to 0 C and anything above 34 C was also limited to 34 C. Rather than try and implement a complicated serial data transfer protocol in Arduino I decided to just use single characters to represent the temperatures, increasing in steps of 2 C (just to simplify the programming) and a switch statement was used for this. With a constant transmission period of approximately 5 seconds.


if (T < 0) T = 0; // Negative temperatures set to 0
T = T/2; // Scale the temperature to the letter range.
if (T > divisions) T = 16;

temperature = T;
// Convert temperature to letter code
switch (temperature)
    case 0 :  value = 'a'; break;
    case 1 :  value = 'b'; break;
    case 2 :  value = 'c'; break;
    case 3 :  value = 'd'; break;   
    case 4 :  value = 'e'; break;
    case 5 :  value = 'f'; break;   
    case 6 :  value = 'g'; break;
    case 7 :  value = 'h'; break;
    case 8 :  value = 'i'; break;
    case 9 :  value = 'j'; break;
    case 10 : value = 'k'; break;
    case 11 : value = 'l'; break;   
    case 12 : value = 'm'; break;
    case 13 : value = 'n'; break;   
    case 14 : value = 'o'; break;
    case 15 : value = 'p'; break;
    case 16 : value = 'q'; break;
    default : value = 'i';  // Half way            
  } /* switch */


The programme for the alarm part is a little bit more complicated. First of all has to identify when the button is pressed which is simply implemented as a while loop that waits until the switch input changes to low, indicating the button has been pressed. There is no need for debouncing or any clever stuff. Then, once pressed, the timer is started and nothing can stop it.


while(digitalRead(button) > 0) // Start timing when button is pressed



  } /* while */

// Visual confirmation then audio confirmation

digitalWrite(LED_BUILTIN, HIGH);


digitalWrite(LED_BUILTIN, LOW);

sounder(100, 500);


The delay is just implemented with a series of nested for loops which first implement a delay of 6 hours and then use the letter code received from the temperature sensor to add up to 34 additional minutes. I've left in all the debug statements and changes to make the timer faster as I just do not have the time to take them all out and make sure it still works. The temperature sensor transmits a new temperature letter code approximately every 5 seconds and the alarm just starts to listen on the radio for whatever letter is transmitted at that time. This avoids all the handshaking needed for bi-directional communication over the radio transceiver link, again , in order to save time in development. It all seems to work.


for (hindex = 0; hindex < hours; hindex++)
    for (mindex = 0; mindex < minsinhour; mindex++)
        Serial.print(hindex); Serial.print(" ");
//        delay(30000);
//        delay(30000);
        sounder(100, 500);
      } /* for */
sounder(100, 500); 
while (Serial.available() < 1)
  } /* while */   
extra_minutes =;
Serial.print(" ");
switch (extra_minutes)
    case 'a' : extra_min = 0; break;
    case 'b' : extra_min = 2; break;
    case 'c' : extra_min = 4; break;
    case 'd' : extra_min = 6; break;   
    case 'e' : extra_min = 8; break;
    case 'f' : extra_min = 10; break;   
    case 'g' : extra_min = 12; break;
    case 'h' : extra_min = 14; break;
    case 'i' : extra_min = 16; break;
    case 'j' : extra_min = 18; break;
    case 'k' : extra_min = 20; break;
    case 'l' : extra_min = 22; break;   
    case 'm' : extra_min = 24; break;
    case 'n' : extra_min = 26; break;   
    case 'o' : extra_min = 28; break;
    case 'p' : extra_min = 30; break;
    case 'q' : extra_min = 32; break;
    default  : extra_min = 15;             
  } /* switch */

// Additional minutes delay
      for (mindex = 0; mindex < extra_min; mindex++)
//        delay(30000);
//        delay(30000);
      } /* for */
sounder(100, 500);
sounder(100, 500);     


Below is a video of the whole system working, in prototype mode where time passes very quickly. One of the problems I had with testing was that in real-time everything took a very long time to complete, about 6 1/2 hours. So I amended the timing so that it all happened in a few seconds. I used the sounder to help me with the debugging.



Overall, I would say that the system operates pretty much as required. It does need a bit of tidying up to make it look better and to ensure the programmes both work properly. Additionally, I have not considered how a real system would be powered. It should be battery powered but this design is relatively power hungry due to the use of Nanos and the eRIC radio transceivers. By changing to another device such as the ATiny85 and using low power modes, plus either using the eRIC in low power mode or LoRa or some other low ppower radio system then a system powered by LiPo batteries would be possible.


I've just made it by completing this Blog before midnight (it's 11.41pm) on 15th May'20, so now I'm off for a cup of tea, a bit of telly and then a long sleep.