Showing posts with label Raspberry Pi. Show all posts
Showing posts with label Raspberry Pi. Show all posts

Thursday, September 6, 2018

KatLight - the wonderlamp



Into

For a very special woman, I needed a very special and unique present. Something really cool. How about a NeoPixel lamp, that can be controlled with a smartphone.
And why not adding some really funky features? Like turning the lamp on/off by the wave of your hand. And some nice animations. How about transmitting the temperature and humidity to your phone. And why not adding a scheduled sunrise, like the one from the sunrise simulator project? Too much? We'll see!

The Build


First of all I need a housing. I decided to use two old CD spindle boxes with different heights. The bigger one will house the Neopixels, the smaller one all the electronics. To make a little glow effect, I wanted to make the transparent plastic look like frosted glass. You can achieve it, by 'polishing' it on the inside with sandpaper. To mount the Nepixels I used a pump spray bottle, that I've cut into length. A lot of hot glue, some holes for the wires and it's a piece of cake.

Video

 

 

Problems

Problem 1: APDS 9960

As soon as the APDS 9960 gesture sensor starts working it blocks the processing of the microcontroller as it tries to check for a gesture. This leads to the stage that the animations stopped working smoothly.
So I outsourced the gesture readings to an Arduino Nano. It communicates with the NodeMcu via three digital pins. I made my own small 'protocol'. By setting the pins to HIGH/LOW I can transmit eight different sensor states.

Problem 2: BME 280

The temperature sensor doesn't want to initialize with the begin()-function of the library.
I uploaded a I2C-scanner and checked for the I2C address. I searched the library of the sensor and find a method where you can define the address. With the call of begin(0x76, &Wire) the BME sensor just worked fine.


Wiring

Does it look a little complicated? Maybe. But it's quite easy. Everything needs power, corresponding to it's specifications. The sensors can be powered by the voltage pins of the microcontrollers. The Neopixels need more current, as the controllers can provide, so it needs to be powered directly by the power supply. The APDS-9960 sensor is connected via I2C to the Nano. So it has to be pin A4 (SDA) and A5 (SCL). On the NodeMcu it doesn't matter which two pins we use, since nearly every two pins can be configured to act as I2C.

Features

The lamp communicates via the MQTT protocol. I've put in a small Raspberry Pi Zero W, that acts as a MQTT broker. The Arduino Nano handles the gesture sensor and sends a signal to the NodeMcu to turn on/off all Neopixels. The NodeMcu has access to the BME280 sensor and publishes the temperature and the humidity to the MQTT broker. You can switch modes between On/Off and several animations. For nearly all functions (except the sunrise alarm and the disco light) you can set the desired RGB color.
The NodeMcu syncs time with a NTP server. So you can set a time when to start the sunrise-mode.


Modes

Off (0)

Well, every NeoPixel is turned off. The Lamp still reacts to the gesture sensor

On (1)

Sets all NeoPixels to the desired color.

Animation (2)

Sets the color of the stripe one pixel at a time, starting from the bottom, rising to the top.

Blue Light (3)

A rotating light. Like the one the firefighter or the police use it. But in any color you want.

Fire Simulation (4)

Random flicker, that starts at the bottom, rises and falls randomly.

Sparkle (5)

Turns on all LEDs at the desired color. Adds randomly some white sparkles to the light.

Blink (6)

Remember the classical blink-sketch? Now with a hole lamp and the color you like.

Sunrise Alarm (7)

You set the hour and minute where the alarm starts and it simulates a sunrise (like in the sunrise simulator project).

Disco Lights (8)

Randomly sets up to 4 LEDs to a random color.


FAQ

Why using three boards, when one can do the trick?
Raspberry Pi Zero W - Well this is not really part of this project. But I wanted a MQTT broker for the ESP. And for upcoming projects. So why not put it in the lamp? Where I have the place and already the needed power line?

ESP 8266 - The heart of this project. Why not an ESP32? Cos' I don't have one

Arduino Nano - I had a small delay with the library controlling the APDS 9960 gesture sensor. I could have used a ESP32, but I don't have one. I could programmed it on the Pi, but I didn't want to. It increases the cost by about 3.50 € and I found a simple way to transmit simple data. So, who cares?!
Everything fits in the CD case on the lower section. And the more boards you can see there, the cooler it looks. And I like the way it looks.

Parts list

NodeMcu
Neopixels 60/m
APDS 9960 Gesture sensor
BME 280
Arduino Nano
Raspberry Pi Zero W

Source Code

KatLight at bitbucket

Thursday, April 20, 2017

Raspberry Pi Zero W(ireless)





Intro

On the 28.02.2017, the fifth birthday of the Raspberry Pi, a new version was released. The Raspberry Pi Zero W. The W stands for wireless and indicates that Wifi and Bluetooth is already integrated on this board. Finally.
The 'old' Raspberry Pi Zero costs about 4£ plus shipping, while the new version costs about 9.60£ plus shipping.

Difference in power consumption

One thing that was on my mind is: does the integrated solution draws more or less power other than attaching external Wifi and Bluetooth.
The solution I found most similar to the configuration on the new Pi Zero W was the HAT from Redbear. It also extends the Pi Zero with the same connectivity as the new one has now.
So I installed the same Version of Raspian on both models (Kernel 4.4, Release Date: 2017-03-02), turned Bluetooth on and connect with active Wifi to my home network.

Pi Zero + Redbear HAT Pi Zero W
... ...
140-160 mA 130 mA

More expensive or cheaper?

Well, kind of a tricky question, isn't it? On the first sight, you see the same-sized board with identical specs for more than the double of the price. But think about it. If you want to use it, as a streaming-client, a home cloud server, a broker for IoT projects or even a small PC, you need what? Internet connection. So you need a Wifi dongle. And since it wouldn't fit, you also need a OTG adapter. And a small USB hub would be also nice. Oops! That's a lot of extra to buy.


Watch the Pi Zero W


Worth it?

If you are looking for a small single board computer as a replace for a Lunix based desktop computer, you should probably go for the Raspberry Pi 3.
But if you want to buy a Pi Zero anyway, you should go for the version with the integrated connectivity. Because if you are a maker and want to build your own IoT device, a Webserver or even a autonomous robot, you wish earlier or later that you can communicate with your Pi.