Lighthouse update: Block Diagram and Prototyping

  • Posted on: 3 May 2023
  • By: Jay Oyster

OK, thinking back to the beginning of this effort in January and February, I had a basic idea of what I wanted to accomplish in this build. First, I wanted the lighthouse itself to look pretty-much stock, as designed by Lego. I just want it to function with more autonomy.

Block diagram of the electronics

Basic design of the lighthouse automation systemSo starting with a basic set of functions and I how I saw it coming together initially . . . this is not that different from what I ended up building. Here are the basic components:

And just for the record, this project is not sponsored by Adafruit. I just like their products and their support site for newby electronics and code developers like me.

  • In the middle, I decided on an Arduino type board rather than a Raspberry Pi. It's easier to interface with basic input/output functions, and the coding and setup is a lot simpler. However, I didn't want to have to integrate extra RAM and Wifi, so I opted for an Adafruit Metro M4 Express Airlift Wifi board. I'd used it before on a digital lunar calendar project, it has integrated Ethernet and wifi, lots of memory, TLS encryption support, and it's fast.
  • I plan to use the wifi to connect to our home network, and from there, pull data from the OpenWeatherMap.org API
  • An add-on board will provide a realtime clock (a DS3231 RTC, also from Adafruit)
  • I wanted two independent sounds to be able to play at a time, and I didn't want to bog down the Metro M4 on this, so I opted for a pair of Adafruit FX sound boards. Very nice, they store the clips in either WAV or OGG files and play sound files whenever input pins are dropped low, so I can trigger from the logic of the M4. I opted for the ones with the speaker wire headers rather than a mini-RCA plug. And I picked the 16MB versions, which can hold several minutes of high quality stereo sound in OGG files.
  • Each sound board will have a pair of speakers. The first board is for background sound effects, and will drive a pair of mini speakers bought specifically for this. The other board will be for the foghorn and I wanted something a bit beefier, so I opted to resuse some Panasonic shelf speakers I had on hand.
  • I plan to drive the lighthouse light and motor, and a secondary light for the tower using digital output pins from the M4. I figured out the method to do this without overtaxing the M4 outputs later on.
  • And for the interface when not connected to a computer through the M4's Micro USB port . . . a 4.3" 40pin TFT touchscreen, being driven by an RA-8875 TFT Driver board, of course from Adafruit.

Yeah, lots of things ordered from Adafruit. The rest of the items for this project were items I had on hand. Wiring, 5V power supply, power switch and power LED, breadboards, and the wood for the case to hold everything.

Prototyping the M4, touchscreen, and sound boards on the desktopProgramming the M4 Metro board on my desktop, wired to the RTC, two sound boards, and the touchscreen.So I prototyped on my desk with the Metro M4, slowly adding components . .  .first the touchscreen, then the RTC, then the sound boards, and finally the wires to the lighthouse itself. Figuring out how to wire into the Lego motor and LED's was a bit tricky, but I managed to figure it out with the help of this great website: https://www.philohome.com/motors/motorcomp.htm

I told you it was working, so I'll share some shots of the prototyping, and the part of this I'm most proud of, the touchscreen interface I built from scratch.

Since I have weather data coming in, I decided to display updates of the current weather at my supplied latitude and longitude coordinates, including current temperature, humidity, weather desciption, visibility range and windspeed. I also got the local time of sunset.

I grabbed a quick shot of a lighthouse somewhere off the internet (sorry, I can't remember where it came from) and used it to test loading a bitmap image to the screen.  I'll go into more detail about the controls and The touchscreen interface as it existed before mounting in the lighthouse basecapabilities of the interface and overall system tomorrow. But here's a quick grab of the screen interface:

Almost finalized version of the touchscreen UI

The M4 is running CircuitPython. This is my first effort at programming in python, so I'm leaning heavily on the training materials provided by the CircuitPython and Adafruit teams.

Basically, it has a set time to turn the lighthouse on after sunset, and then turn it off again. The real kicker and the part I'm proudest of is that, using the weather descriptions provided by OpenWeatherMap, the lighthouse knows when to sound the foghorn. The touchscreen buttons can be used to manually turn the light, horn, and all sound on and off, and there are interface buttons to adjust the Light ON and light OFF times, in increments of five minutes, counted after local sunset.

Anyway, I basically finished the prototyping about two weeks ago, and then started building a wooden base in which to mount everything. Coming up in the next update . . .


Prototyping the electronics for the updated lighthouse
Electronics and Software Development
Woodworking