Tag Archives: Neopixel

Temperature Controlled Stair lights With Raspberry Pi

Ever wished to know the temperature on your way to breakfast after waking up in the morning? Now you can find it out in a fascinating way as Lorraine Underwood at The MagPi magazine designed a temperature controlled colorful stair lights system with raspberry pi. In this tutorial, we’re going to discuss that project.

Temperature Controlled Stair Lights
Temperature Controlled Stair Lights

Required Parts

  • Strip of 50 neopixels
  • A 5V power source for the lights
  • 2 x terminal blocks
  • 2 x male to female jumper cables
  • A raspberry pi zero with SD card with Raspian installed
  • Power supply for the Pi zero (temporary)

 

Make sure that the raspberry pi power supply gives exactly 5 volts and is capable of outputting 2.5A current.

Make The Circuit

At first, examine your LED strip and find out which pin is what. Connect two wires to GND, one wire to Din, and one wire to +5V pin. Now, connect the 5V pin to the “+” terminal of the female jack and GND pin to the “-” terminal. Tighten the screws of the terminal block to ensure that the wires are connected properly.

Connect the Din and GND pin of the LEDstrip to the GPIO 18 and GND of the Raspberry Pi respectively, using the male-to-female jumper wires. Please note that Broadcom numbering (BCM) is used in this tutorial, not the physical numbering. It will look like below after making the connections:

Connecting Wires To The LED Strip
Connecting Wires To The LED Strip

Set Up The Weather API

You need to set up a weather API in order to get the outside temperature in your area. In this tutorial, forecast.io is used as they allow you to make 1000 queries per day free of cost. Go to forecast.io and select Developer option. Then, click sign up to create a developer account and provide your email address. A secret key will be sent to that address. Store it securely as you’ll need in the next step.

Prepare The Raspberry Pi

At first, you need to install the Adafruit NeoPixel library rpi_ws281x. Go here and follow the instructions to install the required files on your raspberry pi. Once installed, navigate to the examples folder, run any script you wish, and check if the LED strip is functioning properly.

Now, save the below script as stair_lights.py in the Raspberry Pi:

#!/usr/bin/python3
from urllib.request import urlopen
import json
import time
from neopixel import *

apikey="get_your_own_key" # get a key from https://developer.forecast.io/register
# Latitude & longitude - current values are Lancaster University
lati="54.005546"
longi="-2.784876"

LED_COUNT = 50 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (must support PWM!).
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
LED_DMA = 5 # DMA channel to use for generating signal (try 5)
LED_BRIGHTNESS = 8 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)

def color(strip, color, start, end): 
 for i in range(start, end+1):
 strip.setPixelColor(i, color)
 strip.show() 
 
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS)
strip.begin()

count = 0
try:
 while True: 
 #get the data from the api website
 url="https://api.forecast.io/forecast/"+apikey+"/"+lati+","+longi+"?units=si"
 meteo=urlopen(url).read()
 meteo = meteo.decode('utf-8')
 weather = json.loads(meteo)

currentTemp = weather['currently']['temperature']

#negative number will always be on 
 color(strip, Color(0, 0, 255), 0,7) # Blue
 
 #what's the temp?
 if currentTemp > 0:
 color(strip, Color(75, 75, 255), 8, 15) # light Blue
 if currentTemp > 5:
 color(strip, Color(0, 255, 0), 16, 23) # dark Green
 if currentTemp > 10:
 color(strip, Color(75, 255, 75), 24, 31) # light Green
 if currentTemp > 15:
 color(strip, Color(255, 100, 0), 32, 39) # yellow 
 elif currentTemp > 20:
 color(strip, Color(255, 50, 0), 40, 47) #orange 
 elif currentTemp > 25:
 color(strip, Color(255, 0, 0), 48, 50) # Red 
 #check every 5 minutes (change to crontab)
 time.sleep(300)
 
except KeyboardInterrupt:
 print("Exit")
 color(strip, Color(0,0,0), 0, 49)

Enter your own secret key in the apikey field on the 7th line. Also, replace the longitude and latitude values on line 9 and 10 with the coordinates of your area. Now save the file and you are almost done.

