Marcin Saj
Published © CC BY

Nixie Tube Shield / HAT for Raspberry Pi

The Nixie HAT allows an Raspberry Pi board to connect any Nixie tube you want to use in your projects.

IntermediateFull instructions provided2 hours5,484

Things used in this project

Story

Read more

Schematics

Nixie-Shield-Hat-for-Raspberry-Pi-Schematic

Nixie-Tube-Socket-Schematic

Code

Raspberry-Nixie-Shield-Basic-Example

Python
'''
Raspberry Nixie Shield Python Basic Example
The Nixie Shield is compatible with Raspberry Pi: 1B+, 2B, 3B, ZERO, ZERO W.
This example shows how to control any nixie tube with a Raspberry Pi using Nixie Shield
Nixie Shield uses five digital outputs to drive nixie tube. 
Pin 29 as on/off (EN) line, 31, 33, 35, 37 as an address (A, B, C, D) of nixie tube digit/cathode.
This example code is in the public domain.
https://www.nixietester.com
'''
import time                 # Import time module
import RPi.GPIO as GPIO     # Import RPi.GPIO module as just GPIO

GPIO.setmode(GPIO.BOARD)    # Declare the type of GPIO numbering system
GPIO.setwarnings(False)     # Disable warnings

# Pin definitions / Nixie tube digit address:
EN = 29                     # On/Off Nixie tube
A = 37      
B = 33
C = 31
D = 35

GPIO.setup(EN,GPIO.OUT)     # Set up a channel EN as an output
GPIO.setup(A,GPIO.OUT)      # Set up a channel A as an output
GPIO.setup(B,GPIO.OUT)      # Set up a channel B as an output
GPIO.setup(C,GPIO.OUT)      # Set up a channel C as an output
GPIO.setup(D,GPIO.OUT)      # Set up a channel D as an output

GPIO.output(EN,GPIO.LOW)    # Turn on the Nixie Tube

# set address of the tube cathode '0':
                            #   ___ 
GPIO.output(A,GPIO.LOW)     #  |   |
GPIO.output(B,GPIO.LOW)     #  |   |
GPIO.output(C,GPIO.LOW)     #  |   |
GPIO.output(D,GPIO.LOW)     #  |___|
time.sleep(1)

# set address of the tube cathode '1':

GPIO.output(A,GPIO.HIGH)    #   /|  
GPIO.output(B,GPIO.LOW)     #  / |
GPIO.output(C,GPIO.LOW)     #    |
GPIO.output(D,GPIO.LOW)     #    |
time.sleep(1)

# set address of the tube cathode '2':
                            #   ___ 
GPIO.output(A,GPIO.LOW)     #      |   
GPIO.output(B,GPIO.HIGH)    #   ___|   
GPIO.output(C,GPIO.LOW)     #  |  
GPIO.output(D,GPIO.LOW)     #  |___
time.sleep(1)

# set address of the tube cathode '3':
                            #   ___ 
GPIO.output(A,GPIO.HIGH)    #      |   
GPIO.output(B,GPIO.HIGH)    #   ___|   
GPIO.output(C,GPIO.LOW)     #      |  
GPIO.output(D,GPIO.LOW)     #   ___|
time.sleep(1)

# set address of the tube cathode '4':

GPIO.output(A,GPIO.LOW)     #  |   | 
GPIO.output(B,GPIO.LOW)     #  |___|   
GPIO.output(C,GPIO.HIGH)    #      |  
GPIO.output(D,GPIO.LOW)     #      |
time.sleep(1)

# set address of the tube cathode '5':
                            #   ___ 
GPIO.output(A,GPIO.HIGH)    #  |      
GPIO.output(B,GPIO.LOW)     #  |___   
GPIO.output(C,GPIO.HIGH)    #      |  
GPIO.output(D,GPIO.LOW)     #   ___|
time.sleep(1)

# set address of the tube cathode '6':
                            #   ___ 
GPIO.output(A,GPIO.LOW)     #  |      
GPIO.output(B,GPIO.HIGH)    #  |___   
GPIO.output(C,GPIO.HIGH)    #  |   |  
GPIO.output(D,GPIO.LOW)     #  |___|
time.sleep(1)

# set address of the tube cathode '7':
                            #   ___
GPIO.output(A,GPIO.HIGH)    #      |   
GPIO.output(B,GPIO.HIGH)    #      |   
GPIO.output(C,GPIO.HIGH)    #      |  
GPIO.output(D,GPIO.LOW)     #      |
time.sleep(1)

# set address of the tube cathode '8':
                            #   ___ 
GPIO.output(A,GPIO.LOW)     #  |   |   
GPIO.output(B,GPIO.LOW)     #  |___|   
GPIO.output(C,GPIO.LOW)     #  |   |  
GPIO.output(D,GPIO.HIGH)    #  |___|
time.sleep(1)

# set address of the tube cathode '9':
                            #   ___ 
