Skip to main content

Break an egg! You've got to be in it to win it.

What the 'egg?

It turns out: parenting is actually quite hard.

Not least because you suddenly find yourself responsible for one, two, or - in our household - three little miniature versions of us that need to be kept well away from the soldering iron. Or the 3D printer. Or that marauding hexapod that you forgot to power off before you left for work in a hurry.  But to compound matters further, you find yourself well and truly ambushed - financially.  You are at all times being pressurised by dark forces beyond your control to make an investment, however dubious the return.

That's right.  Clearly, you will be considered an abject failure as a responsible adult if you don't purchase the latest, trendy parenting gizmo. That feeding bottle sterilising kit clinically proven to kill all known bacteria through the science of nuclear fission. Or that titanium alloy buggy guaranteed not to crumple in the event of a sudden collision with falling Soviet-era space debris.  Evidently, you need them all.

After all, why would you not want the best for your kids? 

But don't mistake us for grumpy adults extolling the virtues of raising kids in an uninhabited prairie. Because some electronic aides do help us be responsible parents. A Gro Egg™ by the Gro Company that displays the current temperature in the nursery room, and glows in an assortment of different colours, did prove to be a rather useful instrument living here in the UK - the only known country on Earth in which it can inexplicably become "a tad" chilly overnight, at the glorious height of summer.  Sure. We shouldn't have to rely on the dispassionate (but scientifically accurate) assessment of a glowing, acrylic egg to make a decision on whether to unpack the sleeping bag from the loft (which rather conveniently, the Gro Company also sell).

But then, why not?

But whichever the gadget, whatever its intended (or unintended) purpose, eventually that inevitable, gut-wrenching moment arrives.  When that device that you grew rather fond of becomes surplus to requirements.  And sits idly in the corner of a room. Covered in dust. Cultivating germs brought back from playgrounds that no laboratory in the world can (or wants to) identify.

Above all, it acts as a stark reminder.

Bringing up kids costs A LOT.

Back in the twilight zone. An imminent sunrise away from when your alarm clock is scheduled to wake you up for work.  While being kicked hard in the face by one of your kids snoring loudly next to you (or by a 3D-printed leg belonging to that hexapod).  This particular egg stares back at you.  Through the dark.  Taunting you with an annoyingly accurate reading of the room temperature.  It's at that precise moment that you're suddenly overcome by an irrational, delusional sense of purpose, fanned by a cheeky check of social media.

The Gro Company Twitter account provides the immediate inspiration. It was as if the manufacturer was positively egging us on to give our ailing gadget a new sense of belonging.

Friendly note to manufacturers of electronic goods: #ParentHack may be misinterpreted by a (very) small minority of the population plagued by sleep-deprived parenthood, with access to a tray full of electronics.

Here's some more fuel being poured onto this fire, this time on their website.

So there it is.  Hacking is good for health and well-being. We don't need to look any further.

We've stumbled upon a completely irrational and nonsensical reason to crack open this egg.  With the view of proving that this egg-shaped gizmo was indeed worth the investment after all.

This post is likely to warrant an unusually stark warning from the very start. Please read the below carefully, as we really do not want the "fun" to end (badly), for us, or anyone.

We are in no way endorsing the brazen tampering of everyday electronic products, nor should you view this post as a call to arms to roam around your home obliterating childcare gadgets (however resentful you may be of their hold on your life). The unethical, and - quite frankly - inhumane biopsy of an electronic product detailed here is after all, wholly unnecessary. Pointless, even.

In avoidance of any doubt: we are not affiliated with the Gro Company, nor did we have access to any technical documentation pertaining to the Gro Egg (a fact that becomes painfully apparent later on). This plastic egg was a random, unlucky victim. We hold no grudges against this or any other baby product.

As the saying goes: please do not try this at home (or at school, on public transport, or in the aisles of Mothercare). Electricity has always had - and always will have - the potential to cause serious injury and damage.

Beating the egg

We start our journey by ungratefully annihilating the egg.

Partly, it is because we want to see what's inside. But it is also to teach the kids an enduring lesson on the raw (and rather alarming) power of human curiosity. Its plastic shell was quite literally yanked apart, not using a tea spoon, but an old-fashioned flathead screwdriver. In fact, this destructive ritual turned out to be as symbolic as it was strangely therapeutic.  After all, it is no different to what is exacted to parental possessions by "clumsy" children on a weekly basis. Favourite mugs. Smartphone screens. Sides of cars. Except, this - ladies and gentlemen - is in the name of science.

