top of page
  • Writer's picturevikram vel

Love box

Updated: Mar 6, 2023

I love making DIY gifts for the people close to me. It also gives me a guilt free reason to buy all the new tech goodies in market and get your hands-dirty ;)


D.I.Y Love box

This was one of my special projects and it is a quiet simple message box inspired from here.


The Love box is a connected, messaging device that lets you send message to your loved ones via MQTT.

The concept of the design I chose was simple, I designed it around the parts I had lying around my home.


To go back, a quick rewind of my thought process in designing this box. I wanted to do a simple toned-down version of the same on my own.


So, the key requirements for my system were the following,

  1. OLED color display - color display would give me flexibility in my future upgrades, and I don't have to rework on the display again.

  2. ESP32 - this was mere biased choice of mine as I have this long past with ESP MCUs.

  3. DEADLINE: To get it running in 2 days’ time - I guess this pointer is just for my sanity in my head, so that I have a reason to justify my code in Arduino IDE (more about this at the end).

I know most of you won’t even be reading this article of mine.


Come on, let us be honest when was the last time we went through an entire documentation of a DIY project on what the author says before getting our hands dirty with the code. It is fine, I would do the same...


Still, I wanted to get these pointers documented somewhere for that one right soul among us who does everything in the right way possible!


System design:


I can go line by line explaining the process of how my code works and make this a design-101 of the love box. But this is not a big thing, the code is in ARDUINO-IDE for God’s sake, and it is pretty much a fancy "system. printf" project. So, I would recommend you give yourself a couple of minutes to go through the few hundred lines of code attached and that should be fine to get you started.


However, as the author I do have few comments which I have put down below,


  • SEMU_SSD1331 Library: I am super grateful for these guys in coming up with a faster version of SSD1331 library to communicate with the OLED, as the version provided by Adafruit is not fast enough for me. Attached the version of library which I used for my code along with my repository.

  • MQTT public client: I know usage of web client with MQTT is not the most efficient way possible. I could have set up a proper MQTT broker and used a cooler MQTT application to send messages. But my problem statement was simple, the person who is going to receive my messages has no clue about any of these gizmo terms and it is me who will be sending these messages so, for my valentine’s day gift the MQTT web client was worth it. But the mechanism is established on the MQTT side, so in my future version all I would need to do is to build a MQTT server and hook it to my ESP code.

  • Screensaver code: This is a part of the code which exists just for my stupid nerdy mind. You are free to comment this off and have this as a simple message receive and display code, I made this simple routine for 2 reasons,

    1. It takes a lot of pressure out of you that you need to keep sending messages to keep this box entertained.

    2. I was coding in Arduino already, and I wanted some challenge in my head to get some compilation error orgasms!


Screen saver

Code and Libraries:

Code:

  • You can find the code repository here

  • Look out for comments ;)

The code is self explanatory as I said, and it is not a complicated state machine which gets you round and round. A code walkthrough along with this flow chart should explain the code if you find any of my stupidity exposed in the code ;)



Flow chart

Libraries:

  • Arduino library for SSD1331-based 96x64 RGB OLED boards - Link

  • This library provides a range of hardware optimized graphics functions for the popular .95" 96x64 SSD1331 driver-based 16-bit color SPI OLED boards which are widely available from Adafruit and elsewhere. Based on the original Adafruit SSD1331 library with additional hardware-optimized functions.

name=SEMU SSD1331 Library
version=1.0.7
author=SEMU
maintainer=semuadmin
sentence=SEMU SSD1331 library which replaces the Adafruit SSD1331 library.
paragraph=Provides hardware optimised command set for SSD1331 OLED.
category=Display
url=https://github.com/semuconsulting/SEMU_SSD1331 
architectures=*

How to send a message:


HIVE MQ server

  • I used a simple online MQTT broker - HiveMQ. You are free to attach any MQTT broker model you wish for, all you have to do is to replace the line 33 in my code (mqtt_server) with your MQTT server address.

  • Once the ESP32 is connected to the WIFI SSID, try going into - http://www.hivemq.com/demos/websocket-client/

  • Connect to the client.

  • Assign the topic to 'display1', again you can customize this topic to anything you want it to be.

  • You should see the message in the screen as soon as you hit the publish button.


I think that is pretty much it about the entire project, everything else the code should explain it to you, or you can always reach out to me.


More on Schematics and other resources : Here


¯\_(ツ)_/¯

It works on my machine!



Confessions:

I know people might get all religious with my hatred towards Arduino but trust me it is not my hatred towards Arduino which I am venting out here. Arduino is the reason I got into this amazing world of embedded systems. It is the religious people who worship Arduino IDE I love to trigger.


Sometimes people just start abstracting everything, you don't want to know how the build system works; you do not care how efficient your code is working on your piece of hardware. So, it is such thought process which annoys me, but anyway you can argue about its pros to me but then get those in comments, we can have a chat there.


To Succeed, you must share.

Recent Posts

See All

Comments


bottom of page