MAXIMIZE THE CAPABILITIES OF ESP-01 ESP8266

11,331

81

14

Introduction: MAXIMIZE THE CAPABILITIES OF ESP-01 ESP8266

About: PLC, Arduino - Do it yourself project

ESP-01 ESP8266 is a popular and widely used module because of its low-cost, reliability and easily availability in the market. It can be used as a stand-alone device or connected with a microcontroller. The ESP-01 is the smallest ESP8266 module and it has limited I/Os. It has totally 8 pins, four of them are needed for module operation (VCC, GND, RST and CH_PD), and remaining four pins (GPIO0, GPIO2, TX and RX) can be used as programmable GPIOs pins but even they have pre-assigned functions as follows:

  • The GPIO0 and GPIO2 check & determine which mode that the ESP8266 needs to enter when ESP8266-01 booting up. During the normal operating mode, the GPIO0 and GPIO2 will be high, and grounding GPIO0 sets the chip to programming mode.
  • The TX/RX pins are used to program the module and for Serial I/O, commonly used for debugging.

I have referenced many articles on how to use these 4 pins on ESP-01 and realize that we can do a lot of things with only those 4 pins. Today, I'm willing to share how ESP-01 can be used as a stand-alone device to control a led matrix 13x15 and even at the same time it can get and show time information, weather information on this led matrix via WIFI.

Let’s getting started.

RGB LED CUBE 4x4x4 with ESP-01S ESP8266 (Update on June 16, 2020).

Step 1: THINGS WE NEED

ELECTRONIC COMPONENTS:

  • 200PCS X LED 3MM, BLUE COLOR IN MY CASE.
  • 02PCS X DOUBLE SIDE DIY PROTOBOARD CIRCUIT 7X9CM.
  • 01PCS X ESP-01 ESP8266.
  • 01PCS X AMS1117 3.3V POWER SUPPLY MODULE.
  • 02PCS X SHIFT REGISTER 74HC595.
  • 02PCS X POWER LOGIC 8-BIT SHIFT REGISTER TPIC6B595N.
  • 16PCS X TRANSISTOR A1013.
  • 16PCS X R100.
  • 20PCS X R1K.
  • 04PCS X CAPACITOR 1UF.
  • 02PCS X FEMALE 40PIN 2.54MM HEADER.
  • 02PCS X MALE 40PIN 2.54MM HEADER.
  • 01PCS X PUSH BUTTON.
  • 01PCS X SLIDE SWITCH.
  • 01PCS X 2PIN 5.08MM PITCH SCREW TERMINAL BLOCK.
  • 01METER X 8P RAINBOW RIBBON CABLE.

PROGRAMMING TOOL FOR ESP-01 ESP8266:

  • 01PCS X FTDI FT232RL USB TO TTL SERIAL ADAPTER.
  • 01PCS X USB CABLE MINI TYPE B TO TYPE A.

Step 2: SCHEMATIC

You can download the schematic in high resolution HERE, it includes:

1. LED MATRIX MODULE:

It includes 195 LEDs arranged in 13 ROWS and 15 COLUMNS. The reason is that my PROTOBOARD CIRCUIT 7X9CM can only fit this size even though my control board below can control led matrix module upto size 16x16.

2. CONTROL MODULE:

  • ROW SCANNING (TO LED ANODES): including 2pcs x 74HC595 + 13pcs x Transitor A1013. Outputs from PNP transistors A1013 are connected to 13 LED ROWS (ANODES), so the row needs to be HIGH for an individual LED to turn on. The PNP transistors A1013 can carry maximum collector current about 1A. If the row and column are either HIGH or LOW, no voltage flows through the LED and it doesn’t turn on.
  • COLUMN SCANNING (TO LED CATHODES): including 2pcs x TPIC6B595N Power Logic 8-Bit Shift Register. Outputs from TPIC6B595N are connected to 15 LED COLUMNS (CATHODES) through current limiting resistors R100, so a column needs to be LOW for any of the LEDs in that column to turn on. High power shift register TPIC6B595N is high power drains, able to sink 150mA per pin and it cannot source current so they should be connected to LED cathodes.
  • ESP-01 ESP8266 including modes slide switch, reset button, programming header and AMS1117 power module for converting from 5V to 3.3V.

