Make a bedroom floorlamp with control for smooth wake-up
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
libraries.zipIRremoteESP8266 & PubSubClient libraries for Arduinox-zip-compressed - 228.48 kB - 08/24/2022 at 09:55 |
|
|
2017-11-25_MQTT_LED-lamp.inoArduino Sketchino - 10.10 kB - 08/24/2022 at 09:53 |
|
It was on an older laptop that got passed along and that I happened to get on my desk for some updates. Anyway, glad to have it. Now I can improve on it, add OTA, MQTT-autodiscover etc.
And try to ignore the big cringe you get when you see your own software from a few years ago :|
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include <PubSubClient.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
ESP8266WiFiMulti WiFiMulti;
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <IRrecv.h>
#include <IRutils.h>
#define PIN_IRLED 10
#define PIN_IRSENSOR 4
uint16_t RECV_PIN = PIN_IRSENSOR;
unsigned long previousMillis = 0;
unsigned long currentMillis = 0;
const long interval = 60000;
const char* ssid = "***";
const char* password = "***";
IPAddress mqtt_server(192,168,1,***);
char* message = "";
WiFiClient espClient;
PubSubClient client(espClient);
IRsend irsend(PIN_IRLED); // An IR LED is controlled by GPIO pin 4 (D2)
IRrecv irrecv(RECV_PIN);
decode_results results;
void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i=0;i<length;i++) {
char receivedChar = (char)payload[i];
Serial.print(receivedChar);
if (receivedChar == '0'){
Serial.println(" - Off received");
client.publish("LEDStalamp/Response"," - ALL OFF received");
irsend.sendNEC(0xFF827D, 32);
irsend.sendNEC(0xFFE817, 32);
}
if (receivedChar == '1'){
Serial.println(" - On received");
client.publish("LEDStalamp/Response"," - ALL ON received");
irsend.sendNEC(0xFF02FD, 32);
irsend.sendNEC(0xFF6897, 32);
}
if (receivedChar == 'U'){
Serial.println("RGB+ received");
client.publish("LEDStalamp/Response"," - RGB+ received");
irsend.sendNEC(0xFF3AC5, 32);
}
if (receivedChar == 'X'){
Serial.println("RGB- received");
client.publish("LEDStalamp/Response"," - RGB- received");
irsend.sendNEC(0xFFBA45, 32);
}
if (receivedChar == 'Y'){
Serial.println("RGB OFF received");
client.publish("LEDStalamp/Response"," - RGB OFF received");
irsend.sendNEC(0xFF827D, 32);
}
if (receivedChar == 'Z'){
Serial.println("RGB ON received");
client.publish("LEDStalamp/Response"," - RGB ON received");
irsend.sendNEC(0xFF02FD, 32);
}
if (receivedChar == 'R'){
Serial.println("RGB RED received");
client.publish("LEDStalamp/Response"," - RGB RED received");
irsend.sendNEC(0xFF1AE5, 32);
}
if (receivedChar == 'G'){
Serial.println("RGB GREEN received");
client.publish("LEDStalamp/Response"," - RGB GREEN received");
irsend.sendNEC(0xFF9A65, 32);
}
if (receivedChar == 'B'){
Serial.println("RGB BLUE received");
client.publish("LEDStalamp/Response"," - RGB BLUE received");
irsend.sendNEC(0xFFA25D, 32);
}
if (receivedChar == 'W'){
Serial.println("RGB WHITE received");
client.publish("LEDStalamp/Response"," - RGB WHITE received");
irsend.sendNEC(0xFF22DD, 32);
}
if (receivedChar == 'C'){
Serial.println("RGB R1 received");
client.publish("LEDStalamp/Response"," - RGB R1 received");
irsend.sendNEC(0xFF2AD5, 32);
}
if (receivedChar == 'D'){
Serial.println("RGB R2 received");
client.publish("LEDStalamp/Response"," - RGB R2 received");
irsend.sendNEC(0xFF0AF5, 32);
}
if (receivedChar == 'E'){
Serial.println("RGB R3 received");
client.publish("LEDStalamp/Response"," - RGB R3 received");
irsend.sendNEC(0xFF38C7, 32);
}
if (receivedChar == 'F'){
Serial.println("RGB R4 received");
client.publish("LEDStalamp/Response"," - RGB R4 received");
irsend.sendNEC(0xFF18E7, 32);
}
if (receivedChar == 'H'){
Serial.println("RGB G1 received");
client.publish("LEDStalamp/Response"," - RGB G1 received");
irsend.sendNEC(0xFFAA55, 32);
}
if (receivedChar == 'I'){
Serial.println("RGB G2 received");
client.publish("LEDStalamp/Response"," - RGB G2 received");
irsend.sendNEC(0xFF8A75, 32);
}
if (receivedChar == 'J'...
Read more »
Create an account to leave a comment. Already have an account? Log In.
Use mylar, like 10-20 wraps on the inside of the pipe. The cheap kind for wrapping like gift baskets in a clear-ish crunchy thing. Also, make the ends of your chamber reflective.
It creates much more internal reflection of the lights before they escape, diffusing it very effectively.
Become a member to follow this project and never miss any updates
By using our website and services, you expressly agree to the placement of our performance, functionality, and advertising cookies. Learn More
Thanks Daren! Wouldn't have thought to use mylar, so great tip. You mean the stuff they use for wrapping flower bouquets? I'll be sure to try this when I can find the time to revisit this.