Software apps and online services
Hand tools and fabrication machines
Behold, the rebirth of ThunderBell, risen from the ashes like the hope of humanity, to stride forward and carve the new path of economic prosperity and mental health, all through the medium of flow-charts.
My advice is to read the whole article first as it's more of rambing story than instruction manual, flicking through the images as they come up (often multiple so use left and right arrows), then the images attached at the end (schematics etc) .
At this point go and have a play with NodeRED on your own Raspberry Pi and try to trigger a GPIO pin first (attach an LED with 330ohm resistor) then test each nodered module (chromecast, google calendar) and finally you'll be ready to recreate all my NodeRED workflows. - As always take advice with a large pinch of salt
As summer unfolds we are blessed with long days and vitamin D, generally charging us up and increasing energy-levels and positivity. This directly affects our economic output which is where this product strikes the problem at its heart.
You may have noticed we are all now going to struggle to bring about economic recovery after the pandemic, and in six months time when the sun is at it's lowest we'll be lucky to see 30 minutes of daylight (assuming you still have to goto a poorly lit office like most of us). This directly leads to depression, less productivity, reduced mental and physical well-being, increased lethargy and stunted economic output, all due to lack of sunlight! We all know how much difference putting a smile on your face can make...
That's where SAD lights come in, they increase your vitamin D production and have been shown to reduce fatigue and depression associated with lack of sunlight. Combined with an unstoppable alarm clock system, people will never struggle to get out of bed again. I personally have really found my wakeup time drifting in this purgatory-like lock-down phase of the pandemic, so this will get me back on an even keel.
Now anyone knows that a good alarm clock is worth it's weight in gold, so along time ago I bought the best there was, the Acctim ThunderBell!
Sadly years later it died, possibly due to frequent bashing, but I'm not an electrical doctor so let's move on, either way the mechanism was salvaged for future use and is the real star of the show (along with NodeRed)!Plan / Notebook Sketches
So the basic plan is to use a servo to capacitively activate the 4 brightness levels of the touch-activated SAD light to gently simulate sunrise (5mins each), and then add in birdsong on the chromecast, and finally if I am still unresponsive (+5mins) then the thunderbell gets rung.
There may well be a need for a final final alarm / text-to-speech via the chromecast again as the thunderbell is powered separately and includes a big red silence button (for my housemate). I imagine the sound of my own voice shouting at me through the chromecast (attached to my bedroom stereo) would be quite effective as a final wakeup attempt, certainly more than the google TTS voice. I have thought about positive affirmations in an answer-repeat game, but the complexity outweighed the benefit for the first draft.
Now to set the alarm I've been investigating using a dedicated google calendar via node-red, and that seems successful enough. So it will check at least every hour for the next upcoming event and then trigger the wakeup sequence accordingly by receiving an active event trigger.
The final piece worthy of mention is the UPS (uninterruptible power supply). The idea is that if the lamp gets unplugged or power fails then the battery powered Pi and ThunderBell will still continue to function for at least one day (and if the chromecast had power it would too), thereby saving humanity one workers job at a time.Action
Ever heard that phrase, "Here's one I made earlier..."? It was made famous in the UK by Blue Peter, a childhood tv program, where they would "make a project on live tv" and part way through they would bring out a model 3/4 finished and say "now here's one I made earlier" and do the finishing touches, thereby skipping the repetitive time-consuming/boring bits. I also love how they avoided commercial names and used creative descriptions, like Mars© Bar as a chocolate caramel nougat bar, and sticky-tape rather than the well known sellotape.
Well to cut a long story short, I setup the Pi for SSH (add file on sdcard) and I2C (use raspi-config and install i2c-tools and run "i2cdetect 1" to verify the attached hardware) then I tested each piece individually in node-red, by following the examples on each module page, with the circuitry breadboarded and loosely clipped together. My Raspberry Pi Zero W and Chromecast have static IP addresses set on my router to make it easier to speak to each. I'm using a 12v to 5V buck converter to power the servo board (lipo UPS could do this but if 12V power to lamp is off then switching it is pointless), and 2x AA (1.5V) or if rechargeable (1.2V) 3xAA to power the bell motor.
I'm using the following modules in node-red on the Pi, which do the hardware functions(We need I2C and GPIO), time monitoring(CRON), calendar events monitoring and triggering chromecast:
- node-red-contrib-cast [for my Chromecast-Audio - we play music + TTS]
- node-red-contrib-cron-plus [to trigger at set times easily (if you ❤️ cron)]
- node-red-node-google [get calendar events]
When you add/view modules via PALETTE menu in NodeRed, you can click the link to goto the modules project page that explains how to use the module and usually includes examples. Do this every timeas using a tool without knowing how is inefficient/ineffective! (Google the module if you can't find link)
Physically we need to setup a darlington pair circuit, (one resistor and two transistors) to trigger the motor from the Raspberry Pi GPIO pin [see https://electronicsclub.info/transistorcircuits.htm if unfamiliar or to help calculate resistor value]. We also need to setup I2C on the Pi and attach the PCA9685 / I2C Servo board. Lastly depending how you wish to trigger your alarm (you could just use windows scheduler and trigger the node-red alarm-clock flow), you will want to setup and test the google calendar node-red integration. These things can be individually tested in separate node-red flows with both a simple Trigger node and an HTTP endpoint node (easy triggering by other devices or browser).
In my initial setup I had 3 separate node-red flows and tried an HTTP endpoint at /tts/:msg which sent that msg value to the chromecast, and an endpoint at /buzzer to trigger the bell, and finally an endpoint at /lamp to activate the servo and "switch" the lamp. I eventually added the alarm routine and events integration as two additional flows.
Chromecast Audio TTS Flow - adapted from basic module example:
The dawn chorus uses a similar flow as TTS with a media url and media type set instead of a message.
Lamp Switch Triggering via Servo and lever/pulley system:
GoogleCalendar Alarm Trigger / Cron Schedule Flow:
Some of the flows are more messy than is ideal, but to account for the different triggers I have a few yellow change nodes to set the variable names correctly. This is most evident in the Alarm Routine, although the TextToSpeech flow also heavily relies on this technique.Results / Initially Working Prototype (Minimum Viable Product?)
When satisfied with the code and functionality I soldered glued and screwed things down (not initially as Usb power bank didn't like powering the Servo board - intermittently - when not drawing current it would switch off and never back on, I switched it out for a dc-dc 12V->5V buck converter.).
Don't worry it doesn't have to be perfect, if it functions that's most of the battle. I went through two iterations of the servo touch mechanism before satisfied and now look at it, it's not pretty, with that thick yellow ground wire coming off the two-pence, but it works well.
Below is a classic example of questionable aesthetics, I like it because it's small and functional, a Darlington pair with resistor, on 7 lines of perfboard, soldered underneath monstrously but securely and hidden in hot-glue (cable tension relief and avoid shorts with my random dangling cables during prototyping).
Yellow= GPIO trigger, Red=+3VDC, Green=+Load
Here's my first attempt at cleaning up the wires and adding a base plate:
Finally I came to hackster.io to report my progress and motivate myself to begin refining the idea!My Setup (rather than yours):
So my setup is personal as you would expect, I am starting the plan with the idea of each light level having a transition time of 5 minutes, a dawn chorus at light level 2 (https://sounds.bl.uk/resources/language-of-birds/dawn-chorus-phil-riddett.mp3) combined with Google TTS at level 3 speaking the phrase "Good Morning, Tyeth,. Let's get this show on the Road!". If I fail to get up still, then the volume of the TTS (chromecast) is raised and the phrase "you asked for it..." followed by the alarm bell and then chromecast playing death metal loudly.
I like the idea of potentially having the google calendar events containing an alternative audio file URL and TTS phrase. Crucially I am also currently unsure how to signal that I am awake, initially I had envisaged a short maths test like google-mail-goggles used to offer (between night hours it would not send email unless you passed a maths test). I'm now coming around to the idea of having to repeat positive affirmations back to the alarm clock like "I am feeling refreshed and awake". I don't have a microphone connected quite yet (no usb micro-B OTG cable for my usb sound-card) so that will have to come later. For now the physical act of disabling the alarm proves your awakedness along with motivating you to not let it happen again and get up at the dawn chorus in the future (to disable the remaining alarm-routine for that day).Pain Points:
The touch-activated switch on the SAD lamp is the most interesting element of this project for me, mainly because I was interested to see how the capacitance between ground and a wire can be enough to trigger a circuit. The coin acts as a large conductive surface, and the wire adds extra capacitance, and that feeds back to the lamps ground in the power supply. Normally a human doesn't need a ground connection as they have capacitance across the skin. The same technique works with aluminium foil etc. This is a great article on the subject: https://www.allaboutcircuits.com/technical-articles/introduction-to-capacitive-touch-sensing/
There are some great examples, I love this simple arduino one creating a piano:
Google and Ngrok and exposing your device to the internet
Setting up the google authentication on the laptop was easy, but on the pi was more painful due to nodered saying the device and ports weren't exposed. To solve this I recommend the free version of ngrok which will expose the raspberry pi instance of nodered on the internet just while you do the google authenticate bit.
Follow the instructions at ngrok.io (once you have an account is best) and you'll get a link to the zip, a command to authenticate, and an example command to expose port 80. We need port 1880 so you will see below in the screenshot that I adjusted the commands. After doing this, access nodered at the new https address (Listed under "forwarding" - masked in red on the screenshot). This will make the google authentication seamless. Once you have added your google account details and authenticated successfully you can stop ngrok running and remove it if you wish.
Powering the servos with 5v proved initially tricky as I tried to use a powerbank but it needs a bleed resistor to maintain enough load otherwise it switched itself off, so I went with a DC converter and replaced the original 12V lamp supply with a higher current version. I had planned to use the UPS (LifePO4WERED+ Device) which can supply 2amps at 5v, however I don't want brownouts on the pi when using the servo and bell and also don't want too much heat generated to then require additional cooling, plus if the power goes I'd like to reserve as much battery for the pi and bell as possible.
Powering the bell with 3v was easier, but I have yet to implement the ideal solution of relying on the lithium ion battery in the UPS or even its 3.3v output rail. Using a battery pack is cheap and efficient on time, plus the replacement with rechargeables takes away my guilt.
Probably my worst thing in electronics projects is having unreliable or not enough jumper cables with the correct heads on. The most common issue I've been betrayed by (excluding my own eyes and stupidity) are flaky intermittent connections due to weakly gripping jumper cables or super-thin end pins in a breadboard. You also end up needing a surprising number when connecting multiple sensors/pcbs/breadboards. The Pi alone needed six before even reaching the breadboard! I have a few very old jumper cables and I usually end up using solid core wire instead but that only works half the time unless you're happy to solder and desolder things all the time when prototyping which I'm not. I think this is the one place you won't regret spending good money. (My solution last year was to get some spring connectors for joining wires - a mixed size box identical in function to https://smile.amazon.co.uk/gp/product/B07JQ5Q5XY )
Strange things did happen once or twice when I had no events before deploying, but it does seem to catch them eventually. I saw the Event trigger fire late a few times, but it seems reliable since I made changes. I have a CRON node setup to trigger every fifteen minutes and update the NextEvent node and print to debug. This seemed to resolve the problem and keep the calendar in sync. I should probably investigate what the module is doing to keep up-to-date and how frequently it updates by default, but it seems to hit the alarm at the correct minute whenever I'm monitoring it so good enough for now. (I no-longer deploy again, just add a new calendar entry and cross fingers.)
Aside from the voice activated confirmation of being awake, in the form of positive meditation (affirmations/mantras probably in a listen-repeat quiz game form), I don't have many plans for this. My friend wants one to aid a positive start to his mornings so I need to reduce the cost and complexity, but it's basically much easier if I get him a different SAD light as the most complex (and fun) element of this design is keeping the touch button accessible to human activation as well as machine.
I'd like to improve the data packets format, allowing specifying media urls, volume and messages in the calendar event. I've already tweaked most flows to allow overriding parameters like delay time and message. I'm also keen to add an air quality sensor but not happy with price and effectiveness yet as I'm usually looking in the sub- £10 range.
Finally I like Simone Giertz, as do most who've heard of her, so it probably is worth considering having the well researched manikin hand slapping me into a morning state of joy... it sure beats most of the wallace and gromit-like ideas I usually come up with, although the bucket of cold water alarm clock is still on that list...