The schematic below is shown how the ESP-01 can boot up in program mode and normal operation mode:

  • The button - S1 - is used to reset ESP-01.
  • The slide switch - S2 - allows switching between program and normal operation modes.
  • In normal operation mode, ESP-01 control 13xrows and 15xcolumns of led matrix by 4 GPIO pins as follows:

- BLANK PIN connecting to GPIO3 - RX

- LATCH PIN connecting to GPIO0

- CLOCK PIN connecting to GPIO2

- DATA PIN connecting to GPIO1 - TX

NOTES:

  • AMS1117 power module is used for supplying 3.3V to ESP-01.
  • All pull-up resistors are 10Kohm.
  • The 6 PIN FEMALE PROGRAMMING HEADER was soldered on control board. We can easily plug FTDI programmer into this header and switch S2 to GND position for uploading our program from Arduino IDE.

Step 3: SOLDERING

1. LED MATRIX MODULE:

You can check at my previous instructable to know how to solder the matrix 13x15: https://www.instructables.com/id/LED-MATRIX-SHIELD...

  • TOP VIEW

  • BOTTOM VIEW:

Take note that male headers for rows and columns of led module are soldered at bottom, it will be connected to control board.

2. CONTROL MODULE:

Soldering the control module following the schematic on previous step. You have to solder very carefully, it takes your time and your effort....

  • TOP VIEW

  • SIDE VIEW

  • BOTTOM VIEW

3. PLUG MATRIX MODULE ON TOP OF CONTROL MODULE

Finally, I plugged LED MODULE on top of CONTROL MODULE.

DONE!!!

Step 4: PROGRAMMING

In my program, ESP-01 ESP8266 is used as a stand-alone device. It gets and shows time information, weather information on led matrix 13x15 from NTP server and openweathermap. The project code is available at my GitHub.

CONNECTION

The ESP-01 ESP8266, 74HC595 & TPIC6B595N are connected together as follows:

LIBRARIES

// ESP-01 ESP8266 WiFi Main Library
#include <ESP8266WiFi.h>

// Libraries for Internet NTP Time
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <time.h>

// Libraries for Internet Weather
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>

LED MATRIX CONTROL

For row scanning (anodes), because my led matrix module has 13 rows, so we need to shift out 2 bytes to 2x74HC595 with order from 0 ~ 12, as anode array below.

byte anode[16][2]={
{B11111111, B11111110}, {B11111111, B11111101}, {B11111111, B11111011}, {B11111111, B11110111},
{B11111111, B11101111}, {B11111111, B11011111}, {B11111111, B10111111}, {B11111111, B01111111},
{B01111110, B11111111}, {B11111101, B11111111}, {B11111011, B11111111}, {B11110111, B11111111},
{B11101111, B11111111}, {B11011111, B11111111}, {B10111111, B11111111}, {B01111111, B11111111}
};

For example, if we want set row_0 to "ON", we will write to 2 x 74HC595 shift register the value: {B11111111, B11111110} with anode low byte B11111110 and anode high byte B11111111.

I also applied the B.A.M method in this program so I can easily adjust the brightness of led matrix.

