Skip to content

marcelstoer/Lovebox

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

❤️ Lovebox ❤️

this is a fork from @julisa99's original code at https://github.com/julisa99/Lovebox

See https://frightanic.com/iot/the-lovebox-a-gift-from-a-maker/ for build instructions and a description of the (early) code improvements I integrated.

How it works

Real quick here's how the Lovebox works:

  • device connects to WiFi
  • it then either
    • polls a GitHub gist you configure for messages to display OR
    • subscribes to a topic on an MQTT broker and waits for new messages to arrive
  • when a new message arrives
    • it is displayed on the OLED display
    • the heart starts wiggling
  • as soon as the lid is lifted from the box, the photoresistor (acronymed LDR for Light Decreasing Resistance, or light-dependent resistor) registers the extra light, assumes the message was read and stops the wiggling heart

Building the Lovebox

Refer to my aforementioned blog post and @julisa99's README for building instructions.

Installing the software

This project targets the Arduino IDE. I actually prefer to work with Visual Studio Code and PlatformIO (a lot) but the Arduino IDE is better suited for IoT beginners.

See https://docs.thingpulse.com/how-tos/Arduino-IDE-for-ESP8266/ for how to prepare the Arduino IDE for this project. Once done install the following two libraries in Arduino IDE (Tools > Manage Libraries):

GitHub gist or MQTT: polling vs. pubsub

Contrary to Lisa's original code this fork offers two ways of obtaining the messages to display: polling a GitHub gist every n seconds (default 60) or subscribing to a topic on an MQTT broker.

I find MQTT the much saner approach and I strongly suggest you give it try.

Polling

Go to https://gist.github.com, create a new gist (see "message format" below) and configure the path to it in settings.h in the Arduino IDE. Also, disable the MQTT option in the same file.

MQTT

The only challenge in using the MQTT approach is the fact that you need access to an MQTT broker the Lovebox can connect to. Also, you will need an MQTT client for your computer or mobile device with which you will publish messages.

If you don't have access to an MQTT broker already I suggest you open an account with adafruit.io. They also documented nicely how to set up a desktop MQTT client.

Finally, configure all MQTT settings in settings.h in the Arduino IDE.

Message format

The Lovebox supports two types of messages: plain text and (pseudo-)binary; a text message with 0/1 representing the black & white pixels of an image.

Please adhere strictly to the message format defined below to avoid unexpected results.

  1. 1st line: increasing message ID only for GitHub gist i.e. omit for MQTT messages! The Lovebox uses this ID to determine whether the message it polls from the GitHub gist is different from the one it previously displayed.
  2. 2nd line: message type t = text or b = (pseudo-)binary.
  3. 3rd and subsequent lines: text or (pseudo-)binary message content.

GitHub gist example

42
t
Look, just because I don't be givin' no man a foot massage don't make it right for Marsellus to throw Antwone into a glass motherfuckin' house...

MQTT example

t
Look, just because I don't be givin' no man a foot massage don't make it right for Marsellus to throw Antwone into a glass motherfuckin' house...

Image message

To send a (pseudo-)binary message prepare a 128x64 black & white image. Then upload it to https://www.dcode.fr/binary-image and set the target width to 128 pixels. The image will then be converted to "0" and "1", each black pixel represented as a 0 and each white pixel as a 1.

GitHub gist binary example

About

DIY Lovebox build. Fork of julisa99/Lovebox.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 71.7%
  • C 28.3%