Introduction

This time I will show You how to make “Notificator”

The device can be connected for example to the IFTTT system and react when a new mail appears. At app.remoteme.org  we will generate a link after calling which bytes will be sent to Arduino, and Arduino will display some light effect and play some mp3 from SDcard

What is needed

  • NodeMCU, WemOS or something similar
  • Two LED rings with WS2812B diodes ( I’ve used 16th leds rings )Image result for LED Ring with WS2812B
  • DFRobotDFPlayerMini – this is mp3 player. It plays mp3 from SDcard, and communicate with Arduino by RX/TXImage result for DFRobotDFPlayerMini

  • Speaker
  • SDcard
  • Logic converter -I’ve used this one, the mp3 player uses 5V and Arduino 3.3 that’s why we need this converter
  • Knowledge and skills to make simple PCB by our selfs

The tower

  • cardboard – two different thicknesses
  • Tracing paper
  • aluminum foil

Tower building

Above the plan of the tower in side view (my adventure with the technical drawing ended in primary school), all dimensions in millimeters.

Principle of operation

  1. ring of LEDs shedding light on 2.
  2. Tracing paper
  3. The truncated cone, made of cardboard and covered with aluminum foil, so it reflects lights from led rings, in figure 3 ‘ = the cut-out mesh
  4. carton tube – holds the towers vertically, inside the tube are cables for leds
  5. The height depends on you I have 85mm
  6. The Stand inside all electronics parts

 

 

All horizontal elements should be made of thicker cardboard.

Wiring diagram

The mp3 player is supplied with 5V voltage and communicates with Arduino via TX / RX, a logic converter is needed because the Arduino itself works on 3.3V voltage. The control of rings is also connected to Arduino (D5, D6) through the logic converter.

At repository, You will find eagle files with PCB plans

I suggest not to solder permanently Arduino and the mp3 player only to use female goldpins

 

Principle of operation

Our Arduino connects to the app.remoteme.org system using WebSockets (there are ready libraries) through this connection 5-byte messages are sent:

  • the first byte of the light effect for the upper LED ring
  • second byte light effect for the bottom LED ring
  • the number of the mp3 file to be played
  • the number of seconds how long the light effect and the mp3 will be played
  • whether mp3 should be played once or in a loop

source code

Whole source code You can find here 

in the SingleRing.cpp and SingleRing.h files there is a class to control the effects of LED rings. I suggest you start by looking at the setMode(int m) function:

depending on the given parameter, the ring will display the effect. You can add your own effect by calling function setConfiguration with new parameters (change of color, display speed) by adding a new mode, or adding a completely new effect – or let me know in the comments if I like it I will add new effect 😉

arduino.ino:

explanation:

We need to provide above data, detailed instructions here at the link also I’ve shown how to register in remoteme.org  and generate the token,

This function will be called when the message comes to Arduino and displays the notification. The code is so clear that it describes itself. I refer to the details of the classes to the documentation here  and  here 

In the loop, we call the loop functions of the objects, and also if the display time of notifications has passed, we turn off the diodes and sound.

Mp3 Player

It communicates with Arduino via TX / RX – Details of the player itself here, and the library  here

We upload mp3 files to the SD card. Files on the card are sorted alphabetically and then by calling:

We play the fifth file from the SD card from the root directory. That is why it is good to give files on the SD card prefixes 01, 02 etc. In my case it looks like this:

To generate voice commands You can use this page.

Uploading the program to Arduino

Before upload sketch to Arduino, You have to download needed libraries here you will find detail instructions

additionally, we need to install the DFRobotDFPlayerMini library

and Adafruit_NeoPixel

Control

We send to our Arduino five bytes

  • the first byte of the light effect for the upper LED ring
  • second byte light effect for the bottom LED ring
  • the number of the mp3 file to be played
  • the number of seconds how long the light effect and the mp3 will be played
  • whether mp3 should be played once or in a loop (1 if it should be played in a loop)

By sending bytes

Top ring will be showing the police lights (mode 6) bottom one blink green (mode 15) (check out setMode function at singleRing.cpp  and comments next to it). The first file form the SDcard will be played for 5 seconds. And the file will be played in the loop (check function  onUserMessage at arduino.ino )

Let’s send these bytes

Go to the devices tab – 1. 2: the status of our device should be like on the screen. Click on the “3” icon for sending messages

The window that appears is used to send messages to the device. In field 1, select the sender device  – because we have only one device, we select it (this is a mandatory field and it does not matter that it is the same device to which we send a message) In field 2 we give bytes to send (in red the value we entered in 2 will be represented as a string) then click the Send button.

After sending the message, our notifier should react by displaying the appropriate lighting effects and playing the selected mp3. I encourage you to try different effects by giving the first two bytes of a number between 0 and 22 (see description in the setMode function).

Sending messages using URLs

If we want to display notifications from an external application eg with IFTTT, we need to have a URL that will do exactly the same thing as we did in the window in the previous step. remoteme.org provides REST APi. Go to it by clicking on the swagger tab in the left (the last one). A page will be displayed, on this page we can also try our URLs

 

fill in the data as in the above screenshot. After clicking the execute we will send a message

The receiver is the device with 205 id, the same device is also a sender. MessageId with the “No_RENEVAL” settings is irrelevant. And then click Execute.

Notificator will react in the same way as when sending messages from the application.

After calling REST below is the URL that was called:

copy it and paste it into your browser’s address:

In my case, the URL is:

unfortunately, after logging out of app.remoteme.org, it stops working. This is because we did not provide the authentication token, and we are no longer logged in. Let’s get our token (or create a new one) and paste it into the URL instead of the star

my token

so URL looks like this:

Now we can call it even if we are not logged in. And when it is called, a message will be sent to our device 205

Integration with IFTTT

Url created in step above is suitable for execution by external applications. How to use it I will show on the IFTTT. I will configure it so that the notifier turns on when an email comes to the email address (Gmail account).

Log in to IFTTT.W iFTTT go to the My Applets tab and then “New Applet”:

Next click “+this”

Then in field “Search services” write “Gmail”.

Then “new email in inbox” (Some configuration could be needed).

After these steps, our IFTTT should look like this:

now we click on “+ that”

find “Webhooks” and click it

then “Make a web request”

we complete the URL of our url with the token. Content type to application / json and click “create action” and Finish. Now we have our applet:

After sending an email to the account indicated in the IFTTT, our notifier will let us know (In my case it turns on in less than 1 minute after receiving email)

Summary

In this tutorial, I showed how to send to our Arduino messages from external systems. We also integrate some other system then IFTTT in a similar way. It does not necessarily have to be a “notificator” I wanted to show in this example how to send messages from outside systems to our Arduino.

sourcecodes

FanPage at Facebook

Cheers,

Maciek