Thursday, 9 November 2017

A close shave

Last night, I thought about the fact that the new display module I have been sent, with its driver circuitry, only uses 4 pins rather than the 12 I was expecting on the naked 4 digit LED.  That means that I can connect the display module, the HC-SR04 ultrasonic sensor, AND the DS3231 RTC to the Uno all at the same time (and still have pins to spare).  By shuffling things up a bit on my breadboard, I could fit the RTC module alongside the ultrasonic module, so that a) it has a semi-permanent home and I don't have to worry about it getting shorted out any more, and b) I can use the display for either the clock or the rainwater tank gauge just by reloading the required sketch.  So I set to, and did just that.

Unfortunately, the combination of my poor eyesight, low light in the evening, and trying to line up small cables with small holes means - inevitably - I did something wrong - with style and panache!  Actually, it turns out I did a couple of somethings wrong, but please, read on...

Eager to see if the RTC was still keeping time after a week in its little bag, I plugged it all in and reloaded my little clock sketch.  Nothing... Zip... Nada! Well - what a let down.  So, hoping I had simply dislodged a wire to the display, I reloaded the tank gauge sketch as a test, but that worked OK.  I tried the clock again, but still nothing.  So it must be the RTC wiring or the RTC itself

I decided to pull out the RTC and the DuPont cables to it and start again.  I grabbed the RTC and burned my thumb on the battery - it was very hot!  I figured this meant I had a power problem and quickly found that I had reversed the Vcc and GND connections to the RTC board...  I'm really surprised I hadn't buggered up everything else on the breadboard - my Uno included! 

Anyway - I removed the battery and let everything cool down and swapped the connections back the way they should be, then tried again.  This time, the display came back to life (whoopee!), but I was a little disappointed and somewhat surprised to see the time was 13:65! 

I guess that just maybe, reversing the polarity and almost setting fire to the module may have had a slightly adverse affect on the data - possibly - so I reloaded the set time sketch, reset the time and tried again.  It was still showing 13:65 - weird...  Uh oh - I started to get that feeling of dread again - you know, the one I got just seconds after hitting the button to buy a Pro Mini that I realised I knew nothing about..?  After the first RTC I bought being DOA, perhaps I've now killed this RTC as well.

I reloaded the tank gauge sketch, just to make sure I hadn't fried the Uno as well, but that seemed to be working OK.  I tried the clock once more - and the time was still 13:65 - DAMMIT!  What was worse, was that the time display seemed static - even after 5 minutes (carefully keeping an eye on the temperature of the battery), it was still apparently 13:65 - I kind of hoped it might tick over each minute and show 13:70.

Well - I had removed and reseated the RTC module, and the Vcc/GND wires had been swapped, but I hadn't touched the SDA and SCL cables yet... Yes, you've guessed it - I had them round the wrong way too!  Good grief, just how much wronger (yes - its a word) could I possibly have got this?  After swapping those two around, and running the set sketch again, the display finally shows the correct time.  Just to make sure, I pulled the rest of the clock data (YYMMDD, DoW, and hhmmss) and displayed them on the Serial console - phew - all seems ok.  I haven't destroyed the chip after all, despite my best efforts.  Mind you, having abused the battery like that, I'm not sure how long that is going to last now.  It has kept the RTC going for around 24 hrs at the time of writing this, and the time is still correct to within about a second.  I'm just counting my blessings, and vow that I am not going to touch that module again until it goes into its permanent home on my portable workbench.

Lesson learned?  Accept that I'm getting older and my eyesight ain't what it used to be.  Don't struggle in dim light where you can't see the difference between a grey and lilac cable, or manage to line up the red and black cables with the appropriate pins on the Uno... TURN SOME LIGHTS ON!


No comments:

Post a Comment