From the moment I saw the MAX7219 Dot matrix modules I wanted to build a news ticker. I wanted the option to enter my own messages without having to install special Apps on my phone or tablet. So the ticker must be approachable via a web interface. In addition to the messages to be entered by myself, it must also be possible to get the current weather and news items from the Internet and display them on the news ticker. Of course, the time must also be shown!
Een Nederlandse vertaling van deze post kunt u hier vinden.
The HardwareAn ESP8266 with built-in WiFi will suite this project just fine.The 1of!-Wemosand 1of!-ESP12processor boards are ideal for small prototype projects of this kind.To make the intensity of the display dependent on the ambient light, I use a Light-Dependent Resistor (LDR).As a display, naturly, the MAX7219 Dot Matrix modules are used.
Connecting the partsFor developing firmware for the ESP8266 I use a so-called Framework which contains everything for connecting to WiFi, retrieving the time via NTP a file browser to download- and upload files from the internal files system (SPIFFS) and there is a web server for the User Interface. Also updating the firmware “Over The Air” is part of that Framework in the form of an Update Server.All that needs to be added is control of the MAX7219 dot matrix display and functions to get the weather and news.
Depending on the type of MAX7219 you use, you must enter the corresponding definition at HARDWARE_TYPE. Depending on how many modules you use you have to adjust the definition of MAX_DEVICES (there are four MAX7219’s on one module). You can use the firmware with one, two, three or four modules. You can also use two modules next to and on top of each other with a BIG Font you can then use double height letters (this is not part of the firmware).
ESP-ticker.h contains a few #define statements that are important:
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
//#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW
#define MAX_DEVICES 8
Of course you have to install the Arduino ESP8266 core (read here how to do that). The ESP ticker has been tested with version 2.6.3.
The User (web) InterfaceExtra Libraries
You need to install the following libraries:
// https://github.com/JChristensen/Timezone
#include <Timezone.h>
// https://github.com/PaulStoffregen/Time
#include <TimeLib.h>
// https://github.com/jandrassy/TelnetStream
#include <TelnetStream.h>
// https://github.com/mrWheel/ModUpdateServer
#include <ModUpdateServer.h>
// version 0.15.0 - https://github.com/tzapu/WiFiManager
#include <WiFiManager.h>
To control the MAX7219 display you also need the following libraries from “Marco Colli”:
- MD_Max72xx
- MD_Parola
You install them with the Arduino Library Manager:
WEERLIVE.NL
We collect the weather from weerlive.nl. Here you must register and request an “API key”. The service is free for private use, as long as you do not request the weather too often (fair use). The firmware allows a maximum of one request every 15 minutes.You enter the API key on the settings page of the web server. Here you also indicate for which place you want the weather (but this is only an indication. In the middle of the Netherlands the weather always comes from De Bilt).
NEWSAPI.ORGThis organisation collects news reports from all over the world. You must also request an “API key” for this service. The service is free for “developers” if you request new messages for less then 500 times a day (note: The delivered messages are at least 15 minutes old!). That is a maximum of 1x per 5 minutes.You enter the API key on the settings page of the web server.
OBTAINING THE FIRMWAREYou can download the firmware from github. It is a bit too much to explain the whole firmware here but the most important things take place in the main loop () function:
void loop()
{
handleNTP();
httpServer.handleClient();
MDNS.update();
//--- het heeft geen zin om het weer op te halen als je geen API-key hebt --
if ((millis() > weerTimer) && (strlen(settingWeerLiveAUTH) > 5))
{
weerTimer = millis() + (settingWeerLiveInterval * (60 * 1000)); // Interval in Minutes!
getWeerLiveData();
}
//--- het heeft geen zin om nieuws op te halen als je geen API-key hebt --
if ((millis() > newsapiTimer) && (strlen(settingNewsAUTH) > 5))
{
newsapiTimer = millis() + (settingNewsInterval * (60 * 1000)); // Interval in Minutes!
getNewsapiData();
}
if (P.displayAnimate()) // done with animation, ready for next message
{
msgType++;
DebugTf("msgType[%d]\r\n", msgType);
switch(msgType)
{
case 1: if (!(millis() > timeTimer)) return;
inFX = random(0, ARRAY_SIZE(effect));
outFX = random(0, ARRAY_SIZE(effect));
snprintf(actMessage, LOCAL_SIZE, weekDayName[weekday()]);
P.displayText(actMessage, PA_CENTER, (MAX_SPEED - settingTextSpeed), 1000
, effect[inFX], effect[outFX]);
DebugTf("Animate IN[%d], OUT[%d] %s\r\n", inFX, outFX, actMessage);
break;
case 2: if (!(millis() > timeTimer)) return;
timeTimer = millis() + 60000;
inFX = random(0, ARRAY_SIZE(effect));
outFX = random(0, ARRAY_SIZE(effect));
sprintf(actMessage, "%s", updateTime());
P.displayText(actMessage, PA_CENTER, (MAX_SPEED - settingTextSpeed), 2000
, effect[inFX], effect[outFX]);
DebugTf("Animate IN[%d], OUT[%d] %s\r\n", inFX, outFX, actMessage);
break;
case 3:
case 6: nextLocalBericht();
P.setTextEffect(PA_SCROLL_LEFT, PA_NO_EFFECT);
break;
case 4:
case 5:
case 7:
case 8: nextNieuwsBericht();
P.setTextEffect(PA_SCROLL_LEFT, PA_NO_EFFECT);
break;
case 9: snprintf(actMessage, LOCAL_SIZE, "** %s **", tempMessage);
utf8Ascii(actMessage);
P.setTextEffect(PA_SCROLL_LEFT, PA_NO_EFFECT);
break;
case 10: nextNieuwsBericht();
break;
default: msgType = 0;
return;
} // switch()
//DebugTln(actMessage);
valueIntensity = calculateIntensity(); // read analog input pin A0
DebugTf("Intensity set to [%d]\r\n", valueIntensity);
P.setIntensity(valueIntensity);
// Tell Parola we have a new animation
P.displayReset();
} // dislayAnimate()
} // loop()
The “switch” statement ensures that alternate local messages (entered via the web interface) or news messages are displayed. If the msgType is 1 or 2, the day name and time are printed respectively. If the msgType is greater than 10 then all will be displayed again.
For the firmware to compile correctly you need the following IDE settings:
I like to be able to see the interior of my “projects”. That’s why I often use plexiglass for the structure or cabinet and why would I deviate from that for the ESP ticker?
I used two pieces of plexiglass (30x24cm and 30x6cm). Plexiglas can be easily cut with a fine hacksaw. By heating it locally with hot air (300 * C) you can bend it well (around the corner of a table, for example). The 1of!-Wemos board and the MAX7219 displays (2 pieces) are screwed onto the rectangular piece of plexiglass of 30x6cm. In order to properly mount the MAX7219’s, it is easiest to remove the two outer 8×8 display units from the PCB. That is quite simple because they are in a socket. You must be very careful not to bend the legs. Now you can screw the unit to the Plexiglas with four M2.5 or M3 bolts and nuts. On the other side you screw the processor board.Make a hole for the LDR and glue it with, for example, hot-glue.It is wise to test the unit now. The MD_parola library is very rigid in what is left and right and top and bottom. You don’t want the newspaper to be “turned upside down” when you’ve put it all together!The larger piece of Plexiglas is bent in a U-shape and serves as a cover.
The LDR is glued to the rectangular base with hot glue
Comments
Please log in or sign up to comment.