Inspiration

After finding out about the hardware-based challenge, I decided to make something hardware-based as I have hardware components at home that I could use. I also found out about the domain.com and the Google Cloud platform challenge. And so I decided to try a project that would be hardware-based, use a back-end server and, more importantly, be slightly ridiculous.

I had a few displays lying around, including both a text display and a numerical segmented display. I also didn't want the project to be mobile and server-controlled as that would make things a lot more complicated. Communication between the server and the hardware was important to me, so I wanted something that would be sent by the user and something that the hardware could generate.

And so came about the idea for lucky numbers! A random number that could in some way decide your luck... which is definitely a real thing.

What it does

When you enter your username into the site, a PHP script saves the username to a file. A bash script on my laptop looks for changes to the file via HTTP and will download the file locally. Another bash script then takes the username from the newly changed file and sends it over a Serial/UART to an Arduino Mega. The Arduino then displays the username on the text display and generates a random number on the segmented display.

This is shown on a stream using RTMP/HLS which is taken from a webcam using OBS and displayed on the website using hls.js.

How I built it

The back-end is hosted on the Google Cloud VM instance (e2-medium) running Debian and the NGINX web server. NGINX is also used as a streaming server for RTMP and converting into HLS, which is used on the website (with hls.js). The web server was also configured with PHP, so that the server is able to make changes per user request.

For the Arduino program, I based it on an example for the LiquidCrystal library but added my own code to handle the segmented display, such as integer to display conversion, digit selection and extra animations.

Challenges I ran into

I had some difficulty with the Google Cloud platform interface to enable the server to allow it to process video streaming. My firewall settings were set incorrectly, which took a while to troubleshoot.

It also took a while to get the segmented display to work properly as there isn't proper documentation about it outside of blog posts.

Accomplishments that I'm proud of

I'm particularly proud of how well the communication between the server and my local machine works, simple but effective. Seeing the displays change after sending a request on the website for the first time felt like an incredible accomplishment.

What I learned

I learned:

  • how to set up RTMP video streaming with NGINX, and how to make the video stream viewable on a web page;
  • how multi-digit segmented displays work, and ways in which they can be programmed;
  • how to write scripts to enable sending data over a serial connection;

What's next for thisisyourluckynumber.space

If this project was to continue and stay live, it would be necessary to implement some sort of queue system to handle large amounts of traffic. At the moment, the server doesn't respect how long a requests stays on stream, and it is possible for your request to be left behind as the server takes care of a new one.

At the moment, the stream also suffers from a long delay between request and seeing it live. It may be necessary to research ways of improving stream latency to reduce waiting time.

Share this project:

Updates