Jump to content

Arduino + WS2811 Christmas Holiday decorations.

22792400_10212798421768190_2686901974112022101_o.jpg?oh=e23bd48997b96a867af5996541ea1c42&oe=5A9757D8


So with too much time on my hands i taught myself some arduino coding and bought too many little arduino boards.

And after a few weeks of tinkering I built this:


23467036_10212884835888489_3952073420569004947_o.jpg?oh=166ea6062a759aa9d76673cedcb6a4ee&oe=5AAAF045

Inside are two arduino leonardo, one for the menu system, oled output, storage of settings and the rotary encoder input.
The other with programs for controlling 200 WS2811 Individual Addressable RGB LEDs,

Started off with small 8 led adafruit bar and 2 chinese knockoff arduino boards.

22254907_10212643042083795_1958145227594009908_o.jpg?oh=e2ce670b3ada493a926f1327e6a21d7d&oe=5AA23848

The code for the led controls I found, is from a polish coder. more info and original project
I built the menu system, with a 2 color oled screen on i2c and a rotary encoder input.

22829685_10212784285974804_8331924992846424958_o.jpg?oh=433da12910b6047611212e4ee9fa48d8&oe=5A90C6E4

I'm happy to share both sketches, certainly because my coding is shoddy at best and there's a lot of room for improvement.

WS2811_xmas_controlboard.ino
WS2811_xmas_ledboard.ino

I used:
2x Arduino Leonardo (any ATmega32U4 or better will do)
1x 0.96" Oled screen I2C (4 wire)
1x KY040 rotary encoder
1x RC model UBEC (other 12v to stable 5v convertor works fine)
bunch of male to male dupont wires
4x string (50 RGB LED each) of WS2811 addressable lights (ordered at aliexpress) search term:  "WS2811 c7 c9" 
1x Universal enclosure 135 x 95 x 45 Polystyrene 

1x Cliff CL178883 rotary D shaft knob (yes start laughing)
1x 
Cliff CL1730 knob cap
And a Dell DA-2 Power Adapter 12v (also ripped the proprietary 8 pin connector off a dell optiplex pc mainboard.)


2 sticks of hot glue + hot glue gun
Hakko 936 soldering station
And a LOT of Patience.

Next iteration will be replacing one arduino for a Wemos D1 Mini Pro - ESP8266 based arduino board.
making the whole project IoT / connected!!

Link to comment
Share on other sites

Link to post
Share on other sites

Damn I am jealous. need to sit down and learn arduino coding as I have alot of cool projects in mind. Right now I am trying to learn how to get sensor data to output to a screen just like the one you have in your pictures. Right now I can only output data to serial monitor.

Technology is both a gift and a curse. do not let the old ways die as you never know when they may be the only way to perform a taks.

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, jakemaster1390 said:

Damn I am jealous. need to sit down and learn arduino coding as I have alot of cool projects in mind. Right now I am trying to learn how to get sensor data to output to a screen just like the one you have in your pictures. Right now I can only output data to serial monitor.

I have approached all arduino things as i would do with PCs:  Every addon hardware needs to talk to the main processor, so it needs some way to know what and where this peripheral is. Libraries for peripherals are like "drivers", they act like it anyway.
You can easily add the library for that specific oled to the sketch and wire it like instructed (most of the time it's only one of 2 standard wire options)
Most of the times libraries come with examples, and there's no shame in borrowing code from examples to make your project work. 

Spoiler

When buying the oled, did it say how many pins the screen needs to be connected with and did it say what display driver/chip it's based on? 
(4 pin I2C or 7 pin SPI, SH1106 or SSD1306 or something else?) This will decide which specific library is a option for your usercase.
Usually you'd need to add a graphics library if you want to do more than just print pixels.
Another option is a fairly generic library for oleds like "u8g lib",  this includes all you need, and 99% of the time you only need to unmask (or define) one device to make it work.
(I linked the git of u8g, but I'd install all libraries from within the IDE so they can be updated automatically.)

i'd need more info on the screen and it's chip to say what library and what definition of device you'd need, the print to serial or print to screen are pretty much the same.

 

Link to comment
Share on other sites

Link to post
Share on other sites

20 hours ago, H00GiE said:

Most of the times libraries come with examples, and there's no shame in borrowing code from examples to make your project work. 

  Reveal hidden contents

When buying the oled, did it say how many pins the screen needs to be connected with and did it say what display driver/chip it's based on? 
(4 pin I2C or 7 pin SPI, SH1106 or SSD1306 or something else?) This will decide which specific library is a option for your usercase.
Usually you'd need to add a graphics library if you want to do more than just print pixels.
Another option is a fairly generic library for oleds like "u8g lib",  this includes all you need, and 99% of the time you only need to unmask (or define) one device to make it work.
(I linked the git of u8g, but I'd install all libraries from within the IDE so they can be updated automatically.)

i'd need more info on the screen and it's chip to say what library and what definition of device you'd need, the print to serial or print to screen are pretty much the same.

 

This is something most people that never coded dont realize, even commercial coders use google and take code snippets that are available to adapt them to their needs.

Its a normal thing not to reinvent the wheel every day.

Link to comment
Share on other sites

Link to post
Share on other sites

On 11/16/2017 at 6:15 AM, H00GiE said:

I have approached all arduino things as i would do with PCs:  Every addon hardware needs to talk to the main processor, so it needs some way to know what and where this peripheral is. Libraries for peripherals are like "drivers", they act like it anyway.
You can easily add the library for that specific oled to the sketch and wire it like instructed (most of the time it's only one of 2 standard wire options)
Most of the times libraries come with examples, and there's no shame in borrowing code from examples to make your project work. 

  Reveal hidden contents

When buying the oled, did it say how many pins the screen needs to be connected with and did it say what display driver/chip it's based on? 
(4 pin I2C or 7 pin SPI, SH1106 or SSD1306 or something else?) This will decide which specific library is a option for your usercase.
Usually you'd need to add a graphics library if you want to do more than just print pixels.
Another option is a fairly generic library for oleds like "u8g lib",  this includes all you need, and 99% of the time you only need to unmask (or define) one device to make it work.
(I linked the git of u8g, but I'd install all libraries from within the IDE so they can be updated automatically.)

i'd need more info on the screen and it's chip to say what library and what definition of device you'd need, the print to serial or print to screen are pretty much the same.

 

Oh my aim is not to re-invent the wheel either. For as long as I can remember google has been my friend for do it yourself projects and for vehicle mantainiance troubleshooting. I am actually working with u8g2 lib and just need to figure out what little thing  I am missing that will just make the two items work together. Now off to the depths of google and youtube to figure out what I am missing

Technology is both a gift and a curse. do not let the old ways die as you never know when they may be the only way to perform a taks.

Link to comment
Share on other sites

Link to post
Share on other sites

I actually managed to combine the two Arduino Leonardo codes into one Arduino Mega 2560
Which reduced the total costs of building this whole design to a (still somewhat hefty) $125 ish (USD) 

The 2560 is total over over kill, I actually only need one I2C, and 4 digital pins. but i need the SRAM. (3k of variables) 
May look into the variables some more see if i can consolidate some more, and clean the code.
 

11 hours ago, jakemaster1390 said:

Oh my aim is not to re-invent the wheel either. For as long as I can remember google has been my friend for do it yourself projects and for vehicle mantainiance troubleshooting. I am actually working with u8g2 lib and just need to figure out what little thing  I am missing that will just make the two items work together. Now off to the depths of google and youtube to figure out what I am missing

 

The fun thing about this google and forum lurking is the amount of new ideas and methods.

Quite literally I found out arduino has EEPROM storage after looking into the SRAM size differences in atmega chips.
when using U8G2 you only have to un remark a setting to define your screen, and that is decided which chip your oled screen has, (99% sure it will be a 1306 or 1106 if it's like my screen.)
i'm using:

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

void setup(void) {
  u8g2.begin();
}

*insert rest of code here*

to define the screen in the pictures. 

Link to comment
Share on other sites

Link to post
Share on other sites

Oh I figured out that part a while ago and have been able to display test patterns on the screen which is very nice in my book. my actual issue is to figure out how to take the variable reading and output it as a changing display because I can both read information to the serial monitor but all it displays is one word on attached screen so information is not flowing to the screen.

Technology is both a gift and a curse. do not let the old ways die as you never know when they may be the only way to perform a taks.

Link to comment
Share on other sites

Link to post
Share on other sites

51 minutes ago, H00GiE said:

I actually managed to combine the two Arduino Leonardo codes into one Arduino Mega 2560
Which reduced the total costs of building this whole design to a (still somewhat hefty) $125 ish (USD) 

The 2560 is total over over kill, I actually only need one I2C, and 4 digital pins. but i need the SRAM. (3k of variables) 
May look into the variables some more see if i can consolidate some more, and clean the code.
 

 

The fun thing about this google and forum lurking is the amount of new ideas and methods.

Quite literally I found out arduino has EEPROM storage after looking into the SRAM size differences in atmega chips.
when using U8G2 you only have to un remark a setting to define your screen, and that is decided which chip your oled screen has, (99% sure it will be a 1306 or 1106 if it's like my screen.)
i'm using:


#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>

U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

void setup(void) {
  u8g2.begin();
}

*insert rest of code here*
 

to define the screen in the pictures. 

Technology is both a gift and a curse. do not let the old ways die as you never know when they may be the only way to perform a taks.

Link to comment
Share on other sites

Link to post
Share on other sites

The funny thing is, that might be the easy-est part. 
 

Spoiler

As a example I use the analog input A0 to be printed on screen.

I used the Adafruit_1306 libary because it's simple. (not as epic as u8g2)
But the code is like this:


void loop()
{
clearDisplay(); //Clear the display
display.setTextSize(1); //text size 
display.setTextColor(WHITE);//text color display.
setCursor(0,0); 
int sensorValue = analogRead(A0); // analog reading (which goes from 0 - 1023)
display.println(sensorValue); // print out the value.
display.display(); // 
delay(1); //delay for 1 milisecond.
}

If i would use U8g (not likely) i'd code it like this:
 


void draw(void)
{
  u8g2.setFont(u8g2_font_helvB08_tf);
  u8g2.setCursor(20,30);
  int sensorValue = analogRead(A0); // analog reading (which goes from 0 - 1023)
  u8g2.print(sensorValue); // print out the value.
}

void loop(void) 
{
  u8g2.clearBuffer();
  draw();
  u8g2.sendBuffer();
  delay(1); //delay for 1 milisecond.
}

or:


void loop()
{
 u8g2.firstPage(); 
 do 
  { 
  u8g2.setFont(u8g2_font_helvB08_tf);
  u8g2.setCursor(20,30);
  int sensorValue = analogRead(A0); // analog reading (which goes from 0 - 1023)
  u8g2.print(sensorValue); // print out the value.
  delay(1); //delay for 1 milisecond.
  } while (u8g2.nextPage());
}

 

Then again google might have better solutions, and i already said i'm a n00b coder in arduino, still gets the job done in my case tho... 
Tried u8g myself and got stuck on all the page buffer stuff, so i decided to use the Adafuit library instead. (feels like the lazy way to be honest, lol.)

 

Link to comment
Share on other sites

Link to post
Share on other sites

As i said before: I want to make the tree a IoT device.
So I purchased a Wemos D1 mini pro, 
Zg4olGToQU2v7ZaES4-dIQ.png
it has the right amount of pins usable, it has decent (enough)arduino support.
(yes i know the 16MB spiffs isn't working nicely with arduino so only 3MB usable... 
but, better have and not need... besides 3MB is well enough for a arduino project)
main reason i specifically like the pro version is the ceramic antenna.
The board will be under a tree with all kinds of (RF) noise around it because of hundreds of chips firing off at random intervals etc.
So a stronger wifi would be appreciated.

The major drawback is really that this board only speaks 3.3v logic level. 
Normally a logic level converter would be the end of that story.

The are reports tho the WS2811 led driver chips expects strict timing, the fall and rise time is too sloppy on a logic level converter.
So after half a day searching ye old interwebs, i found a solution, wel rather someone else did, and i'm totally stealing his good idea.

uDJKnwSFQZKaSxZsTUQ_iw.png
The 74AHCT125N, a tristate Quad buffer/line driver.
It only has a delay of about 6ns, so miles better than a logic level converter.

the Wemos D1 also has a prototype shield to accommodate this kind of circuitry.


IMG_8168_480x480.jpg?v=1508622730


So now only have to rewrite the code for the leds (80MHz vs 16MHz so need to make some wait states etc.)
And write the web interface/api. 

Link to comment
Share on other sites

Link to post
Share on other sites

UPDATE 24129635_10213022191682298_8965769736132177274_n.jpg?oh=280f687a94756c417d7466db92d8a25a&oe=5A973D3C: "This Isn't Even My Final Form"

well... actually it might be! This is the latest iteration of the Nerdy X-Mas lights: A ESP-8266EX enabled Wemos D1 mini pro board running at a nice 80MHz.
Enough SRAM and Sketch storage for all features of the project on a single board. And WIFI... 
Yep you read that right, WIFI !, the tree lights are now IoT enabled. (working on a decent web interface)


In the picture on the right, you see the new Wemos D1 mini pro, with a prototype shield hosting the 74HCT125N and common ground, 5v and 3.3v rails.

I'm actually testing the system as we speak.

There's a web interface that's virtually realtime.

The rotary encoder works it can select mode brightness and effect speed.
The display works and updates even if the web interface is used.


24132017_10213022262244062_1767772563390908893_o.jpg?oh=280f14f00e23b95eb0ff1b02173ace84&oe=5A97C180On the left: A inside peek of the case, hot glue in this case works amazing to keep parts in their place. !!

As a finishing touch end of the week i'll breakdown costs, shipping and items + tools needed (i'll supply EU / US / CA / UK links to objects if i can.)

And obviously video(s) of the finished project actually setup in the tree definitely incoming!! 

Here are the sketch and web interface files:
(folder called WS2811_xmas_esp8266_board) 
WS2811_xmas_esp8266_board.ino

index.html.cpp

main.js.cpp

Webinterface is not finished yet. (not my code)

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×