And that makes it all ok.

With its plastic shell unceremoniously peeled away, we were faced with the ugly aftermath.  There is actually nothing very exciting about seeing a green circular circuit board, host to an array of miniature electronic components.  But it's simply too late to return this egg where we found it, unnoticed. To that shelf in the corner of the room. Or that aisle in Mothercare. The damage has clearly already been done.

Which inevitably means, in the spirit of our blogs, we continue to dig ourselves deeper into the proverbial hole.  In an effort to disguise one act of madness with another.

And here is what we saw. There are 2 sets of 4 LEDs; wholly justified since both the screen and the egg appear to glow 4 difference colours.  What looks like Thermistors to fulfil the egg's sole purpose - to measure temperature.  And, of course, a bunch of other stuff.  All in neatly arranged, tiny Surface Mount Technology (SMD) packaging, which allow them all to be embedded perfectly on the board.  Which makes them near impossible to identify, however.  For the average parent tinkerer intent on reliving a university electronics class, that is.

With daylight almost breaking, we need to rapidly find something interesting to destroy hack here.

Well, it was obvious when we saw it (love at first byte, if you will).

Tucked away behind another piece of plastic. We found the one component that acts as the honest face of the Gro Egg more than any other.  Yes. Its Liquid Crystal Display (LCD) panel. Besides, we've never worked directly with LCD technology before. Never interfaced with one, without the help of some type of ready-made controller, or driver.  Here was that opportunity.

...And just to prove how prevalent LCD / LED segment technology is, here are some examples we found around the house (spot the odd one out - clue: three of these are not Moomins).  The technology has been the de facto, cheep and cheerful mechanism for clever machines to graphically convey information to less clever humans for couple of decades, with no sign of it being replaced in the age of touch screens, holograms, Morse code, smoke signal, etc, etc.

And, truthfully, this see-through LCD panel from the Gro Egg quite literally looks like it comes from the Year 2199.  Here is a mesmerising prototype that was quickly knocked up using this technological centrepiece.

A special ops advanced Head-Up Display (HUD)

Your adversaries can take note of the temperature before they fire their deadly laser weapons at you. You, on the other hand, will remain completely blinded by the parcel tape.

If you are involved in the production of the next Blade Runner film, please feel free to contact us to get your hands on this hyper-futuristic, cyberpunk masterpiece.  We will even deliver it to the set ourselves (providing our flights, expenses and accommodation - for the entire family - are paid for).

That's it - you've got it.

This episode is soon to be consumed by our deranged efforts to exact revenge on the Gro Egg LCD panel.  All in all, a completely irrelevant cause, we realise.  But one that nicely forces us to learn about the intimate workings of a Multiplexed, voltage-biased LCD segment panel. And how to drive it directly using an assortment of DIY circuits built from basic electronic components; from Digital to Analogue Converters (DAC) built using Resistor Ladders, voltage amplifiers and buffers fashioned up using Bipolar Junction Transistors, and voltage followers constructed of op-amps. Even better; we once again get to play with an even bigger ESP8266 (ESP-12E) Wi-Fi enabled microcontroller, equipped with an I2C I/O expander.

Wow, it almost sounds like we know what we're doing (which we assure you isn't the case).  Or did we simply revisit our dusty electronic textbooks from university, and pulled out random, clever-sounding topics, complete with Wikipedia links? Possibly.

Lastly, before we progress past the point of no return (if the moment the egg was hacked apart wasn't that moment), it's worth noting that these three things would have made life significantly easier:

  • Getting your hands on a controller or driver specially designed to drive LCD segment panels.  It would allow you to cut out most of the highly distracting, dubious electronic circuits that we are having to construct, and is definitely likely to provide better results in the way of a) less flicker, b) better contrast / brightness, with c) little to no Cross-talk / Ghosting.  Doesn't that sound wonderful?
  • Having access to the datasheet of the LCD, describing the ideal, tested operating parameters of the component, such as required frequency and voltage. This way, we could have spent the time catching up on missed episodes of the IT Crowd, instead of embarking on a frustrating exercise trialling (and, oh yes, error-ing) different permutations of frequencies and voltages.  For what is, after all, a meaningless objective.
  • Not following through on stupid ideas. Live life normally. Like other parents.

But nobody said parenting should be done the easy way!

Equipped with a tray full of random electronics that we thought would never see the light of day, it's time to start plumbing some stuff in.

