Using Supla on "Sonoff LED- WiFi Dimming LED Pack"

sw3
Posts: 6
Joined: Wed Apr 19, 2017 8:09 am

Hello guys,

thank you for providing Supla. I already have it on my Sonoff "SMART SOCKET" it works perfekt!

I now have "Sonoff LED- WiFi Dimming LED Pack" here and want to control it with supla. Is it possible to provide a Firmware for it?

product information with video:
https://www.itead.cc/sonoff-led.html

I found also this Information here on the same page:
I have shared my code here: https://github.com/jalmerot.... It's a bit rough still and lacks proper input validation. To flash the device, I soldered a PIN-header (Vcc, Tx, Rx, Gnd) to it and used my good old Arduino Uno for flashing. As mentioned above you need to reset the device and hold the button, which pulls GPIO0 low, on the back of the ESP-shield to put it into programming-mode.

The PINs that are used to control it:
PIN_BUTTON 0
PIN_LED 13
PIN_COLD 12
PIN_WARM 14

You are right that the LED are controlled by PWM and there are two separate lanes (GPIO12/GPIO14).
Enclosed also some pictures of the Remote control driver.

That would be perfekt if this device would also work with supla.
Could someone compile a Firmware for it, please?

Thank you guys
sw3
Attachments
LED Remote control driver_03.jpg
LED Remote control driver_03.jpg (49.21 KiB) Viewed 8649 times
LED Remote control driver_02.jpg
LED Remote control driver_02.jpg (43.11 KiB) Viewed 8649 times
LED Remote control driver_01.jpg
LED Remote control driver_01.jpg (74.93 KiB) Viewed 8649 times
sw3
Posts: 6
Joined: Wed Apr 19, 2017 8:09 am

Could it be that the Supla Firmware for "H801 WIFI LED CONTROLLER" could work with smal changes on "Sonoff LED- WiFi Dimming LED Pack"?
There are also RGB and WARM/COLD outgoings on the electronic-board but with different GPIOs.

H801:
J3 (jumper 3) 0
Onboard PIN_LED_GREEN 5
Onboard PIN_LED_RED 1
PIN_COLD 14
PIN_WARM 4

PIN_RED 15
PIN_GREEN 13
PIN_BLUE 12

Sonoff LED- WiFi Dimming:
PIN_BUTTON 0
Onboard PIN_LED 13
PIN_COLD 12
PIN_WARM 14

PIN_RED ?
PIN_GREEN ?
PIN_BLUE ?


I found here also an other project for this device:
https://github.com/KmanOz/SonoffLED-HomeAssistant
User avatar
pzygmunt
Posts: 18282
Joined: Tue Jan 19, 2016 9:26 am
Location: Paczków
Contact:

Try find RGB pins. Then I can prepare dedicated firmware for this device.
sw3
Posts: 6
Joined: Wed Apr 19, 2017 8:09 am

Of cource. I found them out by a continuity tester now:

PIN_RED 15
PIN_GREEN 24
PIN_BLUE 16

Thanks for your help!!
Attachments
RGB.jpg
RGB.jpg (47.4 KiB) Viewed 8602 times
Last edited by sw3 on Thu Apr 20, 2017 9:25 am, edited 1 time in total.
User avatar
pzygmunt
Posts: 18282
Joined: Tue Jan 19, 2016 9:26 am
Location: Paczków
Contact:

This is PIN or GPIO number ?
sw3
Posts: 6
Joined: Wed Apr 19, 2017 8:09 am

This are PINs
Zybi
Posts: 1511
Joined: Sun Jun 26, 2016 4:24 pm

From ITEAD web page

reserved:

RED - GPIO5
GREEN - GPIO4
BLUE - GPIO15
Attachments
PWMLED_ESP8266_Module_Wiring_Instruction.png
PWMLED_ESP8266_Module_Wiring_Instruction.png (57.86 KiB) Viewed 8584 times
User avatar
pzygmunt
Posts: 18282
Joined: Tue Jan 19, 2016 9:26 am
Location: Paczków
Contact:

Flash size ?
sw3
Posts: 6
Joined: Wed Apr 19, 2017 8:09 am

8 Mbit (Flash size) -> 1024kb

I have here also Arduino-Code was used by KmanOz
https://github.com/KmanOz/SonoffLED-HomeAssistant

Code: Select all

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

#define cLED               12                                           // Don't Change for Sonoff LED
#define sLED               13                                           // Don't Change for Sonoff LED)
#define wLED               14                                           // Don't Change for Sonoff LED)
   
#define MQTT_CLIENT        "Sonoff_LED_strip_v1.0p"                     // mqtt client_id (Must be unique for each Sonoff)
#define MQTT_SERVER        "192.168.1.100"                              // mqtt server
#define MQTT_PORT          1883                                         // mqtt port
#define MQTT_TOPIC         "homenet/sonoff_led/living_room"             // mqtt topic (Base topic)
#define MQTT_BRIGHT_TOPIC  "homenet/sonoff_led/living_room/brightness"  // mqtt topic (Brightness topic)
#define MQTT_COLOR_TOPIC   "homenet/sonoff_led/living_room/color"       // mqtt topic (Color topic)
#define MQTT_USER          "user"                                       // mqtt user
#define MQTT_PASS          "pass"                                       // mqtt password

#define WIFI_SSID          "homepass"                                   // wifi ssid
#define WIFI_PASS          "homewifi"                                   // wifi password

#define VERSION    "\n\n------------------  Sonoff LED Strip v1.0p  --------------------"

extern "C" { 
  #include "user_interface.h" 
}

bool debug = false;                                                     // True for easy access to serial window at startup
bool onAtStart = false;                                                 // True to turn on LED as soon as power is applied
bool c_enable = true;
bool w_enable = true;

int kRetries = 10;
int kUpdFreq = 1;
int bright = 255;
int color = 328;
int fadeDelay = 0;                                                      // 0 for no fade, 1 to 5 for delay to fade up & down
int nBright = 255;

unsigned long TTasks;

WiFiClient wifiClient;
PubSubClient mqttClient(wifiClient, MQTT_SERVER, MQTT_PORT);

void callback(const MQTT::Publish& pub) {
  blinkLED(sLED, 100, 1);
  if (pub.topic() == MQTT_TOPIC) {
    mqttClient.publish(MQTT::Publish(MQTT_TOPIC"/stat", pub.payload_string()).set_retain().set_qos(1));
    if (pub.payload_string() == "OFF") {
      analogWrite(cLED, 0);
      analogWrite(wLED, 0);
      Serial.println("LED Status . . . . . . . . . . . . . . . . . . . . . . . . . OFF");
    }
    else if (pub.payload_string() == "ON") {
      if (c_enable) {
        analogWrite(cLED, bright);
      }
      if (w_enable) {
        analogWrite(wLED, bright);
      }
      Serial.println("LED Status . . . . . . . . . . . . . . . . . . . . . . . . . ON");
    }
    else if (pub.payload_string() == "reset") {
      blinkLED(sLED, 400, 4);
      ESP.restart();
    }
  }
  else if (pub.topic() == MQTT_BRIGHT_TOPIC) {
    mqttClient.publish(MQTT::Publish(MQTT_BRIGHT_TOPIC"/stat", pub.payload_string()).set_retain().set_qos(1));
    nBright = pub.payload_string().toInt();
    if (nBright < bright) {
      while(nBright < bright) {
        if (c_enable) {
          analogWrite(cLED, bright);
        }
        if (w_enable) {
          analogWrite(wLED, bright);
        }
        bright--;
        delay(fadeDelay);
      }
    }
    else if (nBright > bright) {
      while(nBright > bright) {
        if (c_enable) {
          analogWrite(cLED, bright);
        }
        if (w_enable) {
          analogWrite(wLED, bright);
        }
        bright++;
        delay(fadeDelay);
      }
    }
    Serial.print("Brightness Level . . . . . . . . . . . . . . . . . . . . . . ");
    Serial.println(bright);
  }
  else if (pub.topic() == MQTT_COLOR_TOPIC) {
    mqttClient.publish(MQTT::Publish(MQTT_COLOR_TOPIC"/stat", pub.payload_string()).set_retain().set_qos(1));
    color = pub.payload_string().toInt();
    if (color >= 154 && color < 269) {
       w_enable = false;
       c_enable = true;
       analogWrite(wLED, 0);       
       analogWrite(cLED, bright);
       Serial.println("LED Colour . . . . . . . . . . . . . . . . . . . . . . . . . COLD");
    }
    else if (color >= 270 && color < 384) {
       w_enable = true;
       c_enable = true;
       analogWrite(wLED, bright);
       analogWrite(cLED, bright);
       Serial.println("LED Colour . . . . . . . . . . . . . . . . . . . . . . . . . BOTH");
    }
    else if (color >= 385 && color <= 500) {
       w_enable = true;
       c_enable = false;
       analogWrite(wLED, bright);
       analogWrite(cLED, 0);
       Serial.println("LED Colour . . . . . . . . . . . . . . . . . . . . . . . . . WARM");
    }
  }
}

void setup() {
  pinMode(cLED, OUTPUT);
  pinMode(sLED, OUTPUT);
  pinMode(wLED, OUTPUT);
  if (onAtStart) {
    analogWrite(cLED, bright);
    analogWrite(wLED, bright);
  }
  mqttClient.set_callback(callback);
  
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  
  Serial.begin(115200);
  if (debug) {
   blinkLED(sLED, 25, 120); 
  }
  digitalWrite(sLED, HIGH);
  Serial.println(VERSION);
  Serial.print("\nESP ChipID: ");
  Serial.print(ESP.getChipId(), HEX);
  Serial.print("\nConnecting to "); Serial.print(WIFI_SSID); Serial.print(" Wifi"); 
  while ((WiFi.status() != WL_CONNECTED) && kRetries --) {
    delay(500);
    Serial.print(" .");
  }
  if (WiFi.status() == WL_CONNECTED) {  
    Serial.println(" DONE");
    Serial.print("IP Address is: "); Serial.println(WiFi.localIP());
    Serial.print("Connecting to ");Serial.print(MQTT_SERVER);Serial.print(" Broker . .");
    delay(1000);
    while (!mqttClient.connect(MQTT::Connect(MQTT_CLIENT).set_keepalive(90).set_auth(MQTT_USER, MQTT_PASS)) && kRetries --) {
      Serial.print(" .");
      delay(1000);
    }
    if(mqttClient.connected()) {
      Serial.println(" DONE");
      Serial.println("\n----------------------------  Logs  ----------------------------");
      Serial.println();
      mqttClient.subscribe(MQTT_TOPIC, 1);
      mqttClient.subscribe(MQTT_BRIGHT_TOPIC, 1);
      mqttClient.subscribe(MQTT_COLOR_TOPIC, 1);
      blinkLED(sLED, 40, 8);
      digitalWrite(sLED, LOW);
      mqttClient.publish(MQTT::Publish(MQTT_TOPIC"/stat", "OFF").set_retain().set_qos(1));
      mqttClient.publish(MQTT::Publish(MQTT_BRIGHT_TOPIC"/stat", "255").set_retain().set_qos(1));
      mqttClient.publish(MQTT::Publish(MQTT_COLOR_TOPIC"/stat", "328").set_retain().set_qos(1));
      if (onAtStart) {
        mqttClient.publish(MQTT::Publish(MQTT_TOPIC"/stat", "ON").set_retain().set_qos(1));
      }
    }
    else {
      Serial.println(" FAILED!");
      Serial.println("\n----------------------------------------------------------------");
      Serial.println();
    }
  }
  else {
    Serial.println(" WiFi FAILED!");
    Serial.println("\n----------------------------------------------------------------");
    Serial.println();
  }
}

void blinkLED(int pin, int del, int n) {             
  for(int i=0; i<n; i++)  {  
    digitalWrite(pin, HIGH);        
    delay(del);
    digitalWrite(pin, LOW);
    delay(del);
  }
}

void checkConnection() {
  if (WiFi.status() == WL_CONNECTED)  {
    if (mqttClient.connected()) {
      Serial.println("mqtt broker connection . . . . . . . . . . . . . . . . . . . OK");
    } 
    else {
      Serial.println("mqtt broker connection . . . . . . . . . . . . . . . . . . LOST");
      blinkLED(sLED, 400, 4);
      ESP.restart();
    }
  }
  else { 
    Serial.println("WiFi Access Point . . . . . . . . . . . . . . . . . . . . LOST");
    blinkLED(sLED, 400, 4);
    ESP.restart();
  }
}

void loop() { 
  mqttClient.loop();
  timedTasks();
}

void timedTasks() {
  if ((millis() > TTasks + (kUpdFreq*60000)) || (millis() < TTasks)) { 
    TTasks = millis();
    checkConnection();
  }
}
sw3
Posts: 6
Joined: Wed Apr 19, 2017 8:09 am

I now changed the GPIOs in h801.h and compiled it with the VirtualBox-SDK.
I flashed the device:

boot_v1.2.bin -->0X00000
h801_user1.1024.new.2.bin -->0X01000

But it´s not showing an AP. I´m also wondering why the "boot_v1.2.bin" have just a size of 2kb?
I´ve download and tryed the supla sonoff_socket firmware and it show up an AP now.
Does anybody know the isue?
Post Reply

Return to “General discussion”