diff --git a/examples/Example projects/Community projects/LedStripDriver_OpenSmart/LedStripDriver_OpenSmart.ino b/examples/Example projects/Community projects/LedStripDriver_OpenSmart/LedStripDriver_OpenSmart.ino new file mode 100644 index 0000000..c4454a2 --- /dev/null +++ b/examples/Example projects/Community projects/LedStripDriver_OpenSmart/LedStripDriver_OpenSmart.ino @@ -0,0 +1,118 @@ +/* + Homey Arduino library + Usage example for use with Wemos D1 and Led Strip Driver (open-smart) + + Homey library: https://github.com/athombv/homey-arduino-library + Driver for P9813 chip: ChainableRGB: https://github.com/pjpmarques/ChainableLED + + Hardware: + - WeMos D1 mini V2 + - RGB LED Strip Driver Module Shield + - Wemos ralais shield (optional) + +*/ + +#include //ESP8266 library +#include //ESP8266 library +#include //Athom Homey library +#include //P9813 driver library + +//configuration LED driver +#define NUM_LEDS 1 //number of leds (chips) in series +#define LED_PIN_C D3 //clock pin +#define LED_PIN_D D4 //data pin +#define RELAY_PIN D1 //relay shield + +boolean ledOnOff = false; +float ledHue = 0; +float ledSaturation = 0; +float ledBrightness = 0; + +ChainableLED leds(LED_PIN_C, LED_PIN_D, NUM_LEDS); + +IPAddress ip; + +//Arduino functions +void setup() { + Serial.begin(115200); + Serial.println("Connecting to wifi..."); + + //Connect to network + WiFi.begin("your SSID", "your password"); + while (WiFi.status() != WL_CONNECTED) { + delay(200); + Serial.print("."); + } + //Print IP address + ip = WiFi.localIP(); + Serial.print("IP address: "); + Serial.println(ip.toString()); + + //Start Homey library + Homey.begin("Arduino LedStrip"); + Homey.setClass("light"); + Homey.addCapability("onoff", setLightOnoff); //boolean + Homey.addCapability("dim", setLightDim); //number 0.00 - 1.00 + Homey.addCapability("light_hue", setLightHue); //number 0.00 - 1.00 + Homey.addCapability("light_saturation", setLightSaturation); //number 0.00 - 1.00 + + //initialise LED driver library + leds.init(); + + //define relais pin + pinMode(RELAY_PIN, OUTPUT); + + Homey.setCapabilityValue("onoff", ledOnOff); //Set initial value + Homey.setCapabilityValue("dim", ledBrightness); //Set initial value + Homey.setCapabilityValue("light_hue", ledHue); //Set initial value + Homey.setCapabilityValue("light_saturation", ledSaturation); //Set initial value + + Serial.println("Setup completed"); +} + +void loop() { + Homey.loop(); +} + +void SendColorToLeds(){ + float tmpHue = mapfloat(ledHue, 0.00, 1.00, 1.00, 0.00); + float tmpBrightMax = mapfloat(ledSaturation, 0.00, 1.00, 1.00, 0.50); + float tmpBrightness = mapfloat(ledBrightness, 0.00, 1.00, 0.00, tmpBrightMax); + + if(ledOnOff){ + for (byte i=0; i + this shield is based on the P9813 chip +* [DC/DC converter](https://nl.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180102232329&SearchText=DC+DC+Step+Down+Buck+Converter)
+ the leds works on 12 volt but the WeMos needs 5 volt. 500mA is more than enough +* [12v DC wall-plug adapter](https://nl.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180102234456&SearchText=12+volt+power+supply)
+ The power (amperes) you need depending on the amount of LEDs. +* [RGB ledstrip](https://nl.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180102234421&SearchText=led+strip+SMD+5050)
+ Use RGB led stript, not the RGBW. + +Optional part +* [Wemos relais shield](https://nl.aliexpress.com/wholesale?catId=0&initiative_id=SB_20180107000934&SearchText=wemos+relais+shield)
+ If you have 12 volt lighting that you want to turn on immediately when you switch on the RGB LED strip you can connect an extra relais to the Wemos by an relais shield. If you want to use something else like a Arduino relais shield watch out for the voltage because the Wemos runs on 3.3 volt. + +## 3. Software +For this project you need to add the following libraries. +* ESP8266WiFi.h
+ WeMos is based on the ESP8266 chip, therefor you need this library. +* WiFiClient.h
+ We use the Wemos as a client, Homey is the master. +* [Homey.h](https://github.com/athombv/homey-arduino-library)
+ The Homey library of course. +* [ChainableLED.h]( https://github.com/pjpmarques/ChainableLED)
+ we use this one for contolling the P9813 led driver chip. + +## 4. Connecting all the parts +* Connect the 12+ of the powersupply to the LED shield +12V and to the IN+ of the DC/DC converter. +* Connect the GND of the powersupply to the LED shield GND and to the GND of the DC/DC converter. +* Now you need to put power to the powersupply and adjust the DC/DC converter to 5 volt on the VO+ connetor. +Of course you can also use an DC/DC converter with an default 5 volt output. +* Disconnect the power. +* Connect the VO+ of the DC/DC converter to the VCC of the LED shield and to the 5V of the Wemos. +* Connect the GND of the DC/DC converter to the GND of the LED shield and to the GND (G) of the Wemos. +* Connect the D3 of the Wemos to the Cin of the LED shield. +* Connect the D4 of the Wemos to the Din of the LED shield. + +Optional +If you want to control other lights like an 12 volt christmas light you can use an Arduino Relais shield. +When turn on the RGB led strip from Homey, than automaticaly the relais will switch. +For that: +* Connect the VO+ (5volt) of the DC/DC converter to the relais shield. +* Connect then GND of the DC/DC converter to the relais shield. +* Connect the D1 of the Wemos to the Din of the relais shield. + + +| Wemos pin | Description | +|-------------|-------------------------------------------------------------------------| +| 5V | 5 volt from DC/DC converter (VO+) | +| GND (G) | GND from DC/DC converter (GND) | +| D1 | Optional to relias shield | +| D3 | Cin of LED shield => clock input | +| D4 | Din of LED shield => data input | + +![PCB](PCB_front.jpg) +![PCB](PCB_back.jpg) + +## 5. nice links +[Video how its works](https://youtu.be/M0kDY31bzbA)
+[3D box to put everything together](https://www.tinkercad.com/things/8Ej6zM3998g-homeyduino-rgb-driver-box) diff --git a/src/Homey.cpp b/src/Homey.cpp index e57df19..25d48d7 100644 --- a/src/Homey.cpp +++ b/src/Homey.cpp @@ -802,7 +802,7 @@ bool HomeyClass::_emit(const char* name, const char* argType, const String& trig yield(); /*Set value if corresponding API call exists and has value storage enabled */ - _setValue(name, argType, triggerValue, evType); + _setValue(name, argType, triggerValue, evType); /* Check if master has been configured */ if (_master_host[0]==0) return false;