I recently bought this development board http://www.aliexpress.com/snapshot/6714 ... 1083055430 I wrote the code to control the WS2812 pixels through ArtNet protocol but I have a problem code is often suddenly resets know anyone tell me where the problem may be there is a report of a reset and code.
ets Jan 8 2013,rst cause:4, boot mode:(3,7)
wdt reset
load 0x40100000, len 28916, room 16
tail 4
chksum 0xe6
load 0x3ffe8000, len 1580, room 4
tail 8
chksum 0x68
load 0x3ffe8630, len 2980, room 0
tail 4
chksum 0xb9
csum 0xb9
code:
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include "WiFiUdp.h"
#include "Artnet.h"
#include <SPI.h>
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <OLED_SSD1306.h>
#define OLED_ADDRESS 0x78 //OLED I2C bus address
// Neopixel settings
const int numLeds1 = 170;
const int numLeds2 = 170;
const int numLeds3 = 170;
const int numLeds4 = 170;
//GPIO Out settings
const byte dataPin1 = 14;
const byte dataPin2 = 12;
const byte dataPin3 = 13;
const byte dataPin4 = 15;
#define OLED_SDA 3
#define OLED_SCL 1
OLED_SSD1306 oled;
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(numLeds1, dataPin1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(numLeds2, dataPin2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip3 = Adafruit_NeoPixel(numLeds3, dataPin3, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip4 = Adafruit_NeoPixel(numLeds4, dataPin4, NEO_GRB + NEO_KHZ800);
// Artnet settings
Artnet artnet;
//STA DHCP - ON/OFF
boolean useDHCP = true;
uint8_t ip[] = {192, 168, 2, 100};
uint8_t gw[] = {192, 168, 2, 2};
uint8_t mask[] = {255, 255, 255, 0};
uint8_t mac[] = {0x04, 0xE9, 0xE5, 0x00, 0x69, 0xEC};
const char* ssid = "STASSID";
const char* password = "STAPASSWORD";
const char* APssid = "AP Mode";
const char* APpassword = "";
void setup()
{
WiFi.begin(ssid, password);
if (!useDHCP) {
WiFi.config(ip, gw, mask);
}
WiFi.mode(WIFI_AP_STA);
WiFi.softAP(APssid, APpassword);
Serial.begin(115200);
pinMode(16, OUTPUT);
digitalWrite(16, LOW);
strip1.begin();
strip2.begin();
strip3.begin();
strip4.begin();
Wire.begin( OLED_SDA, OLED_SCL );
oled.Init();
oled.ClearDisplay();
oled.SendStrXY( "ArtNet - PIX", 0, 2 );
oled.SendStrXY( "Pixel Test", 5, 3 );
oled.SendStrXY( "FW v1.0.0.", 2, 3 );
initTest();
oled.SendStrXY( "AP Mode Running", 7, 0 );
while (WiFi.status() != WL_CONNECTED) {
oled.SendStrXY( "Connecting ", 5, 1 );
delay(500);
oled.SendStrXY( "Connecting.", 5, 1 );
delay(500);
oled.SendStrXY( "Connecting..", 5, 1 );
delay(500);
oled.SendStrXY( "Connecting...", 5, 1 );
delay(500);
}
WiFi.mode(WIFI_STA);
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
digitalWrite(16, HIGH);
oled.SendStrXY( "WiFi Connected", 5, 1 );
oled.SendStrXY( "AP Mode Disable", 7, 0 );
delay(4000);
char result[16];
sprintf(result, "IP:%d.%d.%d.%d", WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], WiFi.localIP()[3]);
oled.SendStrXY("IP: ", 7, 0);
oled.SendStrXY(result, 7, 0);
delay(1000);
artnet.begin(mac, ip);
artnet.setArtDmxCallback(onDmxFrame1);
}
void loop()
{
if (WiFi.status() != WL_CONNECTED) {
oled.ClearDisplay();
oled.SendStrXY( "ArtNet - PIX", 0, 2 );
oled.SendStrXY( "FW v1.0.0.", 2, 3 );
oled.SendStrXY( "Connecting Error", 5, 0 );
oled.SendStrXY( "Rebooting...", 7, 2 );
digitalWrite(16, LOW);
ESP.restart();
while(true);
}else{
artnet.read();
}
}
void onDmxFrame1(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
if (universe == 0) {
// read universe and put into the right part of the display buffer
for (int i = 0; i < numLeds1; i++)
{
strip1.setPixelColor(i, data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
}
strip1.show();
}
if (universe == 1) {
for (int i = 0; i < numLeds2; i++)
{
strip2.setPixelColor(i, data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
}
strip2.show();
}
if (universe == 2) {
for (int i = 0; i < numLeds3; i++)
{
strip3.setPixelColor(i, data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
}
strip3.show();
}
if (universe == 3) {
for (int i = 0; i < numLeds4; i++)
{
strip4.setPixelColor(i, data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
}
strip4.show();
}
}
void initTest()
{
for (int i = 0 ; i < numLeds1 ; i++)
strip1.setPixelColor(i, 255, 0, 0);
for (int i = 0 ; i < numLeds2 ; i++)
strip2.setPixelColor(i, 255, 0, 0);
for (int i = 0 ; i < numLeds3 ; i++)
strip3.setPixelColor(i, 255, 0, 0);
for (int i = 0 ; i < numLeds4 ; i++)
strip4.setPixelColor(i, 255, 0, 0);
strip1.show();
strip2.show();
strip3.show();
strip4.show();
delay(1000);
for (int i = 0 ; i < numLeds1 ; i++)
strip1.setPixelColor(i, 0, 255, 0);
for (int i = 0 ; i < numLeds2 ; i++)
strip2.setPixelColor(i, 0, 255, 0);
for (int i = 0 ; i < numLeds3 ; i++)
strip3.setPixelColor(i, 0, 255, 0);
for (int i = 0 ; i < numLeds4 ; i++)
strip4.setPixelColor(i, 0, 255, 0);
strip1.show();
strip2.show();
strip3.show();
strip4.show();
delay(1000);
for (int i = 0 ; i < numLeds1 ; i++)
strip1.setPixelColor(i, 0, 0, 255);
for (int i = 0 ; i < numLeds2 ; i++)
strip2.setPixelColor(i, 0, 0, 255);
for (int i = 0 ; i < numLeds3 ; i++)
strip3.setPixelColor(i, 0, 0, 255);
for (int i = 0 ; i < numLeds4 ; i++)
strip4.setPixelColor(i, 0, 0, 255);
strip1.show();
strip2.show();
strip3.show();
strip4.show();
delay(1000);
for (int i = 0 ; i < numLeds1 ; i++)
strip1.setPixelColor(i, 0, 0, 0);
for (int i = 0 ; i < numLeds2 ; i++)
strip2.setPixelColor(i, 0, 0, 0);
for (int i = 0 ; i < numLeds3 ; i++)
strip3.setPixelColor(i, 0, 0, 0);
for (int i = 0 ; i < numLeds4 ; i++)
strip4.setPixelColor(i, 0, 0, 0);
strip1.show();
strip2.show();
strip3.show();
strip4.show();
}