Friendship Lamp

by marc_m in Circuits > Arduino

3238 Views, 26 Favorites, 0 Comments

Friendship Lamp

small_cover_pic.JPG
Friendship Lamp
login.png
wifi.png
main_page.jpg
friends_page.jpg
fx_page.jpg

This is, at heart, a rip-off of an existing product borne out of a desire to avoid paying $90 per lamp when you KNOW you can do it cheaper and better yourself. Like all good DIY projects, this is only true if you don't value your time or sanity as you break circuits and waste days developing your version.


Functionality

Each lamp is based around an ESP2866 module that controls a Neopixel ring light. When the device is powered on for the first time, it opens a captive web portal which helps you connect to wifi. Once connected, the device communicates to other devices on the network via a free AdafruitIO dashboard - publishing and subscribing to messages.

These lamps are a bit different from the commercial version or other lamps you can find on Instructables because:

  • You can send multiple colors and multiple lighting effects (pulses, flashes, rainbows)
  • There are two versions - a headless version with just buttons and a "Deluxe" version with an OLED screen
  • You can connect more than 2 devices - each with its own ID such that a Deluxe lamp can communicate with any other lamp on the network

Overall, the lamps function as nodes on your friend network (see step 1). You can add as many friends as you want to your network but if you are using lamps without a display, that lamp can only communicate with a fixed subset of the network. A lamp with a display can communicate with anyone. Because the displays are pretty cheap and very handy, I recommending using them.


Examples!

This video shows the lamp in action.


How to Setup

  1. Plug Device In
  2. Will flash solid red for a moment when power is connected
  3. If powering on for the first time in a new network:
  4. Will flash yellow
  5. Open Web Browser
  6. On your device, connect to the wifi network you setup in the coding step
  7. You'll see a login screen. Connect to your home wifi.
  8. Hit save. You might have to unplug and replug the lamp at this point. It will save your info, so you’ll only have to do this once.


How to Use

For the lamp with no display:

There are two buttons and a dial.

The blue button cycles through the lighting FX from solid color -> off. The dial will adjust the color of the selected FX (if available).

The green button will send the selected FX to the friend setup in the coding step. When that happens, you’ll see the device flash green.

Holding down the blue button will, confusingly, do two things - First it will toggle the lights on the buttons on or off. Secondly WHILE the button is being held down, you can use the dial to adjust how bright the lamp is.

Holding down the green button will reset the lamp back to the home "screen". So if you've sent a message but want to be able to mess with the lighting effect, hold it down. If you've received a message and it's jammed up, hold down that button!


For the lamp with display:

Should be a little more self-explanatory. Top/Bottom buttons navigate through menus. The middle button selects.

Supplies

Tools

These might not all be necessary, but they make life easier:

  • Solder Iron
  • Jumpers (like these)
  • Multimeter

