Lights
ESPixelStick
xLights
Select the menu:
Arduino ->
Preferences ->
Additional Boards Manager URLs:
Insert:
http://arduino.esp8266.com/stable class='acmetable'/package_esp8266com_index.json
Select the menu:
Tools -->
Boards -->
Boards Manager
and install esp8266 by ESP8266 Community board
#include <Adafruit_NeoPixel.h>
#define PIN 4 // D2
#define NUMPIXELS 16
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ400);
#define DELAYVAL 500
void setup() {
pixels.begin();
}
void loop() {
int i;
pixels.clear();
for (i=0;i<16;i+=4) {
pixels.setPixelColor(i+0, pixels.Color(127, 0, 0));
pixels.setPixelColor(i+1, pixels.Color( 0, 127, 0));
pixels.setPixelColor(i+2, pixels.Color( 0, 0, 127));
pixels.setPixelColor(i+3, pixels.Color(127, 0, 127));
}
pixels.show();
}
#include <Adafruit_NeoPixel.h>
#include <ESP8266WiFi.h>
#include <espnow.h>
// ESP8266 Board MAC Address: C8:2B:96:2C:99:59
// ESP8266 Board MAC Address: 5C:CF:7F:AC:C7:3F
// ESP8266 Board MAC Address: 48:3F:DA:6E:13:16
uint8_t broadcastAddress[] = {0x5C, 0xCF, 0x7F, 0xAC, 0xC7, 0x3F};
// Structure example to send data
// Must match the receiver structure
typedef struct struct_message {
char a[32];
int b;
float c;
String d;
bool e;
} struct_message;
// Create a struct_message called myData
struct_message myData;
unsigned long lastTime = 0;
unsigned long timerDelay = 2000; // send readings timer
// Callback when data is sent
void OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) {
Serial.print("Last Packet Send Status: ");
if (sendStatus == 0){
Serial.println("Delivery success");
}
else{
Serial.println("Delivery fail");
}
}
#define PIN 4
#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 500
void setup() {
pixels.begin();
Serial.begin(115200);
//Serial.println();
//Serial.print("ESP8266 Board MAC Address: ");
//Serial.println(WiFi.macAddress());
// Set device as a Wi-Fi Station
WiFi.mode(WIFI_STA);
// Init ESP-NOW
if (esp_now_init() != 0) {
Serial.println("Error initializing ESP-NOW");
return;
// Once ESPNow is successfully Init, we will register for Send CB to
// get the status of Trasnmitted packet
esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
esp_now_register_send_cb(OnDataSent);
// Register peer
esp_now_add_peer(broadcastAddress, ESP_NOW_ROLE_SLAVE, 1, NULL, 0);
}
}
void loop() {
int i;
pixels.clear();
pixels.setPixelColor(0, pixels.Color(0, 63, 0));
pixels.show();
if ((millis() - lastTime) > timerDelay) {
// Set values to send
strcpy(myData.a, "THIS IS A CHAR");
myData.b = random(1,20);
myData.c = 1.2;
myData.d = "Hello";
myData.e = false;
// Send message via ESP-NOW
esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));
lastTime = millis();
}
}