For the first introduction into the (24x5) LED Grid, you should like to review these first introductory projects (Hover Labs Beam - Temperature, Humidity & Time and Hover Labs Beam - Photon Base Shield).
In this project, Beam's life is breathed, literally: the Word of God as a source of daily motivation is tapped and supplemented by the date and time displayed on the Beams, including the text and verses.
For this purpose, the official (and thus protected) Herrnhuter slogans are used.
- The copyright for the motto is: © Evangelische Brüder-Unität – Herrnhuter Brüdergemeinde and more informationen you will find here
- The publisher is: Evangelische Brüder-Unität, Postfach 21, 02745 Herrnhut, Germany
We look at how we assign the
- data to individual variables using JSON,
- explaining how we have managed to retrofit European characters, the so-called umlauts such as Ä, Ö, Ü, ß,
- look at the control structures used to display parts from the daily motto and
- how we update the current daily motto via webhook at 00:00h
At the end, a sweet candy is described, in which an
- individual text from a terminal widget can be sent to the beam using Blynk. This is for an appointment announcement or also greetings to a hospital bed.
ScruffR has simplified the PIN assignment in comparison to the original setup and so follow this assignment.
new:
Beam <> Particle Photon
HOST V+ <> VIN
3.3V <> 3.3V
GND <> GND
SYNC <> D7
RESET <> D3
IRQ <> D2
SCL <> D1
SDA <> D0
for comparison the original PIN-Setting:
HOST_V+: Connect to either 5V or 3.3V depending on your microcontroller. For example, if using the Arduino UNO, this pin should be tied to 5V since it is a 5V platform. The Particle Photon is a 3.3V platform, so this pin should be tied to 3.3V instead.
3.3V: Connect to the 3.3V pin on your host microcontroller
GND: Connect to ground pin.
SYNC: No need to connect this pin to your microcontroller. It's used when chaining multiple Beams in a row.
RESET: Connect to any Digital pin on your microcontroller.
IRQ: Not used at the moment. Leave unconnected.
SCL: Connect to SCL pin on your microcontroller
SDA: Connect to SDA pin on your microcontroller.
Code preparation with Tabs:Please create individual tabs and import / copy the code of the Libary also adapted in some points into the individual tabs. We do NOT use the original libaries of Hoverlabs. So far, suggestions of ScruffR to Hoverlabs are still directed, but Hoverlabs has only partially followed the suggestions: not all points have been committed into a Libary update via Commit. Hoverlabs prefers the use of Raspberry PI and Arduino. However, we decided to use the Particle Photon, which is superior to the Arduino with its performance and built-in functions. The Hoverlabs Beam hardware has been shown as a bottleneck so far: the timing is not optimal, only up to 3 beams can be connected, no influence on the brightness and so on. Nevertheless: we give the not quite cheap Beams an opportunity away from entertainment projects.
Webhook-Preparation:Please create a webhook with the following parameters within the Particle-Cloud under 'Console'-'Integration':
Event Name: tageslosung
Full URL: http://losungen.klose.cloud/api/today
That URL put out this example content:
{
"Datum": "2017-07-19T00:00:00",
"Wtag": "Mittwoch",
"Sonntag": {},
"Losungstext": "Ich bin der HERR, dein Arzt.",
"Losungsvers": "2.Mose 15,26",
"Lehrtext": "Durch Christi Wunden seid ihr heil geworden.",
"Lehrtextvers": "1.Petrus 2,24"
}
Request Type: GET
Device: any device
Include Default Attributes: No
Enforce SSL: No
> In the void(setup) you will find this function that trigger your webhook:
Particle.subscribe("hook-response/tageslosung", myHandler, MY_DEVICES);
Let´s start - We breathe Beam´s life:Don´t forget to include these 2 Libraries over the Particle Library Manager:
- #include <SparkJson.h> and
- #include <blynk.h>
The other libraries are supplied with code from the individual tabs. Do you still remember the confirmation message when the original libarys are flashed? This statement is ignored by #ifdef IGNORE and so we suppressed the first error message.
#include "application.h"
#include "beam.h"
#ifdef IGNORE
#include "charactermap.h"
#include "frames.h"
#endif
Next we set the System-Mode to Semi-Automatic as described here.
SYSTEM_MODE(SEMI_AUTOMATIC)
System-Thread features are available as v0.4.6 as described here.
SYSTEM_THREAD(ENABLED)
Short: the show must go on instead of errors.
Next major point is that we include WiFi-Support: define your WiFi-network you want to use (as example in the hospital, church or private use).
We bind the Blynk-Terminal Widget on V0 and finally you see we use also SYNC, RESET and IRQ-PINs.
Don´t forget to define your beam-count to 1-3.
Remark: It works not correct with 4 Beams in a row!
We define b as an Beam Object and config a custom message, which can be exchanged later by the Blynk terminal information.
You may be surprised that no serial monitor is controlled to output individual messages: we use a Particle function to output information to the serial port: the SerialLogHandler myLogger (LOG_LEVEL_INFO);
Get the data:void myHandler(const char *event, const char *data)
{
static int cntEvents = 0;
char mutableCopy[strlen(data)+1];
strcpy(mutableCopy, data);
Log.info("%d: %s, data: %s", ++cntEvents, event, data);
if (data) {
terminal.println(data);
terminal.println("--------end--------");
terminal.flush();
StaticJsonBuffer<256> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(mutableCopy);
if (!root.success()) {
Log.warn("parseObject() failed");
return;
}
strncpy(datum , root["Datum" ], sizeof(datum) );
strncpy(wochentag , root["Wtag" ], sizeof(wochentag) );
strncpy(sonntag , root["Sonntag" ], sizeof(sonntag) );
strncpy(losungstext , root["Losungstext" ], sizeof(losungstext) );
strncpy(losungsvers , root["Losungsvers" ], sizeof(losungsvers) );
strncpy(lehrtext , root["Lehrtext" ], sizeof(lehrtext) );
strncpy(lehrtextvers, root["Lehrtextvers"], sizeof(lehrtextvers));
lastDay = Time.day();
}
else {
terminal.println("no JSON Records available - check the Webhook under Particle Cloud - Console - Integrations!");
}
}
Each read-in information is assigned to a variable and is available for display in the further course. In addition, the terminal widget informs about the data read in.
The JSON buffer size is our biggest problem in the interplay with the Beams: the memory of the Beams is not enough to make even bigger texts than 256 characters scroll properly. Despite all optimization, we are limited here and therefore it can occur with longer texts with more than 256 characters to irritation. This has not yet been intercepted and offers room for improvement. As a rule, however, the solutions are markedly shorter. If you have problems, a look directly into the Bible can do no harm.
Otherwise, you can also pre-define the variables to perform your own tests.
char datum[20]; //= "2017-01-01T00:00:00";
char wochentag[12]; //= "XXXXXXXXtag";
char sonntag[12]; //= "YYYYYYYYtag";
char losungstext[256]; //= "LosungsText: Das ist ein längerer Text ÄÖÜ";
char losungsvers[32]; //= "LosungsVers ÄÖÜ";
char lehrtext[256]; //= "LehrText: Das ist ein längerer Text ÄÖÜ";
char lehrtextvers[32]; //= "LehrTextVers ÄÖÜ";
More information about JSON-Buffer-Size you will find here. Also a nice assistant from the library author.
void loop() {
static uint32_t msPublish = millis();
Blynk.run();
if (lastDay != Time.day() && millis() - msPublish > 60000) {
Particle.syncTime();
waitFor(Particle.syncTimeDone, 5000);
msPublish = millis();
if (lastDay == Time.day()) return; // if sync brought us back before midnight, try a bit later again
// request new day's data
Particle.publish("tageslosung", "MyLosung", PRIVATE);
}
print_out_on_Beam();
}
In addition to variable definitions, the Blync deamon and the call to the output function (print_out_on_Beam()), the focus is on monitoring whether a new day has arrived at midnight and new data is available for retrieval. This is done in conjunction with the JSON function (here the variable lastDay was assigned the day of the week).
How do we get the European characters of the umlauts Ö, Ä, Ü and ß?Let's examine the file 'charactermap.h': this was decisively manipulated in 3 places:
- in the size of the array to be read with
Const uint8_t charactermap[69][7],
- the entry
#include <Particle.h>,
- as well as the additional definition of the desired special characters:
{0x1D,0x0A,0x0A,0x1D,0x00,0xFF,0xFF}, // 65 Ä added
{0x0D,0x12,0x12,0x0D,0x00,0xFF,0xFF}, // 66 Ö added
{0x0D,0x10,0x10,0x0D,0x00,0xFF,0xFF}, // 67 Ü added
{0x1E,0x15,0x17,0x0D,0x00,0xFF,0xFF}, // 68 ß added
Hoverlabs supports with this information:
Check out this google sheets we made for this case. https://docs.google.com/spreadsheets/d/1JIjV-Fn8DmzT3S4k3O9z71VhcTkiuaUhdBygLJO4-2I/edit?usp=sharing
We decide to use a switch/case-structure which will loop: 8 cases are defined (0-7) plus a default case. So we start with case 0 to display the custom message (which you can change via Blynk Terminal widget), move on with case 1 and 5 to display date/time in context of the chain able Beams (1-4) followed by the JSON-imported variables to display the daily Losung/Motto-Text.
Each case is called with the method none, play or display - these methods ensure a running script or stable display of the context. In addition, the cases are equipped with a msDelay time, if this is missing in the case itself, the standard is defined with 5000 ms below. Especially the exact timing has cost one thing, so that even with longer texts the msDelay is adapted according to the formula and is also fully displayed.
msDelay = BEAMCOUNT * 2000 + strlen(txt) * msDelayPerCharPlay * loopCount;
ScruffR has not left it and has also added the summer/winter-time conversion for the time. In the absence of available features on the part of Particle, he quickly built his own function isDST().
Blynk compliant?Many greetings to my home community in Germany: the EMF Bielefeld!
This custom message "Meine Gemeinde: www.emf-bielefeld.de" can be modified via the Blynk terminal widget without intervention in the sketch via smartphone.
Here is what you need to do:
- 1. Download Blynk app here
- 2. Scan this QR code
- 3. Enjoy my app!
Yes, the firmware can also be compiled on an Electron (tested with v0.6.1).
For this, you need to commented out in 2 places:
A.) within the void(setup)
/*
WiFi.on();
if (!WiFi.hasCredentials()) {
WiFi.setCredentials(defaultSSID, defaultPWD, defaultAUTH, defaultWCIPH);
for(uint32_t _ms = millis(); millis() - _ms < 500; Particle.process());
WiFi.off();
}
*/
B.) and the WiFi credentials
// const char defaultSSID[] = "";
// const char defaultPWD[] = "";
// const int defaultAUTH = ;
// const int defaultWCIPH = ;
To ensure that you do not have to manually adjust this, we check which device is in use:
#if ( PLATFORM_ID != PLATFORM_ELECTRON_PRODUCTION )
Here is my Paypal link. I will send incoming payments to EMF Bielefeld e.V.
If a postal address is given in Germany, it is possible to obtain a donation certificate for the tax office.
Like my description? You will find more under my account.
Follow me to be notified when I publish new projects! You can also send me sensors, which I like to look at.
In the end, thanks again to ScruffR, who has worked with patience through a thread with more than 60 entries and also placed input with Hoverlabs. A quotation from him: "The triumph of spirit over matter has to be won."
Expansion options:
- Setup an IFTTT-Applet which informs if the Photon is offline (easy)
- Setup a second JSON-Statement for additional information like Temp / Humidity or add your own sensor (easy)
- You can still experiment with more methods like setSpeed(), setScroll() setLoops(), setMode() (hard - Library Skills necessary)
- You can still improve the timing so that up to 4 beams in a row would be possible: the AS1130 chip is in use. The full datasheet can be found here. https://ams.com/chi/content/download/185846/834724/file/AS1130_DS000283_3-00.pdf
with regards to this project:
a.) 5 Beams with 25% off and
b.) 10 Beams with 35% off.
This announcement is also placed in the Particle Community.
Comments