To start the script automatically after each reboot and check the outside temperature every five minutes, set up a cron task by entering the following command:

sudoE crontab -e

A file will be opened and add the following lines at the end of the file:

*/5 * * * * /usr/bin/python3 /home/pi/stair_lights.py
@reboot /usr/bin/python3 /home/pi/stair_lights.py

Save the file and exit.

The Color Scheme

The following table shows which color represents which temperature range. You can modify the script to change the current color scheme.

Temperature (°C) Lights (Nos) Color
 0 – 4  9 – 16 Light Blue
 5 – 9 17 – 24 Dark Green
 10 – 14 25 – 32 Light Green
 15 – 19 33 – 40 Yellow
 19 – 24  41 – 48 Orange
 25+  48 – 50 Red

 

A Christmas star with Neopixel LEDs

A geeky Christmas decoration made with 56 LED Neopixel and controlled via an Arduino Micro board:

Let’s take a look, therefore, at the project’s electrical section, that is essentially composed of a set of 56 Neopixel LEDs, that have been arranged so to form two concentric stars; the first 35 RGB LEDs (out of 56) form the bigger, external star, while the other 20 ones form the smaller and internal star. The LED number 56 is placed exactly at the center of the printed circuit board, that has the shape of a five-pointed star.
The Neopixel LEDs are connected in cascade but powered in parallel; such a configuration enables to address each single LED and to individually choose the colour; among the possible hues, the 256 possible combinations for each primary colour (therefore we have 256x256x256 combinations!) determine a total of 16,777,216 colours: that’s what one would call true colours!

A Christmas star with Neopixel LEDs – [Link]

Neopixel Night Light using ATtiny85

F3I7FQEIQJGB80A.MEDIUM

joshua.brooks @ instructables.com describes how he build a night light using an Adafruit NeoPixel, ATtiny85 microcontroller, TSSP4038 IR receiver and some other easy available components.

I’m giving some workshops in electronics in a few weeks, centered around an inexpensive, but useful real-world project. When trying to come up with a thing to make, I wanted it to involve a microcontroller, NeoPixel LEDs (because, they’re awesome), be remotely controllable, and allow for different build options. It also had to be fully simulatable in Autodesk Circuits. This is the project that evolved.

Neopixel Night Light using ATtiny85 – [Link]

Temperature Display with NeoPixel Ring Color

3637311436166764209

This is an OLED temperature display based on ATmega328p along with a NeoPixel led ring to display different colors depending on temperature.

This is a small temperature display using a OLED with a NeoPixel Ring around it using MQTT on a ESP8266 and sending data to the on board ATmega328p. It will cycle on a timer though environmental data from other nodes in the house. The LEDs represents the temperature based on color to give an idea of the temperature in the home or apartment I also added a PIR to turn off the LEDs when no one is around since this is designed to run off a LiPo battery. The core is running DomotiGA (Home automation core) and Mosquitto (MQTT broker). Part of this project is exploring the ESP8266 and learning MQTT.

Temperature Display with NeoPixel Ring Color – [Link]

RGB LED Strip Controller

NewImage-20

Thomas Gonnot has published a RGB LED Strip Controller based  on STM32F0 microcontroller. The controller is able to power NeoPixel and DotStar protocol RGB LEDs.

A simple controller for a RGB LED strip, with independent control of color and intensity.

The design is based on a simple STM32F0 microcontroller. It can handle NeoPixel and DotStar protocols, and the power supply can vary from 5V to 15V.

Firmware available at https://github.com/fearedspark/RGB_LED_Strip_Controller

OSH park permalink: https://oshpark.com/shared_projects/Fg2xQq0t

RGB LED Strip Controller – [Link]

 

WifiPixels – ESP8266 Wifi unit combined with a NeoPixel

800px-WifiPixels_Top

WifiPixels are a combination of a ESP8266 Wifi unit combined with a NeoPixel(Addressable RGB) LED ring all in one. http://wiki.protoneer.co.nz/WifiPixels Video here.

WifiPixels – ESP8266 Wifi unit combined with a NeoPixel – [Link]