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

NodeMCU v3 and WS2801 #367

Open
ketoloco opened this issue Nov 7, 2022 · 10 comments
Open

NodeMCU v3 and WS2801 #367

ketoloco opened this issue Nov 7, 2022 · 10 comments

Comments

@ketoloco
Copy link

ketoloco commented Nov 7, 2022

Hi,
Thanks for this amazing project. I have it up and running via raspberry pi using WS2801 using the suggestions from #135 .

Now I am trying to an ESP (NodMCU v3) instead as controller and wonder if the file ws2812_controller.ino could be easily adapted to ws2801 as well? The examples from the NeopixelBus library were I think mainly using ws2801.

@joeybab3
Copy link
Collaborator

joeybab3 commented Nov 7, 2022

Yes definitely,
Makuna/NeoPixelBus#324 has some info on implementing it, seems like you just need to change the neopixelbus declaration and it will work.

@ketoloco
Copy link
Author

ketoloco commented Nov 8, 2022

Hi, @joeybab3 thanks that's very appreciated. I changed the declarations accordingly and was running to run the visualization.py spectrum effect. I see that the microphone is working but the LEDs are just all turned on. As Serial Output I got the following message:
Exception (28):
epc1=0x40201201 epc2=0x00000000 epc3=0x000000.......
Connected to HomeWifi
IP address: 192.16x.x.xx
FPS: 0
FPS: 0
FPS: 0

Should FPS actually return a value here. Could this be eventually the error source? It seems like the ESP is connected to my router though.

@joeybab3
Copy link
Collaborator

joeybab3 commented Nov 8, 2022

Yes FPS should return a value, are you sure you set up the IP in config.py as well?

@ketoloco
Copy link
Author

ketoloco commented Nov 8, 2022

Would the FPS return the same value as the Python visualization script? I am was using the IP that came with the script:

ws2812_controller.ino:
...
// Network information
// IP must match the IP in config.py in python folder
IPAddress ip(192, 168, 0, 150); //IP ESP
...
config.py:
...
if DEVICE == 'esp8266':
UDP_IP = '192.168.0.150'
"""IP address of the ESP8266. Must match IP in ws2812_controller.ino"""
...

@joeybab3
Copy link
Collaborator

joeybab3 commented Nov 8, 2022

You need to use the ip of the device... It's highly unlikely you have the same settings as Scott which are what the defaults are.

As for FPS it outputs the amount of received frames in the last second so if it isn't receiving frames then it will say 0

@ketoloco
Copy link
Author

ketoloco commented Nov 9, 2022

Thanks, that helped. Now I have the FPS in the Serial Monitor but WS2801 is turning on only first 11 led even though defined first 32 and the colours seem to be not correct and it's flickering . I tested the stripe with FastLED examples that have been working though.

@joeybab3
Copy link
Collaborator

joeybab3 commented Nov 9, 2022

You mind posting your code somewhere and I can review it to see if there's anything I notice that's wrong?

@ketoloco
Copy link
Author

ketoloco commented Nov 9, 2022

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <NeoPixelBus.h>

// Set to the number of LEDs in your LED strip
#define NUM_LEDS 32
// Maximum number of packets to hold in the buffer. Don't change this.
#define BUFFER_LEN 1024
// Toggles FPS output (1 = print FPS over serial, 0 = disable output)
#define PRINT_FPS 1

//NeoPixelBus settings
//const uint8_t DotDataPin = 3; // make sure to set this to the correct pin, ignored for Esp8266(set to 3 by default for DMA)
//const uint8_t DotClockPin = 2;

// Wifi and socket settings
const char* ssid = "xxx";
const char* password = "xxx";
unsigned int localPort = 7777;
char packetBuffer[BUFFER_LEN];

// LED strip
//NeoPixelBus<NeoRgbFeature, NeoWs2801Method> strip(NUM_LEDS, DotClockPin, DotDataPin);
NeoPixelBus<NeoRgbFeature, NeoWs2801SpiMethod> strip(NUM_LEDS);

WiFiUDP port;

// Network information
// IP must match the IP in config.py in python folder
IPAddress ip(192, xxx, x, xx);
// Set gateway to your router's gateway
IPAddress gateway(192, xxx, x, x);
IPAddress subnet(255, 255, 255, 0);

void setup() {
Serial.begin(115200);
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
Serial.println("");
// Connect to wifi and print the IP address over serial
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
port.begin(localPort);
strip.Begin();//Begin output
strip.Show();//Clear the strip for use
}

uint8_t N = 0;
#if PRINT_FPS
uint16_t fpsCounter = 0;
uint32_t secondTimer = 0;
#endif

void loop() {
// Read data over socket
int packetSize = port.parsePacket();
// If packets have been received, interpret the command
if (packetSize) {
int len = port.read(packetBuffer, BUFFER_LEN);
for(int i = 0; i < len; i+=4) {
packetBuffer[len] = 0;
N = packetBuffer[i];
RgbColor pixel((uint8_t)packetBuffer[i+1], (uint8_t)packetBuffer[i+2], (uint8_t)packetBuffer[i+3]);
strip.SetPixelColor(N, pixel);
}
strip.Show();
#if PRINT_FPS
fpsCounter++;
Serial.print("/");//Monitors connection(shows jumps/jitters in packets)
#endif
}
#if PRINT_FPS
if (millis() - secondTimer >= 1000U) {
secondTimer = millis();
Serial.printf("FPS: %d\n", fpsCounter);
fpsCounter = 0;
}
#endif
}

@ketoloco
Copy link
Author

ketoloco commented Nov 9, 2022

My feeling says it is related to the NeoPixelBus lib though. Using Raspberry
Pi was working perfectly well.

@joeybab3
Copy link
Collaborator

joeybab3 commented Nov 9, 2022

yeah not sure what the issue is here as I don't have one of those strips but if the led counts are the same in the py and in the sketch it should be lighting all of them. It's also possible you are using a strip which uses grb instead of RGB in which case your declaration would need to change

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

2 participants