GPIO.output(A,GPIO.HIGH)    #  |   |   
GPIO.output(B,GPIO.LOW)     #  |___|   
GPIO.output(C,GPIO.LOW)     #      |  
GPIO.output(D,GPIO.HIGH)    #   ___|
time.sleep(1)

GPIO.output(EN,GPIO.HIGH)   # Turn off the Nixie Tube
time.sleep(1)

GPIO.cleanup()              # Cleanup GPIO on exit 

Raspberry-Nixie-Shield-Basic-Example-2

Python
'''
Raspberry Nixie Shield Basic Example 2 
This example shows how to control a nixie tube with a Raspberry Pi using Nixie Shield
An example of using a state array and for loop
Nixie Shield uses five digital outputs to drive nixie tube 
Pin 29 as on/off (EN) line, 31, 33, 35, 37 as an address (A, B, C, D) of nixie tube digit/cathode
This example code is in the public domain
https://www.nixietester.com
'''
import time                   # Import time module
import RPi.GPIO as GPIO       # Import RPi.GPIO module as just GPIO

GPIO.setmode(GPIO.BOARD)      # Declare the type of GPIO numbering system
GPIO.setwarnings(False)       # Disable warnings

# Pin definitions / Nixie tube digit address:
EN = 29                       # On/Off Nixie tube
A = 37      
B = 33
C = 31
D = 35

# Pin assignments: 35, 31, 33, 37
address = [D, C, B, A]

# Pattern table for 10 digits
digit = [(0, 0, 0, 0), # '0'
         (0, 0, 0, 1), # '1'
         (0, 0, 1, 0), # '2'
         (0, 0, 1, 1), # '3'
         (0, 1, 0, 0), # '4'
         (0, 1, 0, 1), # '5'
         (0, 1, 1, 0), # '6'
         (0, 1, 1, 1), # '7'
         (1, 0, 0, 0), # '8'
         (1, 0, 0, 1)] # '9'

#Setup pins as an outputs, initially low
GPIO.setup(EN,GPIO.OUT, initial=0) 
GPIO.setup(address, GPIO.OUT, initial=0)

GPIO.output(EN,GPIO.LOW)      # Turn on the Nixie Tube
 
for d in range(10):
    GPIO.output(address, digit[d])
    time.sleep(1)
    
GPIO.output(EN,GPIO.HIGH)     # Turn off the Nixie Tube
GPIO.cleanup()

Raspberry-Nixie-Shield-Nixie-Clock

Python
'''
Raspberry Nixie Shield - Nixie Clock 
This example shows how to display time on the nixie tube using Nixie Shield with the Raspberry Pi
Nixie Shield uses five digital outputs to drive nixie tube 
Pin 29 as on/off (EN) line, 31, 33, 35, 37 as an address (A, B, C, D) of nixie tube digit/cathode
This example code is in the public domain
https://www.nixietester.com
'''
import time                   # Import time module
import RPi.GPIO as GPIO       # Import RPi.GPIO module as just GPIO

GPIO.setmode(GPIO.BOARD)      # Declare the type of GPIO numbering system
GPIO.setwarnings(False)       # Disable warnings

# Pin definitions / Nixie tube digit address:
EN = 29                       # On/Off Nixie tube
A = 37      
B = 33
C = 31
D = 35

# Pin assignments: 35, 31, 33, 37
address = [D, C, B, A]

# Pattern table for 10 digits
digit = [(0, 0, 0, 0), # '0'
         (0, 0, 0, 1), # '1'
         (0, 0, 1, 0), # '2'
         (0, 0, 1, 1), # '3'
         (0, 1, 0, 0), # '4'
         (0, 1, 0, 1), # '5'
         (0, 1, 1, 0), # '6'
         (0, 1, 1, 1), # '7'
         (1, 0, 0, 0), # '8'
         (1, 0, 0, 1)] # '9'

#Setup pins as an outputs, initially low
GPIO.setup(EN,GPIO.OUT, initial=0) 
GPIO.setup(address, GPIO.OUT, initial=0)

while True:
    # Get current local time
    nixietime = time.strftime("%H%M")   
        
    # Display each digit in local time string
    for d in range(4):
        # Lookup each digit in time string and output corresponding pattern
        GPIO.output(address, digit[int(nixietime[d])])
        GPIO.output(EN,GPIO.LOW)  # Turn on the Nixie tube
        time.sleep(0.500)
        GPIO.output(EN,GPIO.HIGH) # Turn off the Nixie tube
        
        if d == 1:                
            time.sleep(1)         # Wait longer between displaying hours and minutes
        else:
            time.sleep(0.500)        
        
    time.sleep(1.500)             # Wait and repeate
        
GPIO.cleanup()

Credits

Marcin Saj

Marcin Saj

2 projects • 5 followers
I'm a DIY designer, I specialize in designing kits for self assembly. I make a toys for hobbyists and geeks. I hope you will enjoy my work.
Contact

Comments