void ICACHE_RAM_ATTR timer1_ISR(void)
{   
  digitalWrite(BLANK_Pin, HIGH);

  if(BAM_Counter==8)    // Bit weight 2^0 of BAM_Bit, lasting time = 8 ticks x interrupt interval time
  BAM_Bit++;
  else
  if(BAM_Counter==24)   // Bit weight 2^1 of BAM_Bit, lasting time = 24 ticks x interrupt interval time
  BAM_Bit++;
  else
  if(BAM_Counter==56)   // Bit weight 2^3 of BAM_Bit, lasting time = 56 ticks x interrupt interval time
  BAM_Bit++;
  BAM_Counter++;
  switch (BAM_Bit)
    {
    case 0: 
        DIY_SPI(matrixBuffer[0][level + 0]);
        DIY_SPI(matrixBuffer[0][level + 1]);
      break;
    case 1:      
        DIY_SPI(matrixBuffer[1][level + 0]);
        DIY_SPI(matrixBuffer[1][level + 1]);   
      break;
    case 2:     
        DIY_SPI(matrixBuffer[2][level + 0]);
        DIY_SPI(matrixBuffer[2][level + 1]);     
      break;
    case 3:
        DIY_SPI(matrixBuffer[3][level + 0]);
        DIY_SPI(matrixBuffer[3][level + 1]); 
             
    if(BAM_Counter==120)    //Bit weight 2^3 of BAM_Bit, lasting time = 120 ticks x interrupt interval time
    {
    BAM_Counter=0;
    BAM_Bit=0;
    }
    break;
  }
  // Row scanning low byte and high byte
  DIY_SPI(anode[row][0]);
  DIY_SPI(anode[row][1]);
  
  digitalWrite(LATCH_Pin, HIGH);
  //delayMicroseconds(2);
  digitalWrite(LATCH_Pin, LOW);
  //delayMicroseconds(2);
  digitalWrite(BLANK_Pin, LOW);
  
  row++;
  level = row * 2; 
  if (row == 13) row=0;
  if (level == 26) level=0;
  
  pinMode(BLANK_Pin, OUTPUT);
  timer1_write(500);
}

I referenced to original shiftOut() function in file "core_esp8266_wiring_shift.cpp" to create for my own SPI function. You can search this file on your computer or check at this LINK.

void __attribute__((optimize("O0"))) DIY_SPI(uint8_t DATA)
{
    uint8_t i;
    uint8_t val;
    for (i = 0; i<8; i++)  
    {
      digitalWrite(DATA_Pin, !!(DATA & (1 << (7 - i))));
      digitalWrite(CLOCK_Pin,HIGH);
      digitalWrite(CLOCK_Pin,LOW);                
    }
}

TIME INFORMATION

The led matrix displays time from NTP Time server by scrolling the messages, with with the following information:

  • Year, month, day.
  • Day of week.
  • Hour, minute, second.

WEATHER INFORMATION

The led matrix displays weather information with selected location from openweathermap by scrolling the messages:

  • Temperature in ˚C.
  • Humidity in %.
  • Pressure in hPa.
  • Wind speed in m/s.
  • Wind degree in ˚deg.

UPLOADING PROGRAM

Uploading the program by FTDI module and take notes:

  • In my program, you can see that GPIO0 of ESP-01 connect to LATCH PIN of 74HC595 & TPIC6B595N for latch function and it is set HIGH and LOW (GND) during this process. As far as my reference, there is no information about how long an interval we should set GPIO0 between the HIGH and LOW level to put ESP-01 into programming mode, but with my hardware and program code it works perfectly without any errors or interruptions. When I want to upload the program, I just simply switch "modes slide switch" to GND position (GPIO0 pull down to GND) and ensure the external power is supplied to ESP-01.
  • After uploading, switching slide switch to NORMAL operation and push RESET button.

NOTES:

In my program, I used wchar_t array to store time and weather information because it can be switched to my VietNamese. In my language, there are many special letters which can be processed by "wchar_t", such as: "", "", ""...

wchar_t YYYYMMDD[34];
wchar_t HHMMSS[32];
wchar_t WEATHER[106];

You can check my first testing as video below:

Step 5: FINISH

Actually, 3 pins of ESP-01 are enough to control a matrix led (LATCH PIN, CLOCK PIN, DATA PIN and BLANK PIN is connected to GND). So we still have one pin left for other applications.

According to my testing result, the ESP-01 ESP8266 can completely control a bigger led matrix or even a led cube and I should try to carry out this someday. (Update on June 16, 2020: ESP-01 with 10mm RGB led cube 4x4x4. It works perfectly).

Thank for your reading and hope you like my post!!!

Arduino Contest 2020

Participated in the
Arduino Contest 2020

Be the First to Share

    Recommendations

    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge
    • Space Contest

      Space Contest
    • Metal Contest

      Metal Contest

    14 Comments

    0
    BruceC94
    BruceC94

    Question 1 year ago

    Hi - I am proceeding to build this project. Thank you! However the schematic is hard to read. Can you post a higher-resolution schematic ? This would be VERY helpful! Thank you.

    0
    tuenhidiy
    tuenhidiy

    Answer 1 year ago

    Hi Bruce. You can download the schematic in high resolution *.PDF at STEP 2.

    0
    dleland71
    dleland71

    1 year ago

    Truly awesome build.Thanks! I'll work on one this winter.

    0
    BruceC94
    BruceC94

    Question 1 year ago

    Thanks for your previous reply. I see you have also designed the 8x8x8 RGB LED project and it says there is a kit for sale. But the old website LEDCube.com does not exist now. How can I buy this from you?

    0
    tuenhidiy
    tuenhidiy

    Answer 1 year ago

    Hi BruceC94,
    This site belongs to someone else I don't know. I did 8x8x8 RGB LED project long time ago for my hobbies, not for business. I'm sorry for that!

    0
    shukrhu
    shukrhu

    1 year ago

    Congratulate for your work and post! It is very nice!
    Just one correction regarding the transistors you have used to drive current on the Rows: They are PNP instead NPN as described on the text, which means that you need to drive than with "0" in order that they put "1" to LEDS's Rows ant make available to turn on with "0" on the Columns... Cheers, Gustavo

    0
    tuenhidiy
    tuenhidiy

    Reply 1 year ago

    Thank you, shukrhu! You're correct. I already fixed this mistake.

    0
    ardu11
    ardu11

    1 year ago

    I am retired... but in my active time, I would have contacted the author to hire him... The project has been intelligently conceived and conducted. That guy can be an excellent designer and product leader. I am impressed. Good job... (Very good job !)

    0
    tuenhidiy
    tuenhidiy

    Reply 1 year ago

    Hi Ardu11. Thank you so much for encouraging me! :-)

    0
    BruceC94
    BruceC94

    1 year ago

    We (especially my wife) love the 3D Cube and I'm looking through the description above... can you post the information on building the cube and integrating it with your design? (Or did I not read carefully enough?) . Thanks - outstanding, and very creative!

    0
    WJTaylor1020
    WJTaylor1020

    1 year ago on Step 5

    Hi tuenhidiy:
    This is a great way to expand the capabilities of the ESP-01 ESP8266. It took a lot of effort to plan and solder this project. Also, from the review of your earlier projects, you really love to make LED cubes and matrices. I would not have the time to set aside to do all that soldering.
    However, I wonder... you already have the great circuit diagram. So, why not make a PCB for the main board and a connector to an OLED or regular LED Display. It would save a lot of time & money. Thank you for the effort & hope you win the Arduino Contest!
    Sincerely,
    Joe

    0
    tuenhidiy
    tuenhidiy

    Reply 1 year ago

    Hi WJTaylor1020,
    Yes, I obsolutely agree with you. In future, I should consider to design a PCB and send to manufactures to do fabricating work.
    I have not much time for PCB design, place an order, waiting for shipping....Normally, I start to do the things that I have an idea in my mind and want to see final result right that time. By doing this way, I can complete my small DIY project within one day at weekend or 3 working days at night time.
    Day by day, soldering work seem like one of my hobbies and it's like being entertained after work :-).
    Thank you for being interest my project and your advice!