Reaching an egg-reement

It soon became painfully clear: making a mysterious LCD panel consisting of many segments, of unknown origin, display stuff is in fact considerably harder than changing the nappies on a crawling baby mid-flight, during turbulence.  While the flight attendants continue to deliver warm hand towels down the aisles. And there are several, very technical reasons as to why attempting to operate a LCD, especially without its specifications or datasheet on hand, is incredibly challenging.

First of all, unlike a much simpler display consisting of LED segments, the mythical, magical crystals making up the segments of a LCD panel need to be fed with the not so mysterious Alternating Current (AC).  This entails, in order to successfully light up any given LCD segment without permanently trashing it, alternating voltages need to be present between one end of the segment ("front") and the other ("back").  Goodbye our stable, dependable friend: DC. And hello to the complex friend we wished we never met: SpongeBob Square Wave Pants.

Secondly, by staring intently at the pins connecting our Gro Egg LCD panel to the circuit board, we quickly became overcome by inconsolable despair. Because there are only 11 connections bridging the LCD to the circuit board.  Physically, that is.  Clearly, these numbers don't quite add up.  Because it doesn't take long to realise that our LCD panel consists of a lot more than 11 segments. All of which - we assume - need to be independently controlled.

In fact, careful observation of the Gro Egg in action (before being ingloriously dismantled) reveals these segments...

Number of segmentsUsed for
71st digit
72nd digit
73rd digit
1Decimal point (.)
1Smiley face (☺)
1Not-so-smiley face (☹)
1Celsius symbol (℃)
1Fahrenheit symbol (℉) - not sure we've ever seen this segment lit while the egg has been in use on our island* of Cheddar cheese and ales featuring menacing-looking hobgoblins.  Nor do we miss it.

