091117_2101_TinkeringTu3.jpg

Tinkering Tuesday – Playmobil Stage – LED Rings

Past posts of this series:

Tinkering Tuesday – Playmobil Stage – Einführung

Tinkering Tuesday – Playmobil Stage – Introduction

Tinkering Tuesday – Playmobil Stage – Playmobil parts

Tinkering Tuesday – Playmobil Stage – LED Stage Lights

Tinkering Tuesday – Playmobil Stage – Disco Ball with stepper motor


This one will be a rather short post to describe the LED rings that I used for the background effect.

They are very cheap WS2812B based LED rings from ebay. I bought 3 different ones, 7 LEDs (1,10 EUR), 16 LEDs (2,29 EUR) and 24 LEDs (3,69 EUR). The wiring is very easy, the WS2812B is addressable and requires only 5V, GND and one control pin from the Arduino. They are even chainable so I connected the control pins of all three rings to only require one singel Arduino pin.

In the following picture you can see the wiring. Yellow is the control pin chained from the biggest to the smallest ring. The black ground wire is also chained. I decided to provide the 5V to every ring on its own to avoid a loss of brightness (but I guess with only 47 LEDs that was not really necessary). I even made a professional looking schematic, see the small orange paper in the pic?!

Soldered and chained rings

In the next picture you see the solder pads in a closeup.. Here is the smallest ring only connecting the input side (black=GND, red=5V, yellow=control pin). As you saw above I secured everything with hot glue.

Solder pad closeup

Here it is already glued to the back of the stage:

Glued to the background

As a beginning I searched for an easy to use library and found FastLED. They are also compatible with Adafruits NeoPixel. So go have a look there. They have great guides.

The most simple program using it is:

#include "FastLED.h"
CRGB leds[1];
void setup() { FastLED.addLeds<NEOPIXEL, 6>(leds, 1); }
void loop() {
leds[0] = CRGB::White; FastLED.show(); delay(30);
leds[0] = CRGB::Black; FastLED.show(); delay(30);
}

This only blinks the first LED. There are some more great examples in the download from Github and the basics are very easy.

Here is a small test video switching all LEDs one after another from red to yellow to blue:

I wanted to use something with a little more effects than just blinking like with the LED spots so I chose one of the bigger examples, the NoisePlusPallette which can be found at: https://github.com/FastLED/FastLED/blob/master/examples/NoisePlusPalette/NoisePlusPalette.ino

This is using readymade color palettes and combines that with a random noise generator. You can influence the parameters (e.g. with the sound input) and so make this you own. I didn’t have so much time so I just fed in some parameters from my sound input and adapted it to the number of LEDs. The result will later be described in my Software wrapup.

I used acrylic glass that I sanded so it is not clear but milky to make the effect more outstanding. That will be seen later in the woodworking part. In my demonstration video you can see the rings in action (here directly starting at 0:11):

090317_0848_TinkeringTu5.jpg

Tinkering Tuesday – Playmobil Stage – Disco Ball with stepper motor

Past posts of this series:

Tinkering Tuesday – Playmobil Stage – Einführung
Tinkering Tuesday – Playmobil Stage – Introduction
Tinkering Tuesday – Playmobil Stage – Playmobil parts
Tinkering Tuesday – Playmobil Stage – LED Stage Lights


 

As already written on my last post I bought a disco mirror ball (5cm diameter) from Conrad:

I had some cheap stepper motors lying around so I decided to use one of those to drive the ball. Those are 28BYJ-48 motors with a ULN2003APG based driver board:

The motor was mounted using two simple screws:

View from above the stage
View from inside the stage

With a small drill bit I was able to make a small hole into the shaft and with some „Tüdeldraht“ and hot glue the ball was mounted onto it.

Final assembly

For the software part the following website http://www.eprojectszone.com/2016/11/19/arduino-and-uln2003apg/ was very helpful in understanding the ULN2003APG and using it together with an Arduino.

//http://www.eprojectszone.com/2016/11/19/arduino-and-uln2003apg/

int motorpin1 = 10;

int motorpin2 = 9;

int motorpin3 = 8;

int motorpin4 = 5;

int t =2;

void setup() {

pinMode(motorpin1, OUTPUT);

pinMode(motorpin2, OUTPUT);

pinMode(motorpin3, OUTPUT);

pinMode(motorpin4, OUTPUT);

}

void loop() {

digitalWrite(motorpin1, HIGH);

digitalWrite(motorpin2, LOW);

digitalWrite(motorpin3, LOW);

digitalWrite(motorpin4, LOW);

delay(t);

digitalWrite(motorpin1, LOW);

digitalWrite(motorpin2, HIGH);

digitalWrite(motorpin3, LOW);

digitalWrite(motorpin4, LOW);

delay(t);

digitalWrite(motorpin1, LOW);

digitalWrite(motorpin2, LOW);

digitalWrite(motorpin3, HIGH);

digitalWrite(motorpin4, LOW);

delay(t);

digitalWrite(motorpin1, LOW);

digitalWrite(motorpin2, LOW);

digitalWrite(motorpin3, LOW);

digitalWrite(motorpin4, HIGH);

delay(t);

}

This is not the most beautiful way to use a stepper motor in your code, so I just switched over to the stepper library (https://www.arduino.cc/en/Reference/Stepper). This reduces the code mostly to the following:

#include <Stepper.h>

#define motorpin1 7

#define motorpin2 8

#define motorpin3 12

#define motorpin4 13

#define STEPS 4096

Stepper stepper(STEPS, motorpin1, motorpin2, motorpin3, motorpin4);

void setup() {

stepper.setSpeed(2);

}

void loop() {

stepper.step(1);

}

This on its own worked great. But I had to learn that this is working just as the first code and is blocking the Arduino / slowing it down so much that everything else is not working as I was expecting it to be (especially the Audio analysis). Also together with the LED rings it was not really working out. It also produces interferences in the power lines. I used one single power source (5V 3A). But this led to so much interferences in using the stepper motor in the Audio output that I had to come up with another solution. More on that in a later part 😉

In the video there is the disco ball in action (starting at 0:48):

082617_0857_TinkeringTu23.jpg

Tinkering Tuesday – Playmobil Stage – LED Stage Lights

Past posts of this series:

Tinkering Tuesday – Playmobil Stage – Einführung

Tinkering Tuesday – Playmobil Stage – Introduction
Tinkering Tuesday – Playmobil Stage – Playmobil parts


 

I bought some stage lights from Playmobil (see also my post on the Playmobil parts):

They have a diameter of 1cm inside. So I thought „why not buy big LEDs that fit in there?“. I measured and looked through the online shop of http://www.conrad.de. I figured out that the 10mm LEDs will not fit because they have a slightly wider ring on the bottom. The 8mm LEDs also have this ring but this one is about 10mm so fit perfectly.

I bought 9 of these in the colors red, yellow and green (after the guy at the parts counter wanted to also sell me white ones. Right before going to the checkout I saw that they cost 4.95 EUR each. He nearly got me. Now I know I always have to ask for the price of all parts, even if they seem nearly the same…).

Back home I calculated the resistors needed and came up with the following results using http://ledcalc.com/:

Green LED

https://www.conrad.de/de/led-bedrahtet-gruen-rund-8-mm-3-mcd-60-20-ma-22-v-l-793-gd-180343.html

Red LED

https://www.conrad.de/de/led-bedrahtet-rot-rund-8-mm-3-mcd-60-20-ma-2-v-l-793-id-180327.html

Yellow LED

https://www.conrad.de/de/led-bedrahtet-gelb-rund-8-mm-3-mcd-60-20-ma-21-v-kingbright-l-793yd-180475.html?sc.ref=Product%20Details

What I didn’t think of was how bright they would be. When I connected everything I was a bit disappointed but having a look at the data sheets I understood why and blamed myself. They only have 3 mcd of light. That’s really next to nothing. A candle has about 1000 mcd. So I will go back to using 5mm LEDs that are cheaper and easier to find in various colors and with a much higher mcd value. Lesson learned!

I then just ordered a cheap LED set from ebay with higher mcd values and 5 colors each in sizes 5mm and 3mm. Those are quite acceptable in brightness. Only the green LED is very dark (although it has the highest mcd ratings… can anyone explain that? I experimented with resistors from 82 ohm to 100 ohm but it is not very bright). I won’t do the full resistor math here, just use an online LED calculator

The light distribution is very wide but I also had some LEDs from a cheap starter set which are more like a spot light. I will combine both and will place the spots. I also have red, blue and green LEDs from those but the green ones have the same brightness problem so I will just use red and blue. I combine the red and blue spots together with the yellow ones from the set in the Playmobil spots and have two white spots at fixed points at the side of the stage for the disco mirror ball (5cm diameter) I bought from Conrad:

The spotlights are mounted on a 4mm aluminum rod:

That is a tight fit but is just the right tension to not move easily and be able to move the spots.

Schematics LED controller board

From my HUEify project I had good experiences with using a MOSFET to drive LEDs so I bought some BUZ11 again (I know, not the best ones to use but at least here a very cheap way to go). So the plan is to drive the LEDs in color groups, each driven by a BUZ11. In the groups the LEDs will be connected in parallel with a resistor each.

This is the basic cabling for one LED. There are two pin headers for power (top=GND, botton=5V) and one pin header for the control pin of the Arduino. Three of the LEDs are connected to one MOSFET with common 5V. The build process is documented in the following pictures:

Resistors first, then the cables to LED’s anode (red cabling).

Then solder the MOSFETs, the pin headers for the control pins and the pin headers for GND in place (I took 2 here which was a good decision in the end. I will explain that later). If you have a closer look at the picture above: do you see what’s wrong? Post it in the comments… Always double-check before soldering!

On the right side is another pin header (also 2 pins here) for the 5V power. Above are the black cablings from the LED’s cathodes. The lower part is for the white LEDs for the mirror ball. I messed up with one resistor so I had to solder a third one… Here the cabling is a bit different because I wired them directly to pins 9 and 10 of the Arduino. I also messed up with the black cable: it goes to the LED’s anode, not cathode so I used yellow cabling to the anode to be reminded of the mistake. It helped! And finally some hot glue to hold everything in place (that is a whole lot of cables…)

Here is a picture to give you an idea of the mess of cables (LED rings are also included there):

I used tape to hold the cable pairs together and marked them to see which is connected to which MOSFET. Also a good idea!

To put them into the spots I had to drill a hole in the spot itself. I think it was a 4mm drill that was perfectly fitting. After that I put some heat shrink tubing in place:

Putting the cables through and adding another small heat shrink tubing to the black wire:

Then I soldered the LED in place:

Always test after sodlering and before shrinking the heat shrink tubes:

Then put the LED into the spot and use hot glue to hold in place:

Last but not least put them on the rod (more on that in a future post):

In the following picture you can see one of the spot LEDs for the disco ball. They are just hot glued into the side walls:

And it’s always a good idea to prepare for mass production:

The control of the lights will be described in the software wrapup. Next week will be about the disco ball, including the control of the stepper motor.

082017_1242_TinkeringTu8.jpg

Tinkering Tuesday – Playmobil Stage – Playmobil parts

In this post I will provide details about all the parts that I used and all the other music stuff I found and could be used.


Past parts of this series:

Tinkering Tuesday – Playmobil Stage – Einführung (German introduction)
Tinkering Tuesday – Playmobil Stage – Introduction


Playmobil sets

I found several music related sets and also wedding related ones that I will just list here. The picture is linked to Amazon using my partner ID. If you choose to buy something I would be glad if you’d use the link.

Music sets

Link and Picture Set number Set name (german)

4787 Musik-Clowns

4231 Zirkuskapelle

4329 Schulband

4784 Rockstar

5377 DJ Z
5602 Pop Stars Stage Bühne


5603 Pop Stars Tour Bus

5604 Pop Stars Keyboarder

5605 Pop Stars Band

5610 Musik Band

6983 Disco mit Liveshow

9095 Sängerin am Keyboard

Wedding sets

Link and Picture Set number Set name (german)

4298 Brautpaar mit Hochzeitstorte

4308 Hochzeitsgäste im Partyzelt

5163 Brautpaar

6871 StarterSet Hochzeit

9226 Brautmodengeschäft mit Salon

9227 Hochzeitslimousine

9228 Hochzeitsparty

9229 Hochzeitspavillon mit Brautpaar

9230 Fotograf mit Blumenkindern

From those sets I researched all the parts that I could use and got the prices and availabilty from the Playmobil spare parts service. Unfortunately I found the really helpful site http://playmodb.org/
after I researched everything via the manuals from Playmobil. But as a hint: use it if you search for something:

Playmobil Parts

To research the part numbers from sets just enter the set number:

And you will get all the details: http://playmodb.org/cgi-bin/showinv.pl?setnum=5602

And you can even get an inventory list (link on the top: Show text-only list with quantities:

This would have saved me some work. If you are not sure about the part, just match the part number from the inventory with the picture. For prices just go to the Playmobil service site and enter the part number:

Most of the parts I searched for had no picture and sometimes the names are also not the best ones. PlaymoDB is much better!

Another hint: Don’t forget to order the stickers for the parts that require some, e.g.:

Sometimes there are even several options:

At the service you have two options. The first one is to directly order in the shop. But there were nearly no parts available that I wanted to order. There is a hint that you have to make an individual order:

There is a separate form for that: https://www.playmobil.de/ersatzteilbestellung But there you can only enter 10 parts. I read some forum posts on http://www.klickywelt.de/ and they just call (also not cool if you want many parts) or send an email (in Germany it’s service@playmobil.de). Please save them some work and prepare your list with part numbers and names and how many you want. I even included the prices. You will get an offer with the total costs which you have to confirm and then receive a package a few days later J

I didn’t know about the service before I purchased my first set, the rockstar (4784) via https://www.ebay-kleinanzeigen.de/. That was cheap and included a guitar, a microhpne and stand and the amp, so it was okay. I also (still) don’t know whether you are able to order the figures from the spare part service or how much they cost because you don’t find them in the spare part search, so I searched and ordered them separately. The wedding couple (5163) was matching the real couple okay (the couple from 9229 would have matched better but that was only announced when I researched and the whole set would anyway been to expensive) and I got that with a coupon also really cheap. I had to search for a boy (they have a kid and a band needs a drummer) a little longer but found a very cheap offer of the set 9230 with a boy as a flower kid also on https://www.ebay-kleinanzeigen.de/. I haven’t yet sold the leftover parts, so if someone is in need of a photographer set without a boy or of a rockstar without equipment…

Here is a list of parts that I researched. For most of the things you need several parts, e.g. for the guitar you need 3 parts (the neck, the body and the strap), for the drum even more. I listed them seperately as complete sets though they include equal parts. For the final order I consolidated that of course:

Part List

Subject / required quantity (if more than 1) Part number Part description Price (EUR)
Drumset blue
30637792 Bass Drum Front 1,15
30064300 Drum-Stand 0,45
30642180 Bass Drum Back 0,95
30642740 Tom Top-Part 0,75
30461280 Tom Bottom-Part n/a
Drum Cymbals
30281540 Cymbal 0,25
30064290 Cymbal Stand Rod 0,25
30064270 Cymbal Stand 0,3
Drumset black
30610292 Bass Drum 0,55
30064300 Drum-Stand 0,45
2x 30610302 Tom 0,3
30808233 Sticker (for the whole stage set) 1,15
Drum Seat
30252313 Drum Seat (blau) 0,4
30064270 Drum Seat Stand 0,3
Guitar Stand
30252213 Guitar Stand Rod 0,15
30064270 Guitar Stand Bottom 0,3
Guitar Strat blue
30252303 Strat Body blue 0,4
30079480 Guitar Neck 0,3
30800400 Guitar Strap 0,35
Guitar Strat white
30212423 Strat Body white 0,4
30252293 Strat Body white (alternative) 0,4
30079480 Guitar Neck 0,3
30800400 Guitar Strap 0,35
Guitar Strat red
30079490 Strat Body red 0,4
30079480 Guitar Neck 0,3
30800400 Guitar Strap 0,35
Guitar Strat yellow
30233022 Strat Body yellow n/a
30079480 Guitar Neck 0,3
30800400 Guitar Strap 0,35
30037202 Guitar Neck (brown) n/a
Micro Stand (short)
30217172 Microphone clip 0,15
30248472 Micro Stand rod 0,15
30064270 Micro Stand Bottom 0,3
Micro Stand (boom)
2x 30217172 Microphone clip 0,15
2x 30248472 Micro Stand rod 0,15
30064270 Micro Stand Bottom 0,3
DJ Counter
30644994 Counter base, solid 3,2
2x 30645004 Compact disc 0,95
30246863 Turntables 0,4
2x 30246873 Turntable-arms 0,2
30246893 Earphones 0,35
Other
30604752 Guitar Amp 3T 0,9
30809443 Guitar Amp 3T (Aufkleber) 0,2
30648603 Rock Guitar 0,55
30209600 Drumstick (2x) 0,15
30609010 Drumsticks and -jazz broomsticks 0,45
30218270 Trumpet 0,3
30657190 Accordion 0,5
30218320 Horn 0,35
30218280 Saxophone 0,3
30080280 Tambourine Batter 0,3
30080290 Tambourine bells 0,3
30252173 Micophone grey 0,15
30035032 Micophone black 0,15
30066220 Micophone black round 0,21
30660103 Strobe-Light n/a
Light 1
30252343 PAR-Stand 0,25
30224582 PAR-Spot 0,25
30032040 PAR yellow glass 0,2
30253133 PAR red glass 0,2
30255083 PAR orange glass 0,2
Light 2 (Set 6983)
30035042 PAR light-yellow glass 0,2
30035052 PAR light pink glass 0,2
30035072 PAR spot 0,2
30245722 PAR Stand 0,2
PA
4x 30252333 PA-Box 0,6
30821603 PA-Box Sticker 4x PA-Box 0,3
30808233 PA-Box Sticker alternative: whole stage set 1,15
Keyboard
30252143 Top 0,35
30252153 Keys (white) 0,3
30252163 Keys black) 0,45
2x 30201212 Stand 0,2

Final order

My final order was the following (german, not including parts that I didn’t use in the final product and which I already had from the sets):

Anzahl Ersatzteilnummer Bezeichnung Einzelpreis Gesamtpreis
1

30610292

Basstrommel-Schlagzeug 0,55 € 0,55 €
1

30064300

Gestell-Schlagzeug II 0,45 € 0,45 €
2

30610302

Trommel-Schlagzeug 0,30 € 0,60 €
2

30281540

Becken-Schlagzeug 0,25 € 0,50 €
2

30064290

Stativstange Gebogen 0,25 € 0,50 €
7

30064270

Dreibein 0,30 € 2,10 €
1

30252313

Sitz-Dreibein 0,40 € 0,40 €
2

30252213

E-Gitarre-Ständer 0,15 € 0,30 €
1

30252303

E-Gitarre-Körper (blau) 0,40 € 0,40 €
2

30079480

E-Gitarre-Hals 0,30 € 0,60 €
2

30800400

E-Gitarre-Riemen 0,35 € 0,70 €
1

30212423

E-Gitarre-Körper (weiß) 0,40 € 0,40 €
2

30217172

Adapter-Clip 3 6 0,15 € 0,30 €
2

30248472

Stange 46×3 6mm 0,15 € 0,30 €
9

30224582

Suchscheinwerfer 0,25 € 2,25 €
4

30252333

Lautsprecher stapelbar 0,60 € 2,40 €
1

30821603

Etikett 5610 „Carrying Case Band“ 0,30 € 0,30 €
1

30209600

Trommelstöcke 0,15 € 0,15 €
1

30035032

Mikrofon 2012 0,15 € 0,15 €
1

30066220

Mikrofon 0,21 € 0,21 €
1

30604752

Verstärker-Gitarre 3T 0,90 € 0,90 €
1

30809443

Etikett 4784 „Rockstar“ 0,20 € 0,20 €

Here again a picture of the first (with the rockstar as drummer and some additional parts I ordered) and the final setup:

Next week I will most probably continue with the assembly of the LED spots.

082017_1114_TinkeringTu1.jpg

Tinkering Tuesday – Playmobil Stage – Introduction

All posts of the series (will be continued):

Tinkering Tuesday – Playmobil Stage – Einführung (German introduction)
Tinkering Tuesday – Playmobil Stage – Playmobil parts
Tinkering Tuesday – Playmobil Stage – LED Stage Lights
Tinkering Tuesday – Playmobil Stage – Disco Ball with stepper motor


 

As a wedding gift for a befriended couple, both are musicians, I build a stage for Playmobil figures. The result can be seen in the following pictures (a video is at the end of the article):

In a series of blog posts within the nest weeks I will describe in detail how I build it, what the difficulties were and everything I had in mind that would be also possible (but as a matter of time I wasn’t able to implement in the final product). Today will be about the basic idea and the implemented functions.

The idea

The inspiration came from a gift we got to our own wedding. In a small wooden frame there was a horse (my wife is a horse rider), bride and groom with a guitar on it. Unfortunately I don’t have a picture of the gift as a whole but I still have the figures:

2017-08-14 20.54.37

 

I thought that I could reuse the guitar and build a small stage with a couple on it. But then there questions came up: I would need new figures, a second guitar (or a bass guitar). And a stage with no light or music at all?

My first thoughts were about figures. I came up with Playmobil. I saw guitars there and after some internet research I found a big community about customizing Playmobil. And even stumbled upon several pictures on Pinterest about rebuilding Rock Bands (I Love Clicks, e.g. Bon Jovi in the following image):

Source: https://www.pinterest.de/pin/300756081338206340/

Some people also build small stages. But that was not what I had in mind. I wanted a festival stage, like Rock am Ring.

Source: https://www.pinterest.de/pin/300756081338196939/

Source: https://www.pinterest.de/pin/300756081338204651/

Playmobil also offers a pop stars stage, even with a builtin speaker and some lights:

Source: http://amzn.to/2wGOC1o

But that’s also not what I wanted and was too expensive.

But there were some cool things: The whole music equipment like the drums, guitars and microphones. The light spots. After another short research I came up with the spare part service from Playmobil (this is the german link but they also provide that in different countries): https://www.playmobil.de/content/spareparts_info/SPAREPARTS_INFO.html

Great! But you need the part numbers. I googled all the sets with music equipment and searched for the part numbers. You can use the manuals available with the set numbers on the Playmobil site and/or http://playmodb.org/. I will provide the details in the next blog post.

The plan

The basic functions I came up with were:

  • Play music
  • Light reacting to sound

And then it went all out of control… J But more on all the ideas in a future post.

As I already said the stage should be like a festival stage. That includes a certain size. The first draft was to use DIN A4 and/or DIN A3 sized sheet wood. But two of those were not quite the size. And I had to plan for some space for all of the electronics:

So it had to be bigger! The detailed measures and the plans for the wood will follow in a separate post.

I did some more research and because of my electronic knowledge is mainly based on the Arduino as a controller and I had some cheap ones lying around, I wanted to do everything on this basis. I found a library to play music from an (micro) SD card and I already played around with lighting in my HUEify project. Build some LEDs into the spot is not the most difficult thing.

The other features have evolved by internet surfing and eBay. The following is included into the final stage:

  • Play music from a microSD card
  • Buttons for Play/Next/Stop
  • Sound Sensor to analyze the ambient sound
  • Sensitivity-potentiometer for the Sound Sensor
  • Switch for swithing between internal and external audio
  • LED-spots (3 blue, 3 red and 3 yellow spots, each color can be controlled seperately, more or less, more on that later …)
  • LED-rings behind a milky acrylic glass as the background, LEDs controllable seperately
  • Turning disco ball (by a stepper motor) with seperate white spots

That’s it. Here is the backpanel:

From top to bottom:
Button: Audio Playback (short push=Play/Next, long pugh=Stop)
Switch: Input Switch (left=internal audio playback, right=external sound)
Potentiometer: Sensitivity for external sound (controls the threshold volume for activating the light)
Cable: Using a rubber from a beer bottle to hide the cable hole. Two cables, small black=audio player, grey=light control.

And now I will finish this post with a video (Music: Monkey Fly – Whatever  – www.monkeyfly.de):

In the next weeks I will continue with the detailed posts. I have already written some of the really technical posts, but I will try to have the general posts before the nitty gritty details.

081417_1823_TinkeringTu1.jpg

Tinkering Tuesday – Playmobil Stage – Einführung

Alle Teile dieser Serie:

Tinkering Tuesday – Playmobil Stage – Introduction (englische Einführung, restliche Parts sind nur auf Englisch verfügbar)
Tinkering Tuesday – Playmobil Stage – Playmobil parts
Tinkering Tuesday – Playmobil Stage – LED Stage Lights
Tinkering Tuesday – Playmobil Stage – Disco Ball with stepper motor


 

Als Hochzeitsgeschenk für ein befreundetes Paar, beide Musiker, habe ich eine Bühne für Playmobilfiguren gebaut. Das Ergebnis ist in den folgenden Bildern zu sehen (ein Video gibt es unten):

In einer Serie von Beiträgen werde ich detaillierter beschreiben, wie das Ding aufgebaut ist, was sich mir für Schwierigkeiten in den Weg gestellt haben und was mir noch alles im Kopf herumgeschwirrt ist, aus Mangel an Zeit dann aber nicht mehr umgesetzt werden konnte. Heute geht es erst mal um die grundlegende Idee und die Funktionen.

Die Idee

Inspiriert hat mich ein Geschenk, das wir zu unserer eigenen Hochzeit bekommen haben. Es war ein Rahmen, darauf ein Pferd, ein Hochzeitspaar, er mit einer kleinen Gitarre in der Hand. Ich habe leider kein vollständiges Bild mehr, aber die Figuren:

2017-08-14 20.54.37

Da dachte ich mir, das lässt sich doch auch für die beiden anpassen. Aber als kleine Bühne. Die Gitarre kann ich nutzen, ggf. Die beiden Figuren auch. Aber dann kamen erst die Probleme: woher einen kleinen Bass oder eine zweite Gitarre bekommen? Vielleicht andere Figuren? Und dann muss es ja auch nach einer Bühne aussehen.

Also mal überlegt. Und auf Playmobil gekommen. Da hab ich doch auch schon mal Gitarren gesehen. Eine kurze Recherche im Internet bringt eine Community zu Tage, die sich mit Playmobil beschäftigt und verschiedenste Szenarien nachbaut. Auf Pinterest gibt es da auch so einiges, wie etwa die „I Love Clicks“ Bilder, hier z.B. Bon Jovi:

Quelle: https://www.pinterest.de/pin/300756081338206340/

Auch einige Bühnen sind dort zu finden, aber nicht so wie ich mir das vorgestellt habe:

Quelle: https://www.pinterest.de/pin/300756081338196939/
Quelle: https://www.pinterest.de/pin/300756081338204651/

Direkt von Playmobil gibt es auch eine Popstars Bühne:

Quelle: http://amzn.to/2wGOC1o

Aber das ist ja auch garnicht so wie ich mir das vorgestellt hatte und auch zu teuer.

Da sind aber schon einige coole Sachen dabei. Das gesamte Musikequipment (Schlagzeug, Gitarren, Mikros und –stative), die Boxen, die Spots. Eine weitere kurze Internet-Recherche bringt einen Top-Ersatzteilservice von Playmobil hervor: https://www.playmobil.de/content/spareparts_info/SPAREPARTS_INFO.html

Großartig! Dafür braucht man aber die Teilenummern. Also erstmal nach Sets gegoogelt, die Musikteile beinhalten. Dann die Einzelteile herausgesucht (dabei helfen http://playmodb.org/ und die Anleitungssuche auf der Playmobil Homepage sehr weiter). Alles weitere dazu kommt in einem seperaten Teil.

Der Plan

Als Grundfunktionen habe ich mir dann folgendes überlegt:

  • Musik abspielen
  • Licht passend zur Musik

Und dann ist es irgendwann aus dem Ruder gelaufen J

Zu allen weiteren Ideen später nochmal mehr.

Insgesamt sollte die Bühne wie eine Festival-Bühne daherkommen. Zuerst habe ich mit A4-großen Spanplatten geplant. Dann aber schnell gemerkt, dass das nichts werden kann. A3 war auch noch sehr gedrängt (hier schon mit dem Bühnensetup und den Hochzeitsfiguren):

Zwei A4 Blätter lassen auch nicht viel Platz für die Technik.

Also musste es noch größer werden. Die genaue Holzplanung und die Abmessungen gibt es ebenfalls in einem späteren Teil.

Dann etwas weiter recherchiert und da sich meine Elektronikkenntnisse hauptsächlich auf den Arduino konzentrieren und ich davon noch einige billige rumliegen habe, wurde auf der Basis versucht die Hauptfunktionen umzusetzen. Audio kann man mit dem Arduino mittels einer Library von einer (micro) SD Karte abspielen. Check.

Licht ist sowieso kein Problem. Die Spots, die auch bei der oben abgebildeten Bühne zum Einsatz kommen kann man einfach mit LEDs bestücken und die Steuerung kenne ich ja schon von meiner HUEify-Serie.

Alle weiteren Funktionen haben sich dann durch Stöbern bei eBay ergeben. Hier der volle Funktionsumfang, der letztlich in der fertigen Bühne steckt:

  • Musik von microSD-Karte abspielen
  • Button für Play/Next/Stop
  • Sound Sensor, der die Umgebungsgeräusche erkennt
  • Sensitivity-Regler für den Sound Sensor
  • Umschalter zwischen internem/externem Audio
  • LED-Spots (jeweils 3 blaue, 3 rote und 3 gelbe, pro Farbe steuerbar, naja, fast…)
  • LED-Ringe als Bühnenhintergrund (hinter milchig geschliffenem Acrylglas), LEDs einzeln ansteuerbar
  • Drehbare Diskokugel mit seperaten weißen Spots

Das ist es grob. Hier einmal das Backpanel:

Backpanel

Von oben nach unten:
Taster: Audio Playback (kurzes Drücken=Play/Next, langes Drücken=Stop)
Kippschalter: Input Switch (links=interne Audio-Wiedergabe, rechts=externer Sound)
Potentiometer: Sensitivity für externen Sound (regelt, ab welcher Lautstärke auf Sound reagiert wird)
Kabeldurchführung: ein Flaschengummi von einer Flensflasche (bzw. einem Alster, da es ein blaues Gummi hatte)

Als Abschluss für heute gibt es noch ein Video (Music: Monkey Fly – Whatever  – www.monkeyfly.de):

In der nächsten Woche geht es dann mit Detailberichten weiter. Ich habe einige Teile bereits vorgeschrieben, allerdings geht es da eher um den eher trockenen Software-Part. Ich versuche möglichst erst die spannenden Dinge zu dokumentieren und eine einigermaßen sinnvolle Reihenfolge hinzubekommen. Außerdem wird es diese Einführung spätestens am Wochenende noch auf Englisch geben, da alle anderen Teile ebenfalls in englischer Sprache erscheinen werden.

052117_1850_TinkeringTu1.jpg

Tinkering Tuesday – HUEify – JN5169 Xiaomi Smart Button – Part 1 – Making a connection

This is a side project to the original HUEify series on connecting a custom light to the HUE ecosystem. On the site http://faire-ca-soi-meme.fr/ there are some articles about what’s inside the Smart Home Gadgets of Xiaomi (at the end of this I provide all the links currently available). Every single piece is taken apart and detailed pictures were taken describing all the identifiable parts. With my little bit french from school even I can read through it. But maybe Google Translator may help others.

I decided to order two pieces because they were very cheap at Gearbest at that time and they would make a perfect match to the nightpanel lights I am currently building and replace the currently used Amazon Dash button. And because they just arrived and I am waiting for PeeVeeOne to publish his solution for the Multiple Endpoint RGB lights on the JN5168, I will now try my luck with the Xiaomi button to see whether I can get it to communicate with Hue.

On faire-ca-soi-meme there are several detailed images of the button and also the pinout from the test pins. Unfortunately these are pogo pins and my tries to solder a wire to them were not very successful. I was successful though with using jumper wires to connect 3.3V and GND to the battery connector, hot-glueing two jumper wires together in the right spacing and forcing it to the pogo pin connectors for RX and TX with a soldering hand. The fifth pin that is required is only temporary and is the SPIMISO pin next to RX/TX. Just shortly connect a ground wire to it when connecting the power (even with my shaky hand that works).

If that is done right you can open the Device Info in NXP Beyond Studio (use 1000000 Baud and the correct COM Port):

I then compiled the Controller_OnOffSensor Demo app from NXP although in the documentation it is only described to work with the JN5168 demo hardware. I used the compile flag for the JN5169 and it compiled successfully. There is an error when flashing the firmware with the flash utility from BeyondStudio but this is only the validation after flashing. The reason is that the chip was read-protected from Xiaomi in order to make reengineering their firmware impossible (or not-so-easy). So the flashing was successful which can be seen from the serial monitor after rebooting:

APP: Switch Power Up...........................(several dots more)
Heap size at step 1 is 11412 bytes (start=04003fe4 end=04006c78)
APP: Watchdog timer has reset device!
Heap size at step 2a is 11412 bytes (start=04003fe4 end=04006c78)
Heap size at step 3 is 11412 bytes (start=04003fe4 end=04006c78)
Heap size at step 4 is 11412 bytes (start=04003fe4 end=04006c78)
Heap size at step 5 is 8216 bytes (start=04004c60 end=04006c78)
Heap size at step 6 is 8216 bytes (start=04004c60 end=04006c78)
Starting Touch Interface...

This ouput is repeated from the timer resetting the device. There seems to be something wrong. The last output message can be found and after that the drivers eTouchInit method is called. I added some debug output and commented out the first for loop (is this a delay or what is that for?):

This results in the following output (the BWE was added because I wanted to be sure I have the correct call):

APP: Switch Power Up...........................(several dots more)
Heap size at step 1 is 11428 bytes (start=04003fd4 end=04006c78)
APP: Watchdog timer has reset device!
Heap size at step 2a is 11428 bytes (start=04003fd4 end=04006c78)
Heap size at step 3 is 11428 bytes (start=04003fd4 end=04006c78)
Heap size at step 4 is 11428 bytes (start=04003fd4 end=04006c78)
Heap size at step 5 is 8232 bytes (start=04004c50 end=04006c78)
Heap size at step 6 is 8232 bytes (start=04004c50 end=04006c78)
Starting Touch Interface...BWE
Starting vTouchInitHardware
Stoping vTouchInitHardware

So there seems to be something wrong with the for-loop. Maybe it tries to read from a wrong pin (because it was made for the JN5168). I will have to take a closer look at the driver and see what I can do. I think I have to understand how it is working first (it is build for a remote control with several buttons so I guess a more simple solution has to be found). I also have to see which DIO pin the buttons are connected to…

In parallel there are also some comments from lucac81 on peeveeone.com about using the JN5169 and Peter also wrote that he ordered some, so maybe the master is faster than me 😀 lucac81 had trouble even installing the light firmware compiled for the JN5169 so maybe I will even try flashing that on the chip to see what happens with the button (just to see if it works, of course I will not use a button to make a light…). I also remember a comment asking about using the chip as a switch for HUE. So maybe someone else is also making progress on this end. I am open for any discussion/help/input.

To be continued sooner or later.

UPDATE

I flashed the JN5169 binary provided by Peter on the Xiaomi SmartHome button but it didn’t join. Unfortunately the debug output on that build doesn’t provide much information.
I build a new one from the demo application with all debugs enabled and the keys in place as I did with the JN5168 but I am getting the same output I had when not correctly putting the keys in place the first time with the JN5168 (see my post http://www.boriswerner.eu/tinkering-tuesday-hueify-making-the-custom-binary-and-the-demo-app-work-on-the-jn5168/):

Try To join 6a075d40c86781e on Ch 11
Try join status 00
Join failed ad

I already researched the error code „ad“ before:

ZPS_APL_APS_E_SECURITY_FAIL: An APSDE-DATA.request requesting security has resulted in an error during the corresponding security processing.

Which definitely hints to a key problem. So the general function is there and it even tries to connect to the bridge but get’s a bad response. That can’t be everything here 😉

 

Links

http://faire-ca-soi-meme.fr/domotique/2017/05/09/test-xiaomi-power-socket/

http://faire-ca-soi-meme.fr/hack/2017/04/24/hack-xiaomi-mi-smarthome-decouverte-de-clef/

http://faire-ca-soi-meme.fr/domotique/2017/04/15/test-xiaomi-mijia-6-in-1-smart-home/

http://faire-ca-soi-meme.fr/domotique/2017/04/04/detournement-capteur-de-mouvement-xiaomi/

http://faire-ca-soi-meme.fr/domotique/2017/03/13/hack-xiaomi-mi-smarthome-zigbee-sniffer/

http://faire-ca-soi-meme.fr/domotique/2017/02/27/hack-xiaomi-mi-smart-temperature-and-humidity-sensor/

JN5169 discussion on https://peeveeone.com/?p=187&

050317_1802_TinkeringTu1.jpg

Tinkering Tuesday – HUEify – PWM to RGB LED strip driver Board

Today I want to show you the board that I created in order to drive 4 RGB LED strips from 16 PWM outputs of the Arduino Mega. It is not the best design as this is my first board and I began without really knowing how to connect the strips in the end 😉 This board connected to the Arduino Mega controlled by the output of the JN5168 will then be the final solution to integrate light in to our nightstands.

I built the design in fritzing so let’s have a look at it:

  • J3, J5, J7, J9 are the connectors (male pin headers) for the PWM pins from the Arduino Mega
  • J2, J4, J6, J8 are also male pin headers to connect the RGB strips
  • J1 ist the input for the external power source (5V in my case) also as male pin headers
  • J22 are additional ground pins to connect the ground from the Arduino (I connected three because you never know…)
  • Q1 – Q12 are MOSFETs, in my case BUZ11

On the board I put all ground connections to the second PCB side (orange) so the connections are clear.

When I had already started soldering the board I thought about how I wanted to connect the RGB strips in the final setup and I decided to go with commonly available 4 wire RGB strip cable (can be found on ebay) and connect it via screw terminals. I was not able to change the design I already started so I just added another board (in the end I had enough space on the same board) which had four 4-pin headers again directly connected to four 4-output (okay, it’s eight 2-output) screw terminals:

I did not put much effort in making the fritzing pretty so the schematic view is a real mess and in the breadboard view I just used perfboard without any wire connections. So essentially just use the PCB view. It should be obvious. Anyway I would modify the board to make direct connections to the screw terminals if you want to use it. But it is working now and it is my first completely self designed and soldered board J

You can download the fritzing file here: 16PWMIn_4RGBOut

This is the progress with the first working module (I already showed a work in progress version in the previous post):

This is the final board including all terminals and pin headers. I even have space to include the logic level converter (LLC) that I need for the JN5168. This way I can directly connect the grounds all on this board. This is not yet soldered because I ran out of solder wire.

This is the board connected to the Arduino and currently directly from the pin headers to the RGB strips.

I put together a small sketch that activates the colors one after the other on all 4 strips. You can download it here: Arduino_Mega_4_RGB_Strip_Color_Test

This is a video of the Arduino Mega controlling all 4 strips via PWM signals from 16 pins:

Next task is to solder the LLC and reconnect the JN5168. Then I have to prepare the wires to connect from the screw terminals to the RGB strip (needs a little soldering and heat shrink tubing). This will then suffice to control all 4 strips with the same setting (one endpoint) but the final piece will then be to create 4 endpoints on the JN5168 to control the 4 strips independently.

042117_1148_TinkeringTu2.jpg

Tinkering Tuesday – HUEify – JN5168 to Arduino Mega PWM extension

The JN5168 chip itself has only 5 PWM outputs and thus is not able to control more than one RGB LED strip. To overcome this I want to connect an Arduino Mega to the JN5168. The Mega has 15 PWM outputs so up to 5 RGB strips can be connected. To connect the two devices I chose to use the standard UART serial interface that is activated by default in the NXP demos. In this post I will describe how to connect the two devices and what to do to make the Arduino understand commands from the JN5168.

Hardware serial connection from JN5168 to the Arduino

As the Arduino is using 5V level on the serial connection and the JN5168 is using 3.3V a logic level converter (LLC) has to be used. This little device connects the two serial interfaces shifting from 5V to 3.3V. The connection can be seen in the following image (to drive the JN5168 from the Arduino connect an additional wire from the 3V3 pin of the Arduino to PIN 17 of the JN5168):

Connecting the JN5168 to the Arduino Mega via logic level converter
Connecting the JN5168 to the Arduino Mega via logic level converter

Software serial connection from JN5168 to the Arduino (JN5168 program)

I used the default UART port of the JN5168 because of two reasons:

  1. It is activated by default and the demos are already making use of the output
  2. I didn’t connect any additional wires than the ones that need to be connected to flash the chip and use the PWM output and the default UART is also used to flash the firmware

To have a more stable connection to the Arduino I reduced the baud rate from 115600, which is the default rate, to 9600 which the Arduino can handle better. To do this in the file app_start_light.c go to the function vAppMain() and search for the line :

DBG_vUartInit(DBG_E_UART_0, DBG_E_UART_BAUD_RATE_115200);

and change it to:

DBG_vUartInit(DBG_E_UART_0, DBG_E_UART_BAUD_RATE_9600);

Do the same in the function vInitialiseApp() in the same file.

I tried two different approaches to send output to the arduino:

  1. Use the debug output of the TRACE_LIGHT_TASK / DEBUG_LIGHT_TASK
  2. Define a custom debug flag to directly output the PWM signal.

As I didn’t have success yet creating multiple RGB endpoints and am waiting for PeeVeeOne to publish his work on multiple endpoints, I first went with option 2 which is currently not able to hand over an identifier for the endpoint which the option 1 is able to. The second option has the advantage that it handles smooth transitions, which the other one doesn’t. Once I am able to create more endpoints I may create another output. I will describe both solutions anyway:

Option 1: TRACE_LIGHT_TASK

First, activate the debug flag in the Makefile:

CFLAGS += -DDEBUG_LIGHT_TASK

Then go to the file app_zcl_light_task.c and search for

DBG_vPrintf(TRACE_LIGHT_TASK

I modified the first appearance (in APP_ZCL_cbEndpointCallback) of the function, where it outputs a new line and the RGBL (Red, Green, Blue, Level) values to include an identifiying symbol (§) and the endpoint:

DBG_vPrintf(TRACE_LIGHT_TASK, "\n§ EP %d R %d G %d B %d L %d ",
psEvent->u8EndPoint, u8Red, u8Green, u8Blue, sLight.sLevelControlServerCluster.u8CurrentLevel);

There is a second appearance in the same file and the same function (APP_ZCL_cbEndpointCallback ) where I did the same thing again.

In the file App_Light_ColorLight.c there are two other usages of the function which handle the identification effect. In the function APP_vHandleIdentify() there is currently no handle for the endpoint available so I didn’t modify this one. In the vIdEffectTick() there is an endpoint reference available so I added this similar to the function call above.

DBG_vPrintf(TRACE_LIGHT_TASK, "§ EP %d R %d G %d B %d L %d Hue %d Sat %d\n",
u8Endpoint,
u8Red,
u8Green,
u8Blue,
sLight.sLevelControlServerCluster.u8CurrentLevel,
sLight.sColourControlServerCluster.u8CurrentHue,
sLight.sColourControlServerCluster.u8CurrentSaturation);

In the end the Arduino will receive a message will look like this:

§ EP 10 R 255 G 227 B 139 L 147 Hue 0 Sat 0 X 24939 Y 24701 M 1 On 1 OnTime 0 OffTime 0

This one call will result in 10 PWM changes in the JN5168 to have a nice transition. This is why I currently go with the second option:

Option 2: TRACE_PWM

First, I defined and enabled a new debug flag in the Makefile:

CFLAGS += -DDEBUG_PWM

Then in the file DriverBulb_JN516X_RGB.c I added the following to the definition section at the beginning:

#ifdef DEBUG_PWM
#define TRACE_PWM TRUE
#else
#define TRACE_PWM FALSE
#endif

Then, in the function DriverBulb_vOutput() I added the following after the calls to vAHI_TimerStartRepeat at the end:

#if TRACE_PWM
DBG_vPrintf(TRACE_PWM, "\n# EP %d On %d R %d G %d B %d L %d",
(uint8)10,
bIsOn,
u8Red,
u8Green,
u8Blue,
u8CurrLevel
);
#endif

Together with the first option this will result in the following output (as I said it produces a smooth transition):

§ EP 10 R 255 G 227 B 139 L 147 Hue 0 Sat 0 X 24939 Y 24701 M 1 On 1 OnTime 0 OffTime 0
# EP 10 On 1 R 170 G 151 B 92 L 170
# EP 10 On 1 R 167 G 148 B 91 L 167
# EP 10 On 1 R 165 G 146 B 89 L 165
# EP 10 On 1 R 162 G 144 B 88 L 162
# EP 10 On 1 R 160 G 142 B 87 L 160
# EP 10 On 1 R 157 G 139 B 85 L 157
# EP 10 On 1 R 154 G 137 B 83 L 154
# EP 10 On 1 R 152 G 135 B 82 L 152
# EP 10 On 1 R 149 G 132 B 81 L 149
# EP 10 On 1 R 147 G 130 B 80 L 147

You can also see that the RGB values changed. This is according to the level value. The calculation is:

/* Scale colour for brightness level */
u8Red = (uint8)(((uint32)u8CurrRed * (uint32)u8CurrLevel) / (uint32)255);
u8Green = (uint8)(((uint32)u8CurrGreen * (uint32)u8CurrLevel) / (uint32)255);
u8Blue = (uint8)(((uint32)u8CurrBlue * (uint32)u8CurrLevel) / (uint32)255);

The level is not really necessary in the output because the RGB values are already adjusted. I kept them anyway.

Software serial connection from JN5168 to the Arduino (Arduino program)

For the Arduino part I first setup the serial connection (I connected it to Serial2) and read the input. Based on the first character (§ or # are the relevant ones for the two options) the program decides whether the whole line is relevant.

Then it parses the input line using the function strtok(). Then I set the PWM using analogWrite(pin, value).

The serial input is lagging sometimes (though I think this is only the case when using the serial output to the other serial port) so garbage is getting read as a line. In case of not set values I checked whether the value is correctly set. Otherwise the old value is used. This may lead to wrong values but better than nothing.

My currently used Arduino sketch (using only one PWM output) can be downloaded here:

SerialReadPWMFromJN5168

Conclusion

This may not be the best way of communication (SPI may be better) but it is the easiest to setup. To command 4 separate endpoints I may have to use option 1 and go without transitions or implement them myself on the arduino. The bottle neck seems to be the serial connection as the arduino seems to be too slow to process the serial input fast enough. This is another argument for option 1 as it sends fewer lines. Although it is sending more than one line for a simple light change, too. Maybe the app itself also sends several commands to have a nice transition. I may check this later on. In any case I recommend disabling all other debug outputs to make better use of the serial communication and loose fewer lines.

Currently I am also building a board to connect everything together. It will not be very professional (as I will be using many jumper wires instead of connecting everything directly but I want to be flexible) but should work for me. It will be hidden away anyway. The board connected to the Arduino and the serial connection to the JN5168 can be seen in the upper left with one temporarily connected RGB strip. In the final version they will be connected with screw terminals. The LLC will also go from the breadboard to the custom board.

The completed serial connection from JN5168 to Arduino Mega and custom PWM to RGB LED adapter board
The completed serial connection from JN5168 to Arduino Mega and custom PWM to RGB LED adapter board

This is the current progress with connections ready for two RGB strips.

Custom PWM to RGB LED strip adapter board (work in progress)
Custom PWM to RGB LED strip adapter board (work in progress)

There will be 4 RGB connections in the final version to be connected with screw terminals, the LLC and a connection for an external power source. This is all still work in progress so I will publih the final schematics when I am ready and know that everything is working as expected. And of course I hope that the weather will be getting better here so I can disassemble our night desks and get them to my workbench (actually my balcony which is why I am hoping for good weather 😉

Working_Prototype

Tinkering Tuesday – HUEify – Making the custom binary and the demo app work on the JN5168

Today I will describe my progress on the development of my own Hue connected lights. Because other people developing with the JN5168 are not necessarily german speakers I will continue my project (which I call HUEify) in english. There is some discussion going on at the latest post from PeeVeeOne.

As I had some trouble with the build provided by PeeVeeOne (lights not turning off, dimming and red not working properly) I had to go through the proecss of building my own binary. This was planned anyways because I have some other plans on top. This post is all about my troubles getting the demo app and a custom build project to work. This should be seen as an additional detailed description to the information that can be found at PeeVeeOne’s website and github repository. So far it is all his work that I am just setting to work on my device. The general setup of the developing environment BeyondStudio and the demo application is described in this post by PeeVeeOne.

Building the binaries

First of all I had some trouble building the binaries from both the NXP demo and the github project PeeVeeOne supplied. Both were not joining the Hue bridge and were not giving any debug information, though the binary directly downloaded from PeeVeeOne was doing both without any issues.

The build of the NXP Demo Application (JN-AN-1171) is defaulted to create a binary for the JN5169. To change this I changed the default in the Makefile (Common_Light/Build) to 5168:

But that is not enough as the builder is getting the command additionally (mind the configuration in the dropdown at the top of the window) In the project properties you have to change the Build command:

Now the correct binary will be build.

Sometimes I had the binary not correctly rebuild after changes as it didn’t recognize any changes (nothing new to build). Then it helped not to use the normal „Build“ but the „Build selected“ and choosing the options „Clean selected configurations“ and „Build selected configurations“:

Debugging the Demo Application and making it work

To trace the startup and the connection you can leave the USB serial converter (FT232) wired to the chip after flashing the binary. It will send debug information which you can read at your PC. I use the serial monitor from the Arduino IDE (you have to close the monitor before flashing the binary because it will lock the serial connection and you get an access error).

In the default of the demo application and the PeeVeeOne github rep the debugs are not enabled. To do this, just uncomment the options in the Makefile (you don’t need all of them, actually I use only some from the first block, check the source code for the relevant ones):

It will show something like this:

This is the debug output when starting the device with no search for new devices from the Hue bridge. It goes through all channels serching for something to connect to.

With a search from the bridge started instead of

***********************************************
LIGHT NODE RESET
***********************************************
Disc st 0 c 1 sel 255
Pan 6a075d40c856781e Ch 11 RCap 3 PJoin 0 Sfpl 2 ZBVer 2
No more nwks to try

I got the following output from the demo application:

***********************************************
LIGHT NODE RESET
***********************************************
Disc st 0 c 1 sel 0
Pan 6a075d40c856781e Ch 11 RCap 1 PJoin 1 Sfpl 2 ZBVer 2
Try To join 6a075d40c86781e on Ch 11
Try join status 00
Join failed ad
No more nwks to try

So it seems like 6a075d40c856781e is the ID of my bridge. When not searching for devices it recognizes it but is not trying to join. When searching for devices it is trying but it is not successful.

This was all from my office room which is located at the other end of our appartment. Moving closer to the bridge the original binary from PeeVeeOne successfully joined and I get the following output:

Discover on ch 11
disc status 00
Disc st 0 c 1 sel 0
Pan 6a075d40c856781e Ch 11 RCap 2 PJoin 2 Sfpl 2 ZBVer 2
Try To join 6a075d40c856781e on Ch 11
Try join status 00
Joined as Router

I was searching the error message and found the lines in the code that output it:

if (sStackEvent.eType == ZPS_EVENT_NWK_FAILED_TO_JOIN) {
DBG_vPrintf(TRACE_CLASSIC, "Join failed %02x\n", sStackEvent.uEvent.sNwkJoinFailedEvent.u8Status );
vTryNwkJoin();
}

Having a closer look at the error message in the output it gave the two letters „ad“ after the „Join failed“. This was actually an error code. In the User Guide of the ZigBee PRO Stack (JN-UG-3101) I was able to find the code (9.2.2 APS Codes):

ZPS_APL_APS_E_SECURITY_FAIL: An APSDE-DATA.request requesting security has resulted in an error during the corresponding security processing.

This made me think of a post at PeeVeeOne’s about Keys. And voila, using the keys in the right places (zpr_light_node.c and app_light_commission_task.c) it successfully joined. Sometimes it’s just careful reading. 

Custom Build from PeeVeeOne

I also applied the debugging to the repository from PeeVeeOne’s github and was moving closer to the bridge so it finally joined my hue bridge. The problems I described in my last post (dimming and the color red not properly working and turning of the light not working) was caused by the inverting of the PWM signal PeeVeeOne was applying. I already had that in mind when turning of the light in the App caused the lights to turn bright. So switching the signal did the trick. In the file DriverBulb_JN516X_RGB.c go to line 57 and modify the value from TRUE to FALSE:

The final outcome can be seen in this youtube video:

Next steps

Until now it was all about the initial setup. But this is where the fun begins. Now I can program the device to my likes and I already have something in mind. I hope to find the time to try it soon. There are some more blog posts about the development, based on PeeVeeOne’s findings, e.g. SevenWatt hacking a SmartPlug from Innr. I am looking forward to see the other projects.

My goal is to use the JN5168 with multiple endpoints configured to act as not only one light to the hue bridge but as several (e.g. to separately control all 4 parts of our nightstands). PeeVeeOne is also working in this direction with controlling 4 dimmable lights with one module. I have some other ideas I first have to check for feasibility and then there will be updates here.