B4R Question Hints for a simple project

udg

Expert
Licensed User
Longtime User
Hi all.
Good at programming but no experience about electronics.
I have a simple project in mind, so I'd like to collect some hints from you.

Three elements: a panic button, an ESPN2 or similar and a wifi-based thermal printer.

Each time the button is pressed, the ESP32 should generate a qr code based on real-time data and other data from a config file. Then send the qr code to the printer.

A few constraints: all the components should be high grade, ready for 1000 tickets each day, operating 16 hours a day. Another constraint is that the pieces should fit in a plug and play configuration because I live 700km away from the shop.

I saw a few tutorials using breadboards, flying cables, powered by PC... but I need to start with something more industrial-grade.

What are you suggestions? Any recommended stuff to use?

Tia
 
Hi udg,

You can print QR codes with an ESP32 (NodeMCU or DevKit) and a thermal printer (even a cheap one like the MPT-II) that uses the Bluetooth Classic protocol (SPP - Serial Port Profile) and Richard Moore's QR Code library... however, there are Bluetooth printers already set up to print QR codes that you can manage via Bluetooth via an ESP32 such as the Epson TM-T20 or TM-m30 printer and also from other brands such as Citizen, Star Micronics, Niimbot and others...
​
 
Last edited:
Upvote 0
Thank you very much.
I worked with Epsom TM printer before so I know the escape sequences to use.

Can you recommend an external power supply 220V AC for the ESP32?
It could even be a standard converter like those used by smartphones for recharging but it should sustain 16 hours a day of operation.
Anyway a power supply that gives enough current for normal operation and leaks when using Bluetooth or wifi.

About the panic button I found a few models having a case where in theory there's enough space to host the ESP32 inside.

As said I have to put together a simple but dependable solution for a friend. Locally they should be able to plug and play any item and eventually substitute it if working had or not at all.

Software should be not a great problem, I guess.

Tia
 
Upvote 0
Thank you very much.
I worked with Epsom TM printer before so I know the escape sequences to use.

Can you recommend an external power supply 220V AC for the ESP32?
It could even be a standard converter like those used by smartphones for recharging but it should sustain 16 hours a day of operation.
Anyway a power supply that gives enough current for normal operation and leaks when using Bluetooth or wifi.

About the panic button I found a few models having a case where in theory there's enough space to host the ESP32 inside.

As said I have to put together a simple but dependable solution for a friend. Locally they should be able to plug and play any item and eventually substitute it if working had or not at all.

Software should be not a great problem, I guess.

Tia
...the most solid choice is an industrial-grade 5V AC-DC power supply rated at least 2A/3A, such as the Mean Well GST18E05-P1J which has an MTBF of around 700,000 hours, or something more industrial-grade, but always with adequate capacitive decoupling on the board where the ESP32 is housed... keep in mind that most ESP32 boards use a linear LDO voltage regulator (usually an AMS1117-3.3) which gets a bit too hot with frequent transmissions (WiFi and/or Bluetooth), so make sure there is good air circulation around the ESP32...​
 
  • Like
Reactions: udg
Upvote 0
Thanks. Based on the number of 1000 tickets in a day on 16 hours shift it leads to about one per minute... close to continuos operation.
Other equipment should be really heavy-duty type for this kind of work.
I have to ask better..
 
Upvote 0
I use an XIAO ESP32-C3 in almost all of my Bluetooth devices.
These devices are very durable and so small that they fit anywhere.
You can use any cell phone charger with a USB-C port as a power source.
 
Upvote 0
Thank you Filippo.
So you would use a phone charger for continuos power and the proper IN port to let the button signal a press so the SW could create and send the qr code. Everything so small to easily fit in the same box of the large button with plenty of circulating air.
One question: does it have a RTC real time clock? I need to know date and time of button pressing with good precision, although not absolute.
 
Upvote 0
Stabilized current ist important for Most modern devices.
5V only, but this must be stable without ups and downs
 
Upvote 0
"One question: does it have a RTC real time clock? I need to know date and time of button pressing with good precision, although not absolute."

Will it be in situation where there is a wifi network?
If so you can use NTP:

Code: Copy
#if C
#include <WiFi.h>
#include "esp_wifi.h"
#include "sntp.h"
#include <time.h>

TFT_eSPI tft = TFT_eSPI();

void ConfigNTP(B4R::Object* o) {
    esp_wifi_set_ps(WIFI_PS_NONE);
    configTime(-18000, 0, "pool.ntp.org", "time.nist.gov");
}

B4R::Object* GetEpoch(B4R::Object* o) {
    time_t now;
    time(&now);
 
    static B4R::Object ret;
   
    if (now < 1767225600) {
        return ret.wrapNumber((ULong)0);
    }
   
    return ret.wrapNumber((ULong)now);
}

void FormatDateTime(B4R::Object* o) {
    time_t now;
    time(&now);
    char* dest = (char*)b4r_main::_text2draw->data;
   
    if (now >= 1767225600) {
        struct tm* timeinfo = localtime(&now);
        strftime(dest, 100, "%Y-%m-%d %H:%M:%S", timeinfo);
    } else {
        dest[0] = 0;
    }
}

#End If
 
  • Like
Reactions: udg
Upvote 0
"Based on the number of 1000 tickets in a day on 16 hours shift it leads to about one per minute... close to continuous operation."

Once per minute is not really continuous for an ESP. 1 minute is 60 seconds = 60000 msec and the CPU speed of the ESP is 240,000 clock cycles per millisecond.

That work load is well within the capacity of the ESP32.

You don't need a lot of amperes to communicate by Bluetooth to the printer, but you do need a continuous power source: standard USB wall puck.
And the printer need its own continuous power source.
 
Last edited:
Upvote 0
The Epson TM-T20 receipt printer runs on 100–240V AC (50/60 Hz) wall power and operates internally at 24V DC.
So two 220AC wall plugs: one for ESP/Button and one for printer.

I like the idea of a large Red Button in a compact heavy duty enclosure (with heat dissipation), that sends to the printer messages via Bluetooth to the printer.

The original Epson TM-T20 does not have built-in Bluetooth, though specific configurations of the newer Epson TM-T20II (such as the TM-T20IIm) offer Bluetooth 2.1.
 
Last edited:
  • Like
Reactions: udg
Upvote 0
I have been working on a B4R project, and I am trying to train Gemini to write B4R code. It does, but it makes repeated syntax errors that it says won't happen again.
On the other hand it seems to know everything about electronics, components, wiring, logic, and overall project goals - recommended and is free.
It has been a real learning experience for me.
 
Upvote 0
Gemini as a teacher..I have to try it.
Surely it knows much better than me.
And the Internet has plenty of videos so there is good chances to avoid big errors 😀
 
Upvote 0
Back
Top