DIY IoT Electronic Shelf Label With Google Firebase

by Northstrix in Circuits > Microcontrollers

1108 Views, 12 Favorites, 0 Comments

DIY IoT Electronic Shelf Label With Google Firebase

IMG_20231019_104635.jpg

An electronic shelf label (ESL) is a type of price tag. The one that enables you to easily set and update the product name, pricing, product description, etc.

The ESL that I've developed enables you to showcase up to 195 characters of relevant product information. It is comprised of only two components: ESP8266 and a 1.77-inch TFT LCD with ST7735.

As for the number of ESLs you can operate. Technically, this particular ESL allows you to operate as many of them as you wish, provided that each has its own unique ID, they all share the same cryptographic key, and there's enough power and bandwidth for all of them.

*The product description and LLC name demonstrated on this page are entirely fictitious. Any similarity to the actual product description and LLC name is purely coincidental.

You can also read this tutorial on Medium.

Supplies

  • ESP8266 x1
  • 1.77-inch TFT LCD with ST7735 x1
  • Access Point x1
  • Either 5V or 3.3V Power Supply x1

Encryption

FXBJWBTL5PC97EH.png

The Electronic Shelf Label With TFT LCD makes use of the encryption scheme taken from the Encrypted-book Reader project.

Back then, I incorrectly stated that the encryption scheme uses the 3DES encryption algorithm in CTR mode.

In fact, it uses the 3DES encryption algorithm in ECB mode while also incrementing the key each time the algorithm is used. I hope this clears up any confusion.

I'll be honest with you - the encryption scheme used in the project is definitely not the "cutting-edge" one, and it's vulnerable to cryptanalysis and Sweet32 attack. However, it's still better than nothing, and as flawed as it may be, it still does its job.

Install Drivers and Configure Arduino IDE *Optional

If you've never flashed ESP8266 before you'll need to configure Arduino IDE and install drivers to upload the firmware to the boards, you can find drivers here:

CH340 driver: https://sparks.gogo.co.nz/ch340.html

CP210x driver: https://www.silabs.com/developers/usb-to-uart-brid...

In case you don't have Arduino IDE, you can download it here:

https://www.arduino.cc/en/software/

Configuring IDE isn't a part of this tutorial, you can read about it here:

https://randomnerdtutorials.com/how-to-install-esp...

Download Firmware

You can download the firmware for the Electronic Shelf Label with TFT LCD from SourceForge or GitHub.

Here are the links for you:

https://github.com/Northstrix/Electronic-Shelf-Label-Firebase-Edition

https://sourceforge.net/projects/esl-firebase-edition/

Download and Install the Libraries

Adafruit-ST7735-Library: https://github.com/adafruit/Adafruit-ST7735-Library

Adafruit-GFX-Library: https://github.com/adafruit/Adafruit-GFX-Library

Adafruit_BusIO: https://github.com/adafruit/Adafruit_BusIO

Firebase-ESP-Client: https://github.com/mobizt/Firebase-ESP-Client

The process of unpacking libraries is typical. You can unpack the content of the archive into the folder: ...\Arduino\libraries. Or open the Arduino IDE, click to the Sketch -> Include Library -> Add .ZIP Library... and select every archive with libraries.

Other required libraries are already present in one way or another.

Set Up Google Firebase

F2Q2ELELNLRHDXU.png

I would be happy to explain to you how to set up Google Firebase. However, I believe that the article at https://medium.com/firebase-developers/getting-started-with-esp32-and-firebase-1e7f19f63401 does a better job on that. I suggest reading the article up until the "Development Environment Setup" headline.

When setting up the database, save the "Realtime Database URL" and "Web API Key."

These values will be needed later.

Get Private Key for Firebase

1.png
2.png
2a.png
3.png

To upload data to Firebase, you need to get the private key and place it in the same folder as the desktop (client) application.

To do so:

  • Open your database;
  • Click on the "Settings" icon;
  • Click on the "Project settings" line;
  • When the next tab loads, go to the "Service accounts" tab;
  • Click the "Generate new private key" button;
  • Click the "Generate key" button in the pop-up window;
  • Save the private key to the "V1.0\Desktop App" folder under the "firebase key.json" name.

Generate the Encryption Key

FDA866ZLNLRHDOA.png

To use this device, you need to generate a 24-byte key. You can do this by any means possible. In my opinion, the easiest way to do it - is to take the key generator from Midbar, generate the keys, and only take the "des_key" from the output.

If you decide to go that path, note that although the output seems "random enough" for me, I haven't run any tests. So, I can't guarantee that it's random.

Use it at your own risk!


My encryption key:

byte des_key[] = {
0x3a,0xab,0x66,0x62,0xde,0xff,0x21,0xd3,
0x64,0xed,0xc6,0x67,0xa8,0xe0,0xbb,0xcf,
0x0d,0xac,0xaa,0xc3,0x25,0xdc,0xb2,0xb5
};

Modify the ESL Firmware

mod_f.png

Open the "Firmware.ino" file from the "V1.0\Firmware" folder and put your values to the following variables:

WIFI_SSID

WIFI_PASSWORD

API_KEY

DATABASE_URL

After that, replace my keys with yours.

Also, pay attention to the following lines:

String id = "Abcde"; - ESL ID. This is how the ESL knows what data belongs to it. It must be unique for each device.

int delay_in_seconds = 600; - Request data from the cloud each n seconds.

Flash ESP8266

flash.png

Upload the modified firmware from the "V1.0\Firmware" into the ESP8266.

Replace the Encryption Key in the Client Application

enc_key.png

Go to the "V1.0\Desktop App" folder, open the "encryption_key.txt" file, and replace my encryption key with yours. Don't forget to save the file after you are done.

Install the Necessary Software

To run the ESL desktop application, you need to have Java Runtime Environment and Python IDE installed.

You can download the Java Runtime Environment from http://www.oracle.com/technetwork/java/javase/downloads/index.html

As for the Python IDE, install whichever one you prefer. I guess any of them should be able to run the desktop (client) application.

Install the Necessary Libraries to Python

Install the following libraries to the Python IDE.

  • firebase_admin
  • tkinter
  • os
  • time

Set the Data to the ESL

client app.png

Open the "Launch.py" file in the Python IDE and run it. Once you do this, a form with nine entries and a button should appear.

Enter the ESL ID in the first entry, and fill out the remaining eight entries with the required data. Keep in mind that the ESL only displays 26 characters from entries 1 - 7 and 13 characters from the entry dedicated to price. Press the "Set Data to ESL" button after you've entered the required data.

It takes roughly a minute for the software to encrypt and upload the data you've entered to the cloud.

Power the Electronic Shelf Label Up

IMG_20231019_104214.jpg
IMG_20231019_104200.jpg
IMG_20231019_104242.jpg

Finally, it's time to power the ESL up.

After being powered up, the ESL connects to your Wi-Fi, connects to the Google Firebase, retrieves, decrypts, and then displays the data on the TFT LCD connected to the ESP8266.


If the inscription "Signing Up to Firebase" is displayed for more than five minutes, try rebooting the ESP.