-->
Page 1 of 1

ESP12F with ws2812 (neopixels)

PostPosted: Mon Jun 12, 2017 1:17 am
by lasse.h.knudsen
Greetings,
I have run into a problem when combining the neopixel library and BasicHttpClient, But when i combine them i cant get the neopixels to work. The the http client works as expected, and the neopixels work when not combined with the BasicHttpClient

The only thing i need to have done is the color of the neopixels set based on the parsing of a webpage.

I have no real idea what is going on :)

I use an 74HCT08 and gate for level translation.

-lasse

ESP8266 boards 2.2.0
Arduino IDE 1.8.2
Adafruit Neopixel version 1.1.1

Code: Select all#include <Adafruit_NeoPixel.h>

/**
 * BasicHTTPClient.ino
 *
 *  Created on: 24.05.2015
 *
 */

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#include <ESP8266HTTPClient.h>

#define USE_SERIAL Serial

ESP8266WiFiMulti WiFiMulti;
#define PIN            5

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      16

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 500; // delay for half a second


void updatepixels() {
  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(150,0,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).

  }
 
}



void setup() {

    USE_SERIAL.begin(115200);
   // USE_SERIAL.setDebugOutput(true);

    USE_SERIAL.println();
    USE_SERIAL.println();
    USE_SERIAL.println();

    for(uint8_t t = 4; t > 0; t--) {
        USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
        USE_SERIAL.flush();
        delay(1000);
    }

    WiFiMulti.addAP("Neopixel", "ESP12f");
 
   


updatepixels();


}

void loop() {
    // wait for WiFi connection
    if((WiFiMulti.run() == WL_CONNECTED)) {

  USE_SERIAL.println("");
  USE_SERIAL.print("MAC: ");
  USE_SERIAL.println(WiFi.macAddress());
  USE_SERIAL.print("SSID");
  USE_SERIAL.println(WiFi.SSID());

 
  USE_SERIAL.print("IP address: ");
  USE_SERIAL.println(WiFi.localIP());
 
        HTTPClient http;

        USE_SERIAL.print("[HTTP] begin...\n");
        // configure traged server and url
        //http.begin("https://192.168.1.12/test.html", "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS
        http.begin("http://www.ajax.esy.es/"); //HTTP

        USE_SERIAL.print("[HTTP] GET...\n");
        // start connection and send HTTP header
        int httpCode = http.GET();

        // httpCode will be negative on error
        if(httpCode > 0) {
            // HTTP header has been send and Server response header has been handled
            USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);

            // file found at server
            if(httpCode == HTTP_CODE_OK) {
                String payload = http.getString();
                USE_SERIAL.println(payload);
            }
        } else {
            USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }

        http.end();
    }

    delay(10000);
}