Skip to content

Please Fix the ESP portion of this Lib . #45

Description

@9ghost9

I have added Change to the ISR ability and corrected what others have already suggested .

It is frustrating to purchase RobotDyn products only to have the firmware not function .

Here is the fixed Lib completed that will remove ESP flashing frustration and also enable reasonable AC LED control .

https://drive.google.com/file/d/13wZMFQneHm8znYDxutUyMGcZuyUESraV/view?usp=sharing

RBDmcuESP8266.cpp

line: 9 int rise_fall_change = true; // added change
line: 61 attachInterrupt(inPin, isr_ext,CHANGE); // set to CHANGE and works with incans or leds.

Note; From my testing and experience with the Robotdyn AC module , by adding a parallel load to Led fixtures the top end percentage is not clipped at 80% but works correctly through to 100%

Thank you

Here is code for a Web Server to test on your Esp + AC device

``#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <RBDdimmer.h>//
// Replace with your network credentials
const char* ssid = "hAPP dAYS"; //REPLACE_WITH_YOUR_SSID
const char* password = "WORDPASS"; //REPLACE_WITH_YOUR_PASSWORD

//const int output = 2;
#define outputPin D6 // Set to your Gpio liking
#define zerocross D1 // for boards with CHANGEBLE input pins

dimmerLamp dimmer(outputPin, zerocross); //initialase port for dimmer for ESP8266, ESP32, Arduino due boards

String sliderValue = "0";

const char* PARAM_INPUT = "value";

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

const char index_html[] PROGMEM = R"rawliteral(

<title>ESP Web Server</title> <style> html {font-family: Arial; display: inline-block; text-align: center;} h2 {font-size: 2.3rem;} p {font-size: 1.9rem;} body {max-width: 400px; margin:0px auto; padding-bottom: 25px;} .slider { -webkit-appearance: none; margin: 14px; width: 360px; height: 25px; background: #FFD65C; outline: none; -webkit-transition: .2s; transition: opacity .2s;} .slider::-webkit-slider-thumb {-webkit-appearance: none; appearance: none; width: 35px; height: 35px; background: #003249; cursor: pointer;} .slider::-moz-range-thumb { width: 35px; height: 35px; background: #003249; cursor: pointer; } </style>

ESP Web Server

%SLIDERVALUE%

<script> function updateSliderPWM(element) { var sliderValue = document.getElementById("pwmSlider").value; document.getElementById("textSliderValue").innerHTML = sliderValue; console.log(sliderValue); var xhr = new XMLHttpRequest(); xhr.open("GET", "/slider?value="+sliderValue, true); xhr.send(); } </script> )rawliteral";

// Replaces placeholder with button section in your web page
String processor(const String& var){
//Serial.println(var);
if (var == "SLIDERVALUE"){
return sliderValue;
}
return String();
}

void setup(){
// Serial port for debugging purposes
Serial.begin(115200);

//analogWrite(output, sliderValue.toInt());

// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)

// Print ESP Local IP Address
Serial.println(WiFi.localIP());

// Route for root / web page
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/html", index_html, processor);
});

// Send a GET request to <ESP_IP>/slider?value=
server.on("/slider", HTTP_GET, [] (AsyncWebServerRequest *request) {
String inputMessage;
// GET input1 value on <ESP_IP>/slider?value=
if (request->hasParam(PARAM_INPUT)) {
inputMessage = request->getParam(PARAM_INPUT)->value();
sliderValue = inputMessage;
//analogWrite(output, sliderValue.toInt());
dimmer.setPower(sliderValue.toInt()); // setPower(0-100%);

}
else {
  inputMessage = "No message sent";
}
Serial.println(inputMessage);
request->send(200, "text/plain", "OK");

});

// Start server
server.begin();
}

void loop() {

}``

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions