Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some error #1

Open
Serg-Pogrebnyak opened this issue Dec 27, 2020 · 0 comments
Open

Some error #1

Serg-Pogrebnyak opened this issue Dec 27, 2020 · 0 comments

Comments

@Serg-Pogrebnyak
Copy link

Hi, I added your home bridge plugin on my raspberry pi, and I have some trouble with dimmer,
first - in console I get next error:
[sconce] undefined
[sconce] { Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:171:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
second problem it's when I turn off my dimmer, and wan't turn on - as I understand home kit make a call in my esp - get brightness - esp return 0 (because it turn off) and next call it's turn off, so why it's going? what I should change for normal working?

#include <WiFi.h>
#include <ESP32WebServer.h>
#include <RBDdimmer.h>

const char* ssid = "";
const char
password = "
*";

ESP32WebServer server(80);
#define outPin 32 // pin for dimming
#define ZCPin 4 // Zero-Cross
dimmerLamp dimmer(outPin, ZCPin); //initialase port for dimmer

void setup(void)
{
Serial.begin(115200); // Serial connection from ESP-01 via 3.3v console cable

// Connect to WiFi network
WiFi.begin(ssid, password);
IPAddress ip(192, 168, 1, 199);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
WiFi.config(ip, gateway, subnet);
Serial.print("\n\r \n\rWorking to connect");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("DHT data Reading Server");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

server.on("/dimmerOn", {
Serial.println("anybody come to /dimmerOn!");
dimmer.setState(ON);
server.send(200, "text/plain", "1");
});

server.on("/dimmerOff", {
Serial.println("anybody come to /dimmerOff!");
dimmer.setState(OFF);
server.send(200, "text/plain", "1");
});

server.on("/getDimmerState", {
Serial.println("anybody come to /getDimmerState!");
Serial.println(String(dimmer.getState()));
server.send(200, "text/plain", String(dimmer.getState()));
});

server.on("/getBrightness", {
Serial.println("anybody come to /getBrightness!");
Serial.println(String(dimmer.getPower()));
server.send(200, "text/plain", String(dimmer.getPower()));
});

server.on("/setBrightness", handleSetBrightness);

server.begin();
Serial.println("HTTP server started");
dimmer.begin(NORMAL_MODE, OFF); //dimmer initialisation: name.begin(MODE, STATE)
}

void handleSetBrightness() { //Handler
Serial.println(server.arg(0));
int brightness = server.arg(0).toInt();
dimmer.setPower(brightness);
dimmer.setState(ON);
server.send(200, "text/plain", "1"); //Response to the HTTP request
}

void loop(void)
{
server.handleClient();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant