Close
0%
0%

ESP8266 Driving an ebay TM1638 Button/7seg display

Drive an elcheapo TM1638 display unit using an ESP8266

Similar projects worth following
This project seeks to drive a elcheap TM1638 based display/button unit from an ESP8266. The intention is to create an awesome remote control - or a remote display unit for very little money.

I'm going to use the details section to contain the code used

There are three main modules, and these are all placed in the standard user directory that the ESP 8266 SDK uses for building code.

tm1638.h

#include "c_types.h"
#include "user_interface.h"
#include "ets_sys.h"
#include "gpio.h"

//You will have to     os_intr_lock();      os_intr_unlock();

void tm1638OutBuffer( uint8_t * buffer, uint16_t length );
void tm1638OutByte( uint8_t data );


// 7 segment BITMAP for hex numbers
const uint16_t NUMBER_FONT[] = {
  0b00111111, // 0
  0b00000110, // 1
  0b01011011, // 2
  0b01001111, // 3
  0b01100110, // 4
  0b01101101, // 5
  0b01111101, // 6
  0b00000111, // 7
  0b01111111, // 8
  0b01101111, // 9
  0b01110111, // A
  0b01111100, // B
  0b00111001, // C
  0b01011110, // D
  0b01111001, // E
  0b01110001  // F
};

const uint16_t MINUS = 0b01000000;

// Bitmap for an Error String
const uint16_t  ERROR_DATA[] = {
  0b01111001, // E
  0b01010000, // r
  0b01010000, // r
  0b01011100, // o
  0b01010000, // r
  0,
  0,
  0
};

// 7 Segment Bitmap for the ASCI Character set..  Note that this starts at ascii position 32, but 
// the array starts at 0 so you need to subtract the difference from the key.
const uint16_t FONT_DEFAULT[] = {
  0b00000000, // (32)  <space>
  0b10000110, // (33)    !
  0b00100010, // (34)    "
  0b01111110, // (35)    #
  0b01101101, // (36)    $
  0b00000000, // (37)    %
  0b00000000, // (38)    &
  0b00000010, // (39)    '
  0b00110000, // (40)    (
  0b00000110, // (41)    )
  0b01100011, // (42)    *
  0b00000000, // (43)    +
  0b00000100, // (44)    ,
  0b01000000, // (45)    -
  0b10000000, // (46)    .
  0b01010010, // (47)    /
  0b00111111, // (48)    0
  0b00000110, // (49)    1
  0b01011011, // (50)    2
  0b01001111, // (51)    3
  0b01100110, // (52)    4
  0b01101101, // (53)    5
  0b01111101, // (54)    6
  0b00100111, // (55)    7
  0b01111111, // (56)    8
  0b01101111, // (57)    9
  0b00000000, // (58)    :
  0b00000000, // (59)    ;
  0b00000000, // (60)    <
  0b01001000, // (61)    =
  0b00000000, // (62)    >
  0b01010011, // (63)    ?
  0b01011111, // (64)    @
  0b01110111, // (65)    A
  0b01111111, // (66)    B
  0b00111001, // (67)    C
  0b00111111, // (68)    D
  0b01111001, // (69)    E
  0b01110001, // (70)    F
  0b00111101, // (71)    G
  0b01110110, // (72)    H
  0b00000110, // (73)    I
  0b00011111, // (74)    J
  0b01101001, // (75)    K
  0b00111000, // (76)    L
  0b00010101, // (77)    M
  0b00110111, // (78)    N
  0b00111111, // (79)    O
  0b01110011, // (80)    P
  0b01100111, // (81)    Q
  0b00110001, // (82)    R
  0b01101101, // (83)    S
  0b01111000, // (84)    T
  0b00111110, // (85)    U
  0b00101010, // (86)    V
  0b00011101, // (87)    W
  0b01110110, // (88)    X
  0b01101110, // (89)    Y
  0b01011011, // (90)    Z
  0b00111001, // (91)    [
  0b01100100, // (92)    \ 
  0b00001111, // (93)    ]
  0b00000000, // (94)    ^
  0b00001000, // (95)    _
  0b00100000, // (96)    `
  0b01011111, // (97)    a
  0b01111100, // (98)    b
  0b01011000, // (99)    c
  0b01011110, // (100)    d
  0b01111011, // (101)    e
  0b00110001, // (102)    f
  0b01101111, // (103)    g
  0b01110100, // (104)    h
  0b00000100, // (105)    i
  0b00001110, // (106)    j
  0b01110101, // (107)    k
  0b00110000, // (108)    l
  0b01010101, // (109)    m
  0b01010100, // (110)    n
  0b01011100, // (111)    o
  0b01110011, // (112)    p
  0b01100111, // (113)    q
  0b01010000, // (114)    r
  0b01101101, // (115)    s
  0b01111000, // (116)    t
  0b00011100, // (117)    u
  0b00101010, // (118)    v
  0b00011101, // (119)    w
  0b01110110, // (120)    x
  0b01101110, // (121)    y
  0b01000111, // (122)    z
  0b01000110, // (123)    {
  0b00000110, // (124)    |
  0b01110000, // (125)    }
  0b00000001, // (126)    ~
};

tm1636.c

#include "tm1638.h"
#include "ets_sys.h"

#include "osapi.h"

// These defines create simple shortcuts to switching IO pins on and off.
#define Set16_1 gpio_output_set(BIT16, 0, BIT16, 0);
#define Set16_0 gpio_output_set(0, BIT16, BIT16, 0);
#define Set14_1 gpio_output_set(BIT14, 0, BIT14, 0);
#define Set14_0 gpio_output_set(0, BIT14, BIT14, 0);
#define Set13_1 gpio_output_set(BIT13, 0, BIT13, 0);
#define Set13_0 gpio_output_set(0, BIT13, BIT13, 0);
#define Set12_1 gpio_output_set(BIT12, 0, BIT12, 0);  // STR
#define Set12_0 gpio_output_set(0, BIT12,...
Read more »

  • 1 × ESP-07 - ESP8266 PCB ORdered from Ebay - ESP-07 as it has an exterman antenna option and all pins borken out.
  • 1 × ES Breakout Board Bough a breakout board for the ESP series with 2mm pin spacing - I prefer to use 0.1"" dupont headters so this makes it easier to connect to
  • 1 × Power Supply 5v 3.3v Breadboard supply
  • 1 × Custom made programmer for ESP -01 and ESP-07 devices Custom made - but really simple - just has push buttons and resistors to allow for reset and program.
  • 1 × USB to TTL Serial I use an FTDI board - but that was bought before they assassinated peoples devices...

View all 6 components

  • 1
    Step 1

    The complexity in the project was not the hardware - although it was a learning experience with the ESP-07 as to what to pull up or down etc.

    Assemble the programming wiring loom

    ESP-07 Pinout (Connector 1 LHS)

    1. RESET - Pullup to VCC using a resistor - Push button shorts to GND to reset the device
    2. ADC
    3. CH_PD - Pullup to VCC using a resistor
    4. GPIO 16
    5. GPIO 14 - Connect to DATA on the TM1638 unit
    6. GPIO 12 - Connect to CLOCK on the TM1638 unit
    7. GPIO 13 - Connect to STROBE on the TM1638 unit
    8. VCC - Connect to VCC 3.3v

    ESP-07 Pinout (Connector 2 RHS)

    1. TXD - Connect to RXD on the FTDI chip
    2. RXD - Connect to TXD on the FTDI chip
    3. GPIO4
    4. GPIO5
    5. GPIO0 - Push Button connects to GND to start program mode
    6. GPIO2
    7. GPIO15
    8. GND - Connect to GND

    There are many example circuits out there, search via google.

    My programming loom looks like this:

  • 2
    Step 2

    Assemble the run time wiring loom

    Once you have programmed and tested the setup then you can simplify the setup with a run time loom. this removes the FTDI and program connections and is much simpler than the programming loom. The two connectors on the left connect to the ESP breakout pins. The top right hand connector connects to the TM1638 display module. The two connectors at the bottom go to the power supply.

    TM 1638 Display Pinout

    1. VCC
    2. GND
    3. STB
    4. CLK
    5. DIO

  • 3
    Step 3

    Connect it all up to start testing - The programming loom is shown here:

View all 6 instructions

Enjoy this project?

Share

Discussions

zpekic wrote 10/23/2021 at 15:58 point

I wish I had found this project earlier, my FPGA implementation would have been easier :-) https://hackaday.io/project/182073-tm-1638-as-8-bit-memory-device-in-vhdl

  Are you sure? yes | no

[deleted]

[this comment has been deleted]

Alex wrote 05/30/2016 at 14:18 point

stop spamming'!

  Are you sure? yes | no

stuart goggin wrote 03/25/2015 at 02:46 point

I should mention that the bitmaps for the 7 seg displays ASCII conversion was inspired by https://code.google.com/p/tm1638-library/

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates