alert('Hello World!');
The intro
As many online I too fancy Chinese cheap electronics. The Milight is no exception, however it does work, it is very limited:
Only four distinct groups one may control on their physical remote One-way communication between sender and receive (e.g. no feedback regarding reception of the command) This did use some frequency hopping to reduce impact of noise Limited colors to choose from.
Uses a memory function to save last options to flash. Great for intended used (100k writes on eeprom), however; not so great when used in conjunction with ambilight (10’s of updates/second) update behaviour.
During my search online, I found a lot of people who used the the awesome work from Henry Plotz https://hackaday.io/project/5888-reverse-engineering-the-milight-on-air-protocol/log/18659-let-there-be-source basically mimicking the PL1167 chips behavior using the NRFL2401 and arduino.
I took a different approach.
Re-purpose of hardware
The hardware used, is not that awefull, lets see what we got:
- A 8-bit STM8S003 controller
- a PL1167 2.4ghz Tranciever (to we can do bi-directional communications!)
- RGB and White leds
- Nice E27/GU10/E10 fittings or RGBW-driver
The microprocessor has protected memory, so we lose it’s configuration, but appart from that, its fully reprogrammable. do note, the STM8S003 is not inteded for trail-error program upload (100 write cycles!)
The journey
(As usual) I browsed eBay and bought an STM8S103, which is a major setback at 1$…. and a LT8900 (API-compatible PL1167) chip.
I installed IAR workbench (free for these tiny chips), which has great debug-capablilites; far superior to Arduino’s IDE!
Investigating the hardware
Basically the STM is connected to the LEDS via its TIMER1 and 4 Compare outputs (RGB + W) - this requires reconfiguration of option bytes! - , and a software implementation SPI interface to the PL1167.
Do note, that all datasheets encountered by me regarding the PL1167 have incorrect pin mapping!!!! took me some time to finally distrust this document, its a datasheet….
Software
SPI
So after this; I stared looking into software. As the pins are not wired to the STM8’s SPI port,as they are shared by the timer for PWM generation. We needed to write an SPI-driver for it, luckly there are plenty of examples online, so i just grabbed one (probably for an ATmega-8 chip), and modified it to work with the STM8S standard peripheral driver.
After that there was SPI Comms, woot woot.
Radio
Now it was time to get the LT8900 chip talking. Luckaly for me, this guy (Rob van der Veer) https://bitbucket.org/robvanderveer/lt8900lib wrote a driver for Arduino. So it was a matter of some copy-paste-and-slightly-modify work for me, and yeaj we have a functioning way to configure our radio chip.
PWM
Getting PWM working was rather easy; just look at some examples to get the timer running. I didn’t really made a lot of effort to get some fast timing or calculate the speeds… but it is plenty fast for led-dimming, at least, according to my eye-sight.
Communicating with my new Milight-compatible-hardware
In order to communicate with my new setup, i just took Rob’s library for the LT8900, and hooked it to an Arduino. I could just send some data on the air back and forth, so all well and dendy :)
Grab your copy
see github.com for the latest and gratest
Share this post
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Pinterest
Email