Materials

  • Neopixels (Ring or Line, Ring works better for the effects)
  • Adafruit Feather HUZZAH with ESP8266
  • Potentiometer and resistors/wires to drop the output voltage to between 0 and 1v (actual sizing depends on your potentiometer size
  • 128x64 px OLED Screen (only necessary on the version with a display)
  • Buttons x2 (like these. Not necessary on the version with a display)
  • Lamp materials! I used a frosted glass shade and bulb along with a wooden bowl and some sort of weird cutting board, all from a thrift shop, to make the two lamps. But it's very flexible and basically any format would work. Neopixels look really good under a diffuser, so it's helpful if the glass isn't clear.
  • USB Power Cord (5V, 1A output - check the plug rating before using)

Resources

Setup Your Adafruit IO Dashboard

feed.png

Follow tutorials here to create your own Adafruit IO dashboard. The dashboard is free if you're sticking below a certain messaging rate (which is pretty generous) and we will be well below that threshold unless you're making a ton of these lamps. Make a dedicated feed, the name is not important.

The feed will contain messages consisting of a sender, a receiver, a color, and a lighting effect. The message content will be passed in the "Value" field of the Adafruit message and looks like this:

{
"sender":"Jane",
"receiver":"Megan",
"fx":0,
"color":25616
}

Lamps will be subscribing and publishing to the feed. When a lamp sees a message where the "receiver" field matches their name, that lighting effect and color will be displayed. When a user wants to send a message, that lamp will publish a new message to the feed.

Wire the Circuit

layout_bb.jpg
IMG_1079.jpg

It's a good idea to breadboard your circuit prior to building into your lamp.

The components we need to test are:

  • The OLED Display (if using)
  • Buttons
  • Neopixel Ring
  • Potentiometer

The circuit shown is for the non-display version. If you're using a display, it connects directly to the HUZZAH with headers and you can eliminate the buttons (as there are three buttons built into the display).

Theoretically you only need a few pins on the OLED screen to work properly (SDA/SCL and +/GND pins) however when I tried this, my results were...temperamental. Sometimes it would work and sometimes it would fail. When I asked Adafruit support, they recommended I connect every pin via a stacking header setup (see here).


The potentiometer and voltage divider output should be verified prior to plugging it into the A0/ADC pin. The HUZZAH can only accept analog voltage <1V so if you haven't done the wiring properly, you can fry your board. Expected behavior is a smooth movement between 0 and 1 volt max when you turn the potentiometer.


Build and Assemble the Lamp

IMG_0836.JPG
IMG_0891.jpg
IMG_0888.jpg
mounted_ring.png
IMG_0835.JPG
IMG_0894.jpg

This step is highly dependent on your lamp configuration. I built one lamp with no display and one with a display. Biggest trick is getting the wiring neat and tidy without breaking any connections.

Upload the Code

Lamp code is here: https://github.com/marc-micatka/friendship_lamp

You can either download it directly from github or clone it to your local machine like so:

git clone https://github.com/marc-micatka/friendship_lamp.git


Depending on your lamp version, open either folder ("lamp_dispay" or "lamp_no_display") in your Arduino IDE.

Modify the code as follows:

config.h

This file contains the important login information for your AdafruitIO dashboard and defines your pin-outs for your inputs/outputs.

Update the AIO_USERNAME (line 19), AI_KEY (line 20), AP_NAME (line 24), AP_PASSWORD (line 25) and all the Neopixel/button inputs if you've made changes.

For the Display version, the config.h file looks like this:

//************************ Adafruit IO Setup *******************************/
#define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883 // use 8883 for SSL
#define AIO_USERNAME "ENTER USERNAME HERE"
#define AIO_KEY "ENTER YOUR KEY HERE" // Put Your adafruit ID here
#define MQTT_KEEP_ALIVE 65535

//************************ Wifi Setup *******************************/
#define AP_NAME "Friendship Lamp" // this is the name of the wifi network the lamp creates
#define AP_PASSWORD "12345" // this is the login for the wifi network

//************************ Adafruit Neopixels *******************************/
#define LED_PIN 14
#define LED_COUNT 16

// *************************** BUTTON STUFF ************************** //
#define BUTTON_A 0 # Up button
#define BUTTON_B 16 # Select button
#define BUTTON_C 2 # Down button
#define BUTTON_D 12 # Aux button (currently not used in code)
#define A_PIN A0 // Input for the potentiometer


light_no_display.ino/light_display.ino

Change Lines 2 to your name/the lamp name.

Add your list of other lamp friends to the friend array.

// *************************** CONFIGURATION STUFF ************************** //
#include "config.h"
const char* owner = "Lamp Owner Name";
const char* all_friends = "All Friends";

// ******** FRIEND STUFF ******** //
// List tbe names of the other lamps here (this should match the "owner" field 
String friends[] = {
"friend A",
"friend B",
"All Friends"
};


Build and upload the code to your HUZZAH board.