Skip to main content

My first hands-on night light hat for Raspberry Pi EP 0098

Hi everyone, here is the night light hat for Raspberry Pi EP-0098 from 52PI. This night light hat is an add on that gives the Raspberry Pi colourful LEDs creating a nice warm glow.

This night light hat is simple and ready to use. The hat comes with the sample code in three formats, including Java, python, and c++.

Inside the box, there is one night light hat board for Raspberry Pi, one acrylic holder, four acrylic boards, four long screws, four short screws, and four copper spacers.

20190927_151122_e9da3862c692f399c43ca9aab985b85261ced062.jpg

The LEDs and the acrylic holder:

20190927_151131_4c4babbdd371704cff8da36b31555cb220d0758a.jpg

Use the long screw and copper spacers to fix the night light hat board and the acrylic holder.

20190927_151144_efa7057715ee1827a3d536fc67fdf95c018a2397.jpg

Finish as below.

20190927_151212_8afb9b98c481852a6a6dbc99123d95ea2712b135.jpg

Put the night light hat board on the Raspberry Pi.

20190927_151343_864846bf6eb0e3e785e4abcc60072709c48a1bd2.jpg

Add force to combine them.

20190927_151357_b5b081e63d5e76ca6c3a3e6df4675ed30537585e.jpg

Use the short screw to fix the Raspberry Pi and the night light hat board. 

20190927_151410_0dc30b24305e2fa123cda7f070c6453f81cd55cc.jpg

Finish as below.

20190927_151449_caada3a0288878788ec8f0e463f77ca89a1565f2.jpg

Remove the protective plastic from the acrylic boards.

20190927_151913_1a9aec6515971350f1a44236784cbddf8f6acc41.jpg

Insert the acrylic board inside the acrylic board holder.

20190927_151657_ff3b0dd07dec0c3086264649fd6a829c5e478376.jpg

Finish as below.

20190927_152407_b2d7cf6a0d3545607265e5e846bf2582b0a85819.jpg

Let's move on to the programming.

This Python program is using the I2C method to turn on and off the LEDs.

The register map table helps you manage the LED colour and position which are pre-defined.

registor_ca308fbe966c405d6862d261b49f4d543525d722.jpg

I named the program below as ep0098.py on desktop.

import time as t
import smbus
import sys

DEVICE_BUS = 1
DEVICE_ADDR = 0x15
bus = smbus.SMBus(DEVICE_BUS)

while True:
    try:
        #check the table (Register map) from
        #https://wiki.52pi.com/index.php/NightLight_Hat_Board_For_Raspberry_Pi_SKU:_EP-0098
        for i in range(1,25):
            #turn on light from the first lightand so on.
            bus.write_byte_data(DEVICE_ADDR, i, 0xFF)
            #turn off the light of the first light and so on.
            bus.write_byte_data(DEVICE_ADDR, 26 - i, 0xFF)
            #delay 0.2 s
            t.sleep(0.2)
            #turn on the light of the last light and so on.
            bus.write_byte_data(DEVICE_ADDR, i, 0x00)
            #turn off the light of the last light and so on.
            bus.write_byte_data(DEVICE_ADDR, 26 - i, 0x00)
            #delay 0.2 s
            t.sleep(0.2)
            
    except KeyboardInterrupt as e:#type e to stop the programe
        sys.exit()
        print("Quit the Loop")

2_98f1655d4815a1f1cdd1284f7619ba983f04f25b.jpg

It is a must-have gadget for an old Raspberry Pi since Raspberry Pi 4 has been released, some Pi 3 will be left behind, so it is a great use for your old Raspberry Pi.

If you want to plug in and play the night light hat board, you may follow the steps below to autorun the script when you power up the Raspberry Pi.

First, open the terminal and type sudo nano /etc/rc.local

_2019-10-04_上午11.28_.24__fbe58d7097b71f690bf45e73e80ea83830429da1.png

Then type python3 /home/pi/Desktop/ep0098.py

_2019-10-04_上午11.28_.06__dd556b6966b7aac6b224862fa07670ccf1b88d2e.png

Then press ctrl + X

Enjoy~~~~~~

Result:

Dual light:

Brian0925 has not written a bio yet…