Skip to content

help with mqtt dmx dimmer sketch #4

@Giaitzoglou

Description

@Giaitzoglou

Jan 05, 2019, 01:56 am
hi so i use an esp 8266 to control the dmx dimmer of some lights via mqtt and nodered
The only problem i come across after a few minutes of use it resets at the begining mayebe 30' nad after every 10 or more minutes and send these errors :
`/*

*/
#include <espDMX.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.

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

WiFiClient espClient;
PubSubClient client(espClient);
uint32_t lastMsg = 0;
char msg[50];
uint8_t dmxPayload[2];
uint16_t value = 0;

void setup_wifi() {

delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}

randomSeed(micros());

Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
//Serial.println(length);
// Serial.print("Message arrived [");
// Serial.print(topic);
// Serial.print("] ");
// for (int i = 0; i < length; i++) {
// Serial.print((char)payload);
// }
// Serial.println();

// Should really check the topic matches the exact one your subscribed to before using value
for (int i = 0; i < length; i++) {
msg = (char)payload;
}
msg[length] = 0;

int x = atoi(msg);
Serial.println(x);
dmxPayload[0] = (byte)x;
dmxB.setChans(dmxPayload, 1);
}

void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("group1","user","password")) {
Serial.println("connected");
// Once connected, publish an announcement...
client.publish("outlight/dmx1/", "On Dmx Esp");
// ... and resubscribe
client.subscribe("inlight/dmx1/");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(5000);
}
}
}

void setup() {
// Start dmxA, status LED on pin 12 with full intensity
Serial.begin(115200);
dmxB.begin();
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
delay(2000);
}

void loop() {

if (!client.connected()) {
reconnect();
}
client.loop();

if (millis() - lastMsg > 60000) {
lastMsg = millis();
snprintf (msg, 49, "On Dmx Esp");
//snprintf (msg, 49, "On Dmx Esp #%ld", value++);
//Send free memory ram
// uint32_t free = ESP.getFreeHeap();
// itoa(free, msg, 10);

//  Serial.print("Publish message: ");
//  Serial.println(msg);
client.publish("outlight/dmx1/", msg);

}

delay(10);
}`

`ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld

Connecting to hkhkhkhk
.......
WiFi connected
IP address:
192.168.0.110
Attempting MQTT connection...connected

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld

Connecting to hkhkhkhk
...
WiFi connected
IP address:
192.168.0.110`

any help will be really appreciated
thanks
chris

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions