-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
551 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Custom light instruction | ||
|
||
This build is for: https://github.com/mariusmotea/diyHue/tree/master/Lights/Arduino/Generic_Dimmable_Light | ||
|
||
1. try out your parts and plan pathways | ||
|
||
2. solder gnd/- pathway and the 1k OHM resistors in place | ||
|
||
3. fasten wemos headers, and connect G pin to ground pathway | ||
|
||
4. Bring a wires from GPIO pins to the paths with resistors | ||
|
||
5. Fasten the blue cables (these go to the - of your strip(s)) (the board in the picture will have 2 individual controlable lights, you can have multiple strips on each) | ||
|
||
7. Fasten 3 pin headers for mosfets | ||
|
||
8. Connect the various paths to 3 pin headers | ||
|
||
9. Done | ||
|
||
|
||
This build is very simular to the Generic RGBW light build. (didnt take picture with the mosfets and wemos inserted, but i guess this can be imagined) make sure the G pin on the wemos hits the grounded path. | ||
|
||
![Top](https://github.com/mariusmotea/diyHue/blob/master/Lights/Arduino/Generic_Dimmable_Light/images/Over.jpg?raw=true) | ||
![Back](https://github.com/mariusmotea/diyHue/blob/master/Lights/Arduino/Generic_Dimmable_Light/images/Under.jpg?raw=true) | ||
|
||
## Components | ||
[IRLB8721-TO220 MOSFETS (2x)](https://www.aliexpress.com/item/10PCS-IRLB8721-TO220-IRLB8721PBF-TO-220-free-shipping/32714364118.html) | ||
|
||
[Wemos D1 mini (1x)](https://www.aliexpress.com/item/ESP8266-ESP12-ESP-12-WeMos-D1-Mini-WIFI-Dev-Kit-Development-Board-NodeMCU-Lua/32653918483.html) | ||
|
||
[1k OHM resistor (2x)](https://www.aliexpress.com/item/100pcs-1-4W-Metal-Film-Resistor-1K-ohm-1KR-1-Tolerance-Precision-RoHS-Lead-Free-In/1851964338.html) | ||
|
||
[Female Headers (2x)](https://www.aliexpress.com/item/10-10-pcs-Single-Row-Pin-Female-Header-Socket-2-54mm-Pitch-1-10p-12p-20p/32783590196.html) | ||
|
||
[Prototyping board (1x)](https://www.aliexpress.com/item/20pcs-5x7-4x6-3x7-2x8-cm-double-Side-Copper-prototype-pcb-Universal-Board-for-Arduino/1847727667.html) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
234 changes: 234 additions & 0 deletions
234
Lights/Arduino/Generic_ON_OFF_device_433Mhz/Generic_ON_OFF_device_433Mhz.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
|
||
|
||
/* | ||
This can control bulbs with 5 pwm channels (red, gree, blue, warm white and could wihite). Is tested with MiLight RGB_CCT bulb. | ||
*/ | ||
|
||
#include <ESP8266WiFi.h> | ||
#include <ESP8266mDNS.h> | ||
#include <WiFiUdp.h> | ||
#include <ArduinoOTA.h> | ||
#include <ESP8266WebServer.h> | ||
#include <WiFiManager.h> | ||
#include <EEPROM.h> | ||
#include <RCSwitch.h> | ||
|
||
RCSwitch mySwitch = RCSwitch(); | ||
|
||
#define devicesCount 4 | ||
|
||
uint8_t devicesPins[devicesCount] = {12, 13, 14, 5}; | ||
|
||
uint8_t transmitterPin = 4; //Pin the Transmitter is attached to | ||
uint8_t transmitterDelay = 100; // Delay between sending commands | ||
uint8_t repeatTransmit = 2; // Number of Transmit attempts (sometimes one Transmit is not enough) | ||
|
||
char* deviceId[] = {"10000", "01000", "00100", "00010"}; // Button Codes | ||
char* houseCode = "11110"; //Housecode set in Handheld Remote | ||
int c; | ||
|
||
|
||
|
||
|
||
// if you want to setup static ip uncomment these 3 lines and line 72 | ||
//IPAddress strip_ip ( 192, 168, 10, 95); | ||
//IPAddress gateway_ip ( 192, 168, 10, 1); | ||
//IPAddress subnet_mask(255, 255, 255, 0); | ||
|
||
bool device_state[devicesCount]; | ||
byte mac[6]; | ||
|
||
ESP8266WebServer server(80); | ||
|
||
void handleNotFound() { | ||
String message = "File Not Found\n\n"; | ||
message += "URI: "; | ||
message += server.uri(); | ||
message += "\nMethod: "; | ||
message += (server.method() == HTTP_GET) ? "GET" : "POST"; | ||
message += "\nArguments: "; | ||
message += server.args(); | ||
message += "\n"; | ||
for (uint8_t i = 0; i < server.args(); i++) { | ||
message += " " + server.argName(i) + ": " + server.arg(i) + "\n"; | ||
} | ||
server.send(404, "text/plain", message); | ||
} | ||
|
||
void SwitchOn433(uint8_t c) { | ||
|
||
for (int x = 0; x < repeatTransmit; x++) { | ||
|
||
mySwitch.switchOn(houseCode, deviceId[c]); | ||
delay(transmitterDelay); | ||
|
||
} | ||
|
||
} | ||
void SwitchOff433(uint8_t c) { | ||
|
||
for (int x = 0; x < repeatTransmit; x++) { | ||
|
||
mySwitch.switchOff(houseCode, deviceId[c]); | ||
delay(transmitterDelay); | ||
|
||
} | ||
} | ||
|
||
|
||
void setup() { | ||
EEPROM.begin(512); | ||
Serial.begin(115200); | ||
mySwitch.enableTransmit(transmitterPin); | ||
|
||
for (uint8_t ch = 0; ch < devicesCount; ch++) { | ||
pinMode(devicesPins[ch], OUTPUT); | ||
} | ||
|
||
//WiFi.config(strip_ip, gateway_ip, subnet_mask); | ||
|
||
|
||
if (EEPROM.read(1) == 1 || (EEPROM.read(1) == 0 && EEPROM.read(0) == 1)) { | ||
for (uint8_t ch = 0; ch < devicesCount; ch++) { | ||
digitalWrite(devicesPins[ch], OUTPUT); | ||
} | ||
|
||
} | ||
|
||
WiFiManager wifiManager; | ||
wifiManager.autoConnect("New Hue Device"); | ||
|
||
WiFi.macAddress(mac); | ||
|
||
// Port defaults to 8266 | ||
// ArduinoOTA.setPort(8266); | ||
|
||
// Hostname defaults to esp8266-[ChipID] | ||
// ArduinoOTA.setHostname("myesp8266"); | ||
|
||
// No authentication by default | ||
// ArduinoOTA.setPassword((const char *)"123"); | ||
|
||
ArduinoOTA.begin(); | ||
|
||
|
||
server.on("/set", []() { | ||
uint8_t device; | ||
|
||
for (uint8_t i = 0; i < server.args(); i++) { | ||
if (server.argName(i) == "light") { | ||
device = server.arg(i).toInt() - 1; | ||
} | ||
else if (server.argName(i) == "on") { | ||
if (server.arg(i) == "True" || server.arg(i) == "true") { | ||
if (EEPROM.read(1) == 0 && EEPROM.read(0) != 1) { | ||
EEPROM.write(0, 1); | ||
EEPROM.commit(); | ||
} | ||
device_state[device] = true; | ||
digitalWrite(devicesPins[device], HIGH); | ||
SwitchOn433(device); | ||
} | ||
else { | ||
if (EEPROM.read(1) == 0 && EEPROM.read(0) != 0) { | ||
EEPROM.write(0, 0); | ||
EEPROM.commit(); | ||
} | ||
device_state[device] = false; | ||
digitalWrite(devicesPins[device], LOW); | ||
SwitchOff433(device); | ||
} | ||
} | ||
} | ||
server.send(200, "text/plain", "OK, state:" + device_state[device]); | ||
}); | ||
|
||
server.on("/get", []() { | ||
uint8_t light; | ||
if (server.hasArg("light")) | ||
light = server.arg("light").toInt() - 1; | ||
String power_status; | ||
power_status = device_state[light] ? "true" : "false"; | ||
server.send(200, "text/plain", "{\"on\": " + power_status + "}"); | ||
}); | ||
|
||
server.on("/detect", []() { | ||
server.send(200, "text/plain", "{\"hue\": \"bulb\",\"lights\": " + String(devicesCount) + ",\"modelid\": \"Plug 01\",\"mac\": \"" + String(mac[5], HEX) + ":" + String(mac[4], HEX) + ":" + String(mac[3], HEX) + ":" + String(mac[2], HEX) + ":" + String(mac[1], HEX) + ":" + String(mac[0], HEX) + "\"}"); | ||
}); | ||
|
||
server.on("/", []() { | ||
float transitiontime = 100; | ||
if (server.hasArg("startup")) { | ||
if ( EEPROM.read(1) != server.arg("startup").toInt()) { | ||
EEPROM.write(1, server.arg("startup").toInt()); | ||
EEPROM.commit(); | ||
} | ||
} | ||
|
||
for (uint8_t device = 0; device < devicesCount; device++) { | ||
|
||
if (server.hasArg("on")) { | ||
if (server.arg("on") == "true") { | ||
device_state[device] = true; | ||
digitalWrite(devicesPins[device], HIGH); | ||
|
||
SwitchOn433(device); | ||
|
||
if (EEPROM.read(1) == 0 && EEPROM.read(0) != 1) { | ||
EEPROM.write(0, 1); | ||
EEPROM.commit(); | ||
} | ||
} else { | ||
device_state[device] = false; | ||
digitalWrite(devicesPins[device], LOW); | ||
SwitchOff433(device); | ||
if (EEPROM.read(1) == 0 && EEPROM.read(0) != 0) { | ||
EEPROM.write(0, 0); | ||
EEPROM.commit(); | ||
} | ||
} | ||
} | ||
} | ||
if (server.hasArg("reset")) { | ||
ESP.reset(); | ||
} | ||
|
||
|
||
String http_content = "<!doctype html>"; | ||
http_content += "<html>"; | ||
http_content += "<head>"; | ||
http_content += "<meta charset=\"utf-8\">"; | ||
http_content += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"; | ||
http_content += "<title>Light Setup</title>"; | ||
http_content += "<link rel=\"stylesheet\" href=\"https://unpkg.com/[email protected]/build/pure-min.css\">"; | ||
http_content += "</head>"; | ||
http_content += "<body>"; | ||
http_content += "<fieldset>"; | ||
http_content += "<h3>Light Setup</h3>"; | ||
http_content += "<form class=\"pure-form pure-form-aligned\" action=\"/\" method=\"post\">"; | ||
http_content += "<div class=\"pure-control-group\">"; | ||
http_content += "<label for=\"power\"><strong>Power</strong></label>"; | ||
http_content += "<a class=\"pure-button"; if (device_state) http_content += " pure-button-primary"; http_content += "\" href=\"/?on=true\">ON</a>"; | ||
http_content += "<a class=\"pure-button"; if (!device_state) http_content += " pure-button-primary"; http_content += "\" href=\"/?on=false\">OFF</a>"; | ||
http_content += "</div>"; | ||
http_content += "</fieldset>"; | ||
http_content += "</form>"; | ||
http_content += "</body>"; | ||
http_content += "</html>"; | ||
|
||
server.send(200, "text/html", http_content); | ||
|
||
}); | ||
|
||
|
||
server.onNotFound(handleNotFound); | ||
|
||
server.begin(); | ||
} | ||
|
||
void loop() { | ||
ArduinoOTA.handle(); | ||
server.handleClient(); | ||
} | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# 433Mhz Power Socket - Control (Hue Bulb Emulation) | ||
This ESP-8266 Firmware controls generic 433Mhz Power Sockets. | ||
Showing up as regular Hue Bulbs with ON/OFF feature. | ||
|
||
* I used one of those cheap Transmitters. [Ebay-Link](https://www.ebay.com/itm/5pcs-433Mhz-RF-transmitter-and-receiver-kit-for-Arduino/381374427148?epid=2037463354&hash=item58cbaff00c:g:8wEAAOSw6EhUN9s-) | ||
* Controlling cheap 433mhz Power Sockets [Picture below] | ||
|
||
* Directly connected to VCC(+3,3V) GPIO4 (Data) and GND. | ||
* You need to Edit your **"House Code"** in order to control the correct Sockets! | ||
|
||
|
||
<center> | ||
<img src="https://cdn.instructables.com/FU4/UJYA/HM8DG3Q3/FU4UJYAHM8DG3Q3.MEDIUM.jpg" width="250"> | ||
<br> | ||
</br> | ||
<img src="https://glsk.net/wp-content/uploads/2016/08/433mhz_sockets.jpg" width="300"> | ||
<br> | ||
</br> | ||
|
||
<div style='float: center'> | ||
<img style='width: 300px' src="images/Fritzing.JPG"></img> | ||
</div> | ||
<br> | ||
</br> | ||
<div style='float: center'> | ||
<img style='width: 300px' src="images/Schematic.JPG"></img> | ||
</div> | ||
<br> | ||
</br> | ||
<div style='float: center'> | ||
<img style='width: 300px' src="images/PCB1.jpg"></img> | ||
</div> | ||
<br> | ||
</br> | ||
<div style='float: center'> | ||
<img style='width: 300px' src="images/PCB2.jpg"></img> | ||
</div> | ||
|
||
</center> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.