*Just to prove it, here is stereotypical content of the car boot belonging to a British citizen after a weekly shop at Morrisons.  Cheddar cheese, ale, and some fish and chips (just don't question the origin of these fries chips).

Wow, that was random. We need to re-focus our minds on the task at hand.

Here is our graphical summary of the segments that were identified, complete with smiley and not-so-smiley faces (strictly technical terms).

If we progress with our perfectly sensible assumption that all these segments are independently controlled (in other words, none are bound together), if the LCD panel is statically controlled and shares a single backplane, it would require a total of 27 connections.  Yes that's right.  1 connection to supply a square wave to the common backplane.  Then, 26 other frontplane pins to pass individual segments an appropriate square wave:

  • [If we want a segment to be off] A square wave that perfectly matches the phase of the common backplane.  Matching signals will never produce a substantial voltage difference, therefore no current flow to activate the Narnia-esque magic of the crystals.
  • [If we want a segment to be on] A perfectly inverted (reverse) waveform.  This will produce an alternating voltage difference, resulting in alternating current, and thus bring thy magik krystals to fruition.

Oh well, it looks like we're stuck with 11 physical connections to achieve the same end result - for all 26 segments. But how? Multiplexing becomes that friend that you are sure you never invited to your child's birthday party, but turned up anyway. And ate all the food (and probably never left your child a present).

Lastly, as if we didn't already have enough to grapple with, for reasons described later, use of multiplexing means that, for the backplane, we need to be able generate a square wave with a third state - one with ½ the HIGH voltage.  That is, the square wave supplying the backplane needs to be able to switch between 3 different voltage levels (0V, ½VDD and VDD), centred on the ½VDD.  Or in baby language: LOW, HIGH and "goo goo, gaa gaa: otherwise known as half way in-between".

Suddenly, the square wave driving the common backplane(s) cannot simply be binary - a luxury that we became accustomed to in the world of digital electronics. A makeshift Digital to Analogue Converter (DAC) needs to be wheeled in to the rescue.

Ouch. This is all not at all what we wanted.

This is no longer starting to sound so enjoyable, like the smell of nappies in the morning. And we've started to regret embarking on this rather ridiculous project borne out of chronic late nights and related caffeine binges. Still - for the time being - we'll persist with the insanity.

All in the name of science, of course. Because, strangely, we feel that we're actually starting to learn something.

(De)scrambled egg

If we hadn't been required to buy that mountain of baby formula that the young majesty would not even care to try, we may have been able to sneak into our weekly shopping list an Oscilloscope or a Logic Analyser to monitor real-life signals traversing the pins to our LCD.  This may have allowed us to reverse engineer its workings more methodically, from looking at readings of actual waveforms.  Sounds immensely sensible. And it's precisely why we're not doing it.

Instead, in order to identify each one of our 11 pins, we will manually send alternating square waves based on a "sensible" voltage to any give pairing of random pins, and observe what happens on the display with each combination.  If the LCD hasn't altogether combusted in a puff of smoke, we should be able to work out which combination of pins results in a particular segment being activated.  Furthermore, if nothing happens between particular pins, that tells us a lot too.  That they are of the same type.

But before we do, we can actually make some useful assumptions.

Multiplexing of LCD panels works by having segments (and therefore their pins) connected to more than one backplane.  By address a single backplane at a time, but in quick succession, one after the other, we can target specific segments anchored to a particular backplane for the duration that the backplane is "active".  In short, for each backplane, we can reuse the same "front end" segment connections.  Unsophisticated human eyeballs won't notice the flicker that exists if the whole sequence repeats itself at a sufficiently high refresh rate, or frequency, typically something approaching 60Hz.

How does this help us with our assumption?

We established earlier that our LCD panel has 11 pins.  If we contemplate the existence of 4 backplanes (and therefore 4 "common" backplane pins to drive them), we would be left with 7 pins to control the segments. This permutation gives us the overall ability to control a total of 28 independent segments through multiplexing (7 segments, across 4 backplanes addressed sequentially).

That's right: 28.  How very convenient. Since we identified we have 26 segments.  Any other combination, and we would either have the theoretical ability to control too few, or too many segments.

So we prematurely concluded, with reasonable certainty: 4 of our pins are to control the "common" backplanes, remaining 7 for the segments. 

Ever better.  This theory can be quickly proved (or disproved). Providing alternating, inverted square wave signals between any pair of the 4 pins we suspect as being for the backplanes won't illuminate any segments.  Same goes for the remaining 7 pins we suspect as being for the segments.  But if we pair up 1 of the 4 common backplane pins, with any 1 of the 7 remaining segment pins, we get a very specific segment light up. Yay!

Here's the tedious bit. No thanks to the temporary partition of unopened baby formula dividing up the kitchen, it will be manual trial and error of the maximum (dis)order.

Now that we've identified the batch of common and segment pins, we'll try out each and every combination of these (there will be 28 total).  This allows us to work out which pair activates which segment.  And once we record this, we can claim to have deciphered the internal wirings of our Gro Egg LCD panel... which means we're one baby step closer to controlling it... for no reason whatsoever.

Here is a busy matrix of our finding:

This essentially reveals how the LCD is fabricated.  Notice the physical proximity of the segment numbers, and the fact that you could quite easily (physically) link the segments to their common.  All the reason why these panels are arranged in this way. Presumably this makes them cheaper to make. With less wiring.

You'll also notice that segments 1/2, 3/4, 5/6 follow the same pattern for 1st, 2nd and 3rd digits.  This means - for the digits at least - you only need to add 2 to address the same segment 1 digit along.

SPOILER ALERT. We don't think we're actually going to be showing the temperature on the display (because otherwise, why would we have hacked apart a perfectly usable device that did just that)... This means we should be able to ditch pins 5 and 6.  We won't get to show the decimal point, or the 3rd digit that comes after it.  But we won't miss them, really.  Besides, we're now down to only requiring the 4 common backplane and 5 segment control lines.  9 total.  Still a sizeable number of physical ports required to drive our LCD.  But manageable.

Egg and chips

Right, how do you like your eggs in the morning? ...Burnt on a crudely rigged LCD panel, please.

We think we now know how to drive our LCD.  Which means it's time to get our hands on a system running software that will allow us to kill the avian layers of these eggs with one not so giant stone.

Fresh from our recent foray into the IoT favourite ESP8266, we feel that it is as good as any place to start. We will be using the ESP-12E variant, as we will need access to a large number of GPIO pins to interface with our LCD (which at first feels like 9, but it turns out we need more).  It has been setup to run on MicroPython, and connected to the WiFi network, using the exact steps we used before for the ESP-01S model.  Of course once the egg is "connected", we can now formally attach the infinitely marketable "IoT" tag to our creation. It just makes it sound so much more sophisticated than it actually is.

For those not in the know, ESP-12E is the meatier, meaner sibling of the ESP-01S.

But here's the proverbial curve ball.

9 GPIO pins available on the ESP8266 (ESP-12E) may at the start seem conveniently sufficient to interface with the 9 pins of LCD.  But this does not take in to account a third state - a ½ VDD - required on our common backplane lines.

And here's why we definitely require a ½ voltage bias.
  • We address each of the 4 backplanes in turn by providing a HIGH (VDD), followed by a LOW (0V) signal on that backplane's common pin.  For the backplanes not being addressed, we simply supply a static ½VDD signal for the bias.
  • We then address any specific segments that we want to activate for the backplane being addressed at the time, by providing the exact opposite signal to what is being provided on that backplane's common line.  This generates maximum a possible alternating voltage difference of VDD for the segments being turned on, and difference of around 0V for the segments being left off.  So far so good.
  • Which begs the question, why is a voltage bias of ½VDD necessary for the common of backplanes not being addressed? Because without it, the backplanes not being addressed would inadvertently have a maximum possible difference of VDD (for half a phase) which would be sufficient to activate segments on that backplane.
In short, we need to determine a VDD voltage value that activates our LCD segments, but for which ½VDD doesn't. And arriving at this value is absolutely crucial.

We repeat the above sequence as many times a second as our frequency dictates, varying only the phase of the segment signal depending on which segments we want to activate, and we have our crude, multiplexed LCD driver.

We do still need to work out what VDD should be, however.

Too low, and we found the segments not being bright enough. Too high, and we discovered inactive segments being inadvertently activated ("cross-talk" or "ghosting") because a sufficiently high ½VDD was enough to light a segment.  Frequency was a significant variable as well.

As the hearsay goes: pure and simple. Without the LCD's datasheet, it becomes an arduous exercise of trial and error. And as results unfortunately show, we still didn't manage to arrive at the perfect value.

Green eggs and... BAM!

Oh dear. Things are about to turn a little too complicated.  Yes, more complicated.

Dishing out our segment signals appear to be straightforward, since we simply use GPIO outputs.

ESP8266 GPIOConnected toGotcha
12LCD segment 0Buffered using voltage buffer. Inverted as a result.
13LCD segment 1Buffered using voltage buffer. Inverted as a result.
14LCD segment 2Buffered using voltage buffer. Inverted as a result.
15LCD segment 3Buffered using voltage buffer. Inverted as a result.
16LCD segment 4Buffered using voltage buffer. Inverted as a result.

And these are handled pretty simply in MicroPython code.  For example, if we want to set GPIO 12 to off (LOW):

import machine
s0 = machine.Pin(12, machine.Pin.OUT) 

...or to turn it on (HIGH):

But let's return to our initial conundrum: are 9 GPIO pins sufficient?  No.  Because the 4 backplane common signals we determined are not binary (they have 3 possible states:- 0V, ½VDD and VDD).  This ultimately entails we need 4 hand-cranked Digital to Analogue Converters (DAC).  And to produce 3 voltage levels out of each, we would require minimum of 2 bits to feed each of our 4 DACs.  Yes, we now need 2 GPIO pins per common pin, for which:

  • "00" provides a LOW of 0V
  • "01" (1) provides our ½VDD 
  • "10" (2) provides our HIGH of VDD.

Our DACs were built using a R-2R Resistor Ladder.  It is essentially a voltage divider circuit on steroids, which allows us to feed our pair of binary signals, and get 4 possible voltage levels (of which we'll only use the first 3).  We did methodically tweak the resistor values so that we could get a slightly higher ½VDD and VDD than would otherwise be possible if we simply stuck to the R and 2R values. Otherwise you immediately sacrifice half of the voltage for the "10" (2).

We also buffer the 4 analogue outputs of the DACs using LM324N Op-Amps in a Voltage Follower configuration, so that load resistance of the LCD segments didn't interfere with the workings of our resistor ladder.

Here is a stylish photo of 4 LM324N op-amps.  We only need one of these - since each LM324N chip actually has 4 op-amps built in.

So it's clear: we'll now be needing 8 (2 × 4) common + 5 segment signals = 13 outputs total. We suddenly find ourselves needing even more GPIO ports than our ESP has.

Time to dust off another piece of electronic paraphernalia: an I/O expander.  Here, we've used a PCF8574 8-channel I/O expansion board, which provides us with additional 8 outputs that can be controlled using I2C, which is a serial protocol that only uses 2 ports.  You don't get let off that easily. Here's another exciting close-up of this particular electronic component.

Connect the PCF8574 to the nominated I2C pins of the ESP8266, and you suddenly have the ability to control 8 further ports.

PCF8574 inputConnected to...Used for?
I2C SCLESP GPIO 4I2C clock line
I2C SDAESP GPIO 5I2C data line
VCCPower supply (3.3V)
Ground (0V)Power supply (Ground)

Output of the PCF8574 therefore now becomes...

PCF8574 outputConnected toGotcha
P0Least significant bit (LSB) of LCD common 0 2-bit DACBuffered using voltage buffer. Inverted as a result.
P1Most significant bit (MSB) of LCD common 0 2-bit DACBuffered using voltage buffer. Inverted as a result.
P2Least significant bit (LSB) of LCD common 1 2-bit DACBuffered using voltage buffer. Inverted as a result.
P3Most significant bit (MSB) of LCD common 1 2-bit DACBuffered using voltage buffer. Inverted as a result.
P4Least significant bit (LSB) of LCD common 2 2-bit DACBuffered using voltage buffer. Inverted as a result.e
P5Most significant bit (MSB) of LCD common 2 2-bit DACBuffered using voltage buffer. Inverted as a result.
P6Least significant bit (LSB) of LCD common 3 2-bit DACBuffered using voltage buffer. Inverted as a result.
P7Most significant bit (MSB) of LCD common 3 2-bit DACBuffered using voltage buffer. Inverted as a result.

If all is connected properly, it doesn't take much to configure an i2c object and scan (scan()) for our PCF module in MicroPython.  Once the device is found, it really is as simple as sending a byte that corresponds to the pins that we would like to be on / off on the expander (each bit of the 8 bits of the byte represents the status of the port) using the writeto() method.

For example, to set all 8 GPIO pins on the PCF8574 HIGH, we send (binary data "11111111", which in hex is "FF") to the expander on I2C address 32.  All LOW would be "00000000", "00" in hex.  Therefore setting just the least significant bit of our 4 DACs to get ½VDD would be "01010101" - "55" in hex.  You get the idea.  Except later on we discover that we need to invert the bits, since we use some NPN transistors to isolate our chips outputting logic signals from the rest of the circuit.

Here is a short snippet of us interacting with the PCF8574 using I2C.

import machine
i2c = machine.I2C(-1, machine.Pin(4), machine.Pin(5))

Have you found your device on the I2C bus to talk to? Good. Let's send a byte (hex 01) to it.

i2c.writeto(32, b'\x01')

We're almost there.... 

Transistors did we say?

Oh yes.  Do we really want to be driving the segments of the LCD directly from the GPIO of the ESP8266, or supplying the power to our makeshift DACs from the output of the PCF8574?  Arguably not.

Chip outputs are used predominantly for handling digital logic (not to generally power stuff that draws lots of current).  Moreover, we don't want to be limiting ourselves to the 3.3V that the ESP outputs.  We have a MB102 breadboard power supply ready to provide us with both 3.3V and 5V.  Therefore, we want to be using the 3.3V logic outputs from our ESP and PCF to switch our slightly higher 5V supply for the LCD.

In short, what we need are some Bipolar Junction Transistors (BJT) to switch all our common and segment outputs, and amplifying the 3.3V to 5V.  A Common Emitter setup works well in this scenario, allowing us to pass 5V to the remainder of the circuits, and provide circuit isolation to protect our ESP and PCF.  It is worth bearing in mind, however, that voltage amplifiers constructed with a NPN transistor (we used 2N2222 BJTs) invert the output.  We handle this in software by setting a HIGH when we mean a LOW, and vice versa.

We keep the glamorous shots coming.  Here's a pack of transistors. They are not sweets, so don't eat them.

And last but not least, we have a simply Voltage Divider circuit, followed by a voltage buffer constructed using a Common Collector transistor configuration, to carefully control the voltage level of the segment signals.  Remember, this needs to exactly match the VDD value of the common signal.

This is a high level pictorial representation of the supposed "solution", complete with a fluffy cloud to denote how the egg will eventually meet its maker in heaven.  Freeing up GPIOs on the ESP8266 using the expander also means that more arbitrary sensors can be added... like one that measures temperature.  Yes, wouldn't that be useful?

In reality, our Gro Egg appears to have had one mysterious Chip-on-Board (COB), tucked away underneath a blob of epoxy, which presumably handles most of this multiplexing and logic. Oh well. Never mind.  Manufactures make these things look so simple.

By comparison, here is our monstrosity used to turn theory into practise.

Here's equally confusing annotation to attempt to explain away this poor excuse of a circuit.

New Yolk, New Yolk

With the necessary hardware allegedly in place, arranged in a chaotic whirlpool of componentry, all that is left for us to do is write some Python code that will run on MicroPython.  It simply needs to execute a loop that we can try to repeat at our desired frequency.  And for each phase, we drive the 8 bits of the common pins via the PCF8574 8-channel I/O expansion board using I2C to output the desired 0V, ½VDD and VDD values.  And near-simultaneously, we'll drive the 5 GPIO pins of the ESP driving the segment pins with VDD (HIGH) or 0V (LOW) values.  The result should be an amateurish representation of the required waveforms we drew further up in the post.  And driven at a sufficiently high frequency - perhaps 30Hz or more - the LCD segments we intend to activate should activate, while others remain (mostly) off.

As mentioned earlier, discovering the VDD sweet spot (through trial and error) becomes the biggest challenge.  We eventually settled on a VDD of approximately 2.8V (which gives us a ½VDD of 1.4V).  We couldn't get the segments to light bright enough, and there was some residual ghosting, but without wasting even more time, it was the best that we could do.  We also pulled down each common and segment pin to ground via a resistor as this appeared to alleviate ghosting of inactive segments.  Blanking all the common and segment pins before embarking on each phase helped as well.

We clearly need to maintain a dictionary data structure detailing the common / segment combination required for a particular character, which allows us to activate the specific segment(s) when its / their backplane is being addressed.

Padded out with additional logic describing when we want to display what character, we are now all set to hijack this screen for our own demented use.

Show us the whey

So what EXACTLY do we want to do with this?

Exhausting all this time and effort into this nonsensical project epitomises the very need to realise a genuine financial award.  We'll therefore embed a highly sophisticated, mathematically proven, AI-driven, award-winning algorithm to predict the winning numbers of the National Lottery "Lotto" game.

We'll use urandom().  Which is the micro version of Python favourite random().

We'll generate 6 unique 2 digit numbers randomly between 1 and 59 so that we can see a GUARANTEED return on investment from this unsuspecting childcare gizmo.  No more weekend shopping trips to Tesco to buy out the items from the baby care aisle.  They will be delivered to us on our private island, by our assistants, on private jets.

But just because we see two remaining ESP GPIO ports begging to be used, we'll do some of these pointless things as well:

SensorUseBut why do we ACTUALLY need it?Haven't we done this already?
SW-520DShock / tilt sensorLet's generate the numbers when the egg is shaken.Yes (with Pi)
LEDsLights eggFlash some LEDs.  Because it acts as a useful distraction to all the other things that the egg should be doing, but isn't.  We'll place red and orange LEDs in series with a resistor.Yes. Lots of times.

If there was another GPIO free, we could have wired a temperature sensor back in (like we did before) and take readings using the 1-Wire protocol.  Perhaps we are feeling really quite guilty about demolishing a perfectly usable parenting accessory.  But it transpires, we've ran out of GPIO pins. And reworking all this to include another GPIO expander simply isn't in the spirit of Not Doing Things Properly™ - which as you now know, is the overarching motto of our blogs.

The SW-520D is used to detect when the egg is shaken (it is essentially a switch made up of conductive balls that move around as we discovered from our previous outing).  We'll configure a GPIO pin (2) as an interrupt input pin, and force the regeneration of Lotto numbers while the LEDs flash ominously (like it's doing something genuinely clever).

This is done like this, using the default machine library.

import machine
shake_sensor = machine.Pin(2, machine.Pin.IN)
shake_sensor.irq(trigger=machine.Pin.IRQ_RISING | machine.Pin.IRQ_FALLING, handler=_detect_shake)

_detect_shake() has a bit of logic to de-bounce the switch crudely (so it's not hyper sensitive to switch bounce, and requires a bit of effort on the shaker's part) and to set a flag (generating_numbers) that forces the main loop to generate the numbers:

def _detect_shake(gpio_pin=None):
    if not generating_numbers:
        shakes += 1
        if shakes > 20:
            generating_numbers = True

After a few good vigorous shakes, the flag is set and the main loop breaks out of driving the LCD when it next checks the flag, and regenerates the numbers.

If you like your electronics neatly wired inside your egg, look away now.  This doesn't pass the basic "tidy electronics" smell test, unless the smell you're testing for is the one of burning plastic.

And just because we claimed the egg was "connected", we'll send off our numbers.  Using an API-driven email system, like AWS's Simple Email Service, will allow you to fire off an email via a simply constructed REST API, providing that you have your email domain registered, and you have all the access key information in hand.

Clearly, you can do many other things over the Internet.  You could remotely trigger the number generation, or perhaps even buy the lottery ticket for you if there is such an API available.  You could also do what other IoT devices do, and send numbers to a distant dashboard for the whole world to see.  But this is all starting to sound a little too creepy. And - quite frankly - we're no longer that bothered.

One clear source of disappointment: this beast of a handmade circuit cannot be fitted into the egg due to the size of components we've used.  We'd need smaller components to pack this all into the chassis of the egg, and an actual circuit board that we can attach them onto.  But we're exhausted. We've taken this little mission to the extremities of absurdity.  For now, we'll simply run some cables through the gaping hole at the bottom of the egg where the power switch used to be.

We finally got there in the end. Are you feeling p-lucky, Punk?

The orange and red LEDs in series gives the egg a nice "flame-y" feel, with the wholly unintentional crack giving it a dramatic effect (as if a grand some of money is about to hatch).

It's now time for us to shake the Gro Egg to reinforce our wallet with millions in our chosen denomination. We need the money... so we can continue to fill our house with many other gadgets like it.

...And perhaps an email to the Gro Company support team is required after all this.

Dear Gro Company. The Gro Egg we purchased sometime ago no longer appears to work. One morning, without warning, it suddenly stopped displaying the temperature, and displays seemingly random numbers instead. We no longer have the receipt, but we believe it is still under warranty, an in no way have we invalidated it. We look forward to receiving the replacement.

Meanwhile... Huh, what's this..?

If you feel the urge to reproduce this hack, here's the code:

Further information:

Working out how to directly drive a multiplexed, voltage-biased LCD requires lots of research.  Here are some of the very useful material we found out there on the Wild Wild Web (WWW):



LoRa-Wan Kenobi

In the regurgitated words of Michael BublĂ©: It's a new dawn .  It's a new day .  It's a new Star Wars film .  For me .  And I'm (George Lucas, and I'm) feeling good .  Unfortunately for Canadian Mike, the Grammy that year was won by the novelty disco classic with the famous refrain: We love IoT, even in Planet Tatooine * . *Not true. Clearly, the Star Wars producers didn't sincerely mean the last Jedi the previous time around.  Return of the Jedi, released during the decade that spearheaded cultural renaissance 2.0 with the mullet and hair-metal , was less economic with the truth.  Either way, we're going to take inspiration from the impressive longevity of the money-spinning space-opera and reboot our franchise with some Jedi mind tricks.  Except this particular flick doesn't require an ever-growing cast of unrecognisable characters, unless ASCII or UTF counts.  In place of an ensemble gathering of Hollywood stars and starlets, we will b

Battle of BLEtain

The trolling . The doxing . An army of perplexing emojis. And endless links to the same - supposedly funny - viral video of a cat confusing a reflection from a dangling key for a golden hamster, while taking part in the mice bucket challenge. Has social media really been this immense force for good? Has it actually contributed significantly to the continued enlightenment of the human (or feline) race? In order to answer these poignant existential questions about the role of prominent platforms such as Critter, StinkedIn and Binterest, employing exceptional scientific rigour equal to that demonstrated by Theranos , we're going to set up a ground-breaking experiment using the Bluetooth Low Energy feature of MicroPython v1.12, and two ESP32 development boards with inexplicable hatred for one another.  And let them hurl quintessentially British expressions (others call them abuse) at each other like two Wiltshire residents who have had their internet access curbed by the co

Hard grapht

You would all be forgiven for assuming that bar , pie and queue line are favourite pastimes of the British .  Yet, in fact – yes, we did learn this back in GCSE maths – they are also mechanisms through which meaningless, mundane data of suspect origin can be given a Gok Wan -grade makeover, with the prime objective of padding out biblical 187-page PowerPoint presentations and 871-page Word reports (*other Microsoft productivity tools are available).  In other words, documents that nobody has the intention of ever reading.  But it becomes apparent over the years; this is perhaps the one skill which serves you well for a lifetime in certain careers.  In sales.  Consultancy.  Politics.  Or any other profession in which the only known entry requirement is the ability to chat loudly over a whizzy graph of dubious quality and value, preferably while frantically waving your arms around. Nevertheless, we are acutely conscious of the fact that we have spent an inordinate amount