Hi fellow makers,

This is the MoodBox, a simple module equipped with buttons and LEDs. The idea is to communicate via a very simple interface, from anywhere in the world to anywhere else, allowing you to express how you feel as well as see how the other is feeling. The two boxes will be communicating with each other via internet, each button on a MoodBox controlling the corresponding LEDs of the other module.

This device allows to keep in touch with someone during a long distance relation ship for example.

In this instructables, I will explain how I designed and built it the device, and provide the code that runs the script.

Before getting started

Before beginning, I want to point out that the original concept for the MoodBox is not mine. All the credit for the initial idea goes to periprohus with his instructables on the EmotionBox. However, I decided to take this great idea a step further, using different hardware and creating a communication between to modules instead of between a module and an android application. I decided to write this instructables to share my work.

Step 1: How It Operates

For a communication to be established through internet, we need something that can store our data and act as a really tiny server. By creating two of these "servers", we can write and read data from each one of them. The communication is not direct between the two modules, the servers allow to keep the information accessible from anywhere at anytime. We will use Thingspeak for this purpose.

In order for the module to exchange data through the internet, we need to first connect it to a router. For this, we will use the famous Wifi module ESP-01, with an arduino to control the LEDs and receive inputs from the buttons. We could use any ESP above the version 10, because it has sufficient amount of inputs/outputs, but I wanted the final device to be easily flashed with the program by a complete beginner, only using the arduino IDE.

Using the ESP alongside with an arduino means that the code will be a bit more tricky to write, as we will have to send every command to the ESP manually using the AT commands set

Step 2: Designing the Circuit

The circuit is pretty straightforward. We only need to add a DC/DC converter, because the ESP-01 needs a decent amount of current under 3.3V in order to work properly. I found this very little and inexpensive converter which fit perfectly for this project. If you want to know more about this module, you can search for 'mini 360 buck converter'.

NB : there is no buttons in the photo of the prototype. I simulated input buttons through software

The pins on the ESP-01 are wired according to the datasheet. GPIO0, GPIO2 and CH_PD are pulled up to 3.3V in order to be able to send commands to the module.

Each LED has its own 220 ohm limiting current resistor. For the buttons, there is no need to add pull up resistors, as we can use the internal pull up of the arduino later in the code.

As you can see, the ESP-01 Tx and Rx pins are directly connected to the Rx and Tx pins of the arduino. This will not able the arduino to be programmed while the ESP is connected. I decided to go for this solution, because I found that the hardware serial port of the arduino is much, much more reliable than the one you can create with the SerialSoftware library. The downside is that the ESP needs to be disconnected each time the program is flashed on the arduino, but once the code is working, we only need to upload the code once.

Step 3: Create Two Thingspeak Channels

In order to communicate via internet, we will use the tools provided by Thingspeak. It is a very convenient and easy way to send data to a prebuilt database and to retrieve data from it.

We will start by creating two separate Thingspeak channels, one for each device. I tried using a single channel with one field for each device, but it didnt work very well, because updating one of the device blocks the other one from being updated for the next 15 seconds, leading to eventual loss of data (you can only upload a Thinspeak channel once every 15s).

Thingspeaks saves all the data that we sent to the channel, but the only data that means something to us is the last data sent by the other device. A request has been implemented by Thingspeak to retrieve only this last data, which is perfect for our application.

Once the channels are created, we can go into the Thingspeak settings and look for the Write API keys that will allow us to write data. I created my channel public so that there is no need for Read API keys, after all, there is nothing crucial in this data.

Step 4: Making the Circuits

The goal was to create the MoodBox as tiny as possible, so that it would look nice, and also a design/build challenge. However, I had to use some tricks when making the electronics, such that it was not possible to make a Fritzing file.

As you can see, the circuit is made of two sub-circuits that are connected so that they are perpendicular to each other. This allows to the buttons and the LEDs to be on a different side on the enclosure.

I used some copper wire from an old transfomer to make the connections. It's not the easiest way to do it, but it looks kinda cool !

I took some close up photos of the results, if someone is interested in replicating the electronics from this project

Step 5: The Enclosure

The enclosure has been designed on Autocad and printed out. It consists of 6 side panels that come together with M2.5 screws, directly screwed into the 3d print. This turned out to work pretty well, even after screwing and unscrewing multiples times.

The total print time for one long side panel is about 1h30, and 20 minutes fir a small panel, which makes for a total printing time of around 7h30 for the whole enclosure.

The PCB is fixed to the top panel using spacers added in the top panel model. Each LED has a cover that prevent the light from reaching the other smileys faces.

I will upload as soon as possible the files needed to print this enclosure.

Step 6: Flashing the ESP

This step is almost mandatory, as the AT commands set changes from one ESP firmware to another. The code provided below might work, or might not depending on the default firmware of your ESP-01. I flashed the firmware in the binary code just below, with the help of this instructables, and the code was written according to this version's commands.

If you don't want to go through this step, which can take quite some time, you can as well modify the AT commands in the arduino code below.

Step 7: The Code

I will not discuss much about the code, as I commented it the best I could. The arduino file is composed of a .c for the main code, and a .h for the variable definition. If you want to use the code, then all that you need to do is to input your own parameters such as :

  • Wifi SSID
  • Wifi Password
  • Channel ID 1 and 2
  • Write API key 1 and 2

I created a field called USER that allows to upload automatically the right parameters for the module. Switching USER to 0 or 1 will upload the right parameters accordingly.

For the operating mode, pressing a button sends the data to Thingspeak, and retrieving the data is automatic. Some LED patterns allows to understand what is going on with the module. For example, after initialization, when data has been successfully sent, when data could not be sent etc.

The code is quite heavy, due to the fact that I used AT commands to control the ESP-01, but it was really instructive. I recommend using a serial to usb module with a software such as terminal to see what is going on with the serial communication..

Step 8: The Results

I made this short video to show the results of this project. Only one of the two modules has its enclosure printed at that time. Please excuse my editing skills.

This project was a lot of fun, and quite challenging to make. This is my first instructables , but I will definitely keep making more in the future.

I hope you enjoyed this instructables as much as I enjoyed writing it !

<p>Great project! Voted for you. Are you still planning to upload the files for the case?</p>
Thank you very much ! I will upload the files in the coming days sorry for the wait.
Great idea! Just wondering, could u do the same thing with text and a small lcd? Like a mini text messenger?<br>
Thank you !<br>If you were to display text messages, you would have to find a way to input text which would be quite complicated. The goal was to have a very simple interface. You could however use an LCD to display smiley faces or predefined messages
excellent improved idea !!!! my respect to you !!
<p>Very fun an good Work. thankx</p>
<p>prepare to make and integrating with my project <a href="https://www.instructables.com/id/Lumen-Histoire-IoT-App/">https://www.instructables.com/id/Lumen-Histoire-IoT-App/</a></p><p>it will be awesome..</p><p>by the way your project is cool..</p>
<p>Awesome! It greatly improves the EmotionBox.</p><p>Luckily I'm living with my partner now, so no need to upgrade for me :)</p>
<p>I am very happy you found this project interesting ! Thank you very much :)</p>
<p>this is awesome.. suit for my girlfriend</p>
Cool Idea
<p>This is a cute idea for long distance friends and family!</p>

About This Instructable




More by SalvageIt:Moodbox, stay connected despite the distance 
Add instructable to: