Please find the working code and the connections.
hardware connection:
Nodemcu ESP12 - RS485 adapter
3.3 V DE
earth RE
TX(D4) DI
sketch (maybe it can be optimized) :
/**************************************************************************
Souliss - RGB LED Strips
Control RGB LED Strips using DMX- controller
Run this code on one of the following boards:
- ESP8266 + DMX-drivers
***************************************************************************/
// Let the IDE point to the Souliss framework
#include "SoulissFramework.h"
// Configure the framework
#include "bconf/MCU_ESP8266.h" // Load the code directly on the ESP8266
#include "conf/Gateway.h" // The main node is the Gateway, we have just one node
//#include "conf/Gateway_wPersistence.h"
#include "conf/IPBroadcast.h"
#include <ESP8266WiFi.h>
// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID "xxxxxx"
#define WiFi_Password "yyyyyy"
// Include framework code and libraries
//#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include "Souliss.h"
// dmx LIBRARY
#include <ESPDMX.h>
DMXESPSerial dmx;
uint8_t ip_address[4] = {192, 168, 0,178};
uint8_t subnet_mask[4] = {255, 255, 255, 0};
uint8_t ip_gateway[4] = {192, 168,0,1};
#define Gateway_address 178
#define myvNet_address ip_address[3]
#define myvNet_subnet 0xFF00
#define myvNet_supern Gateway_address
#define LEDCONTROL_A1 0
#define LEDRED_A1 1
#define LEDGREEN_A1 2
#define LEDBLUE_A1 3
#define LEDCONTROL_A2 5
#define LEDRED_A2 6
#define LEDGREEN_A2 7
#define LEDBLUE_A2 8
#define LEDCONTROL_A5 10
#define LEDRED_A5 11
#define LEDGREEN_A5 12
#define LEDBLUE_A5 13
void setup()
{
Initialize();
Serial.begin(9600); // enkel voor testen programma
//DMXSerial.init(DMXController);
dmx.init(100);
// Get the IP address from DHCP
// GetIPAddress();
Souliss_SetIPAddress(ip_address, subnet_mask, ip_gateway);
SetAsGateway(myvNet_address);
Set_LED_Strip(LEDCONTROL_A1); // Set a logic to control a LED strip
Set_LED_Strip(LEDCONTROL_A2); // Set a logic to control a LED strip
Set_LED_Strip(LEDCONTROL_A5); // Set a logic to control a LED strip
}/**************************************************************************
Souliss - RGB LED Strips
Control RGB LED Strips using DMX- controller
Run this code on one of the following boards:
- ESP8266 + DMX-drivers
***************************************************************************/
// Let the IDE point to the Souliss framework
#include "SoulissFramework.h"
// Configure the framework
#include "bconf/MCU_ESP8266.h" // Load the code directly on the ESP8266
#include "conf/Gateway.h" // The main node is the Gateway, we have just one node
//#include "conf/Gateway_wPersistence.h"
#include "conf/IPBroadcast.h"
#include <ESP8266WiFi.h>
// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID "xxxxxx"
#define WiFi_Password "yyyyyy"
// Include framework code and libraries
//#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include "Souliss.h"
// dmx LIBRARY
#include <ESPDMX.h>
DMXESPSerial dmx;
uint8_t ip_address[4] = {192, 168, 0,178};
uint8_t subnet_mask[4] = {255, 255, 255, 0};
uint8_t ip_gateway[4] = {192, 168,0,1};
#define Gateway_address 178
#define myvNet_address ip_address[3]
#define myvNet_subnet 0xFF00
#define myvNet_supern Gateway_address
#define LEDCONTROL_A1 0
#define LEDRED_A1 1
#define LEDGREEN_A1 2
#define LEDBLUE_A1 3
#define LEDCONTROL_A2 5
#define LEDRED_A2 6
#define LEDGREEN_A2 7
#define LEDBLUE_A2 8
#define LEDCONTROL_A5 10
#define LEDRED_A5 11
#define LEDGREEN_A5 12
#define LEDBLUE_A5 13
void setup()
{
Initialize();
Serial.begin(9600); // enkel voor testen programma
//DMXSerial.init(DMXController);
dmx.init(100);
// Get the IP address from DHCP
// GetIPAddress();
Souliss_SetIPAddress(ip_address, subnet_mask, ip_gateway);
SetAsGateway(myvNet_address);
Set_LED_Strip(LEDCONTROL_A1); // Set a logic to control a LED strip
Set_LED_Strip(LEDCONTROL_A2); // Set a logic to control a LED strip
Set_LED_Strip(LEDCONTROL_A5); // Set a logic to control a LED strip
}
void loop()
{
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
// Execute the code every 1 time_base_fast
FAST_10ms() {
// Execute the logic that handle the LED
Logic_LED_Strip(LEDCONTROL_A1);
Logic_LED_Strip(LEDCONTROL_A2);
Logic_LED_Strip(LEDCONTROL_A5);
//
dmx.write(1, mOutput(LEDRED_A1+1));
dmx.write(2, mOutput(LEDGREEN_A1+2));
dmx.write(3, mOutput(LEDBLUE_A1+3));
dmx.write(4, mOutput(LEDRED_A2+1));
dmx.write(5, mOutput(LEDGREEN_A2+2));
dmx.write(6, mOutput(LEDBLUE_A2+3));
dmx.write(7, mOutput(LEDRED_A5+1));
dmx.write(8, mOutput(LEDGREEN_A5+2));
dmx.write(9, mOutput(LEDBLUE_A5+3));
dmx.update();
// Just process communication as fast as the logics
ProcessCommunication();
}
// Process the other Gateway stuffs
FAST_GatewayComms();
}
EXECUTESLOW()
{
UPDATESLOW();
SLOW_10s() {
// The timer handle timed-on states
Timer_LED_Strip(LEDCONTROL_A1);
Timer_LED_Strip(LEDCONTROL_A2);
Timer_LED_Strip(LEDCONTROL_A5);
}
}
}
void loop()
{
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
// Execute the code every 1 time_base_fast
FAST_10ms() {
// Execute the logic that handle the LED
Logic_LED_Strip(LEDCONTROL_A1);
Logic_LED_Strip(LEDCONTROL_A2);
Logic_LED_Strip(LEDCONTROL_A5);
//
dmx.write(1, mOutput(LEDRED_A1+1));
dmx.write(2, mOutput(LEDGREEN_A1+2));
dmx.write(3, mOutput(LEDBLUE_A1+3));
dmx.write(4, mOutput(LEDRED_A2+1));
dmx.write(5, mOutput(LEDGREEN_A2+2));
dmx.write(6, mOutput(LEDBLUE_A2+3));
dmx.write(7, mOutput(LEDRED_A5+1));
dmx.write(8, mOutput(LEDGREEN_A5+2));
dmx.write(9, mOutput(LEDBLUE_A5+3));
dmx.update();
// Just process communication as fast as the logics
ProcessCommunication();
}
// Process the other Gateway stuffs
FAST_GatewayComms();
}
EXECUTESLOW()
{
UPDATESLOW();
SLOW_10s() {
// The timer handle timed-on states
Timer_LED_Strip(LEDCONTROL_A1);
Timer_LED_Strip(LEDCONTROL_A2);
Timer_LED_Strip(LEDCONTROL_A5);
}
}
}