Nathan Charpentier
Published © GPL3+

PCL-CompSculpt Project- Wind Turbine Display

Pulls data on wind power generated from the EIA API and displays it physically.

AdvancedShowcase (no instructions)5
PCL-CompSculpt Project- Wind Turbine Display

Things used in this project

Hardware components

Photon 2
Particle Photon 2
×1
Breadboard (generic)
Breadboard (generic)
Any generic breadboard/Proto board should work. I used 1 of each cause that's what I had, but depending on your wiring you could probably get away with 1.
×1
LED Strip, NeoPixel Digital RGB
LED Strip, NeoPixel Digital RGB
Only need a strip of 8 LEDs total
×1
DC Motor, 12 V
DC Motor, 12 V
×3
L298N DC Motor Driver
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Cardboard
Both the box and the turbine stands are made from carboard
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
EIA.gov API

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Soldering iron (generic)
Soldering iron (generic)
Tape, Electrical
Tape, Electrical

Story

Read more

Code

Real Code

C/C++
This the final code including the actual data pulled from the API.
// This #include #include "Particle.h"
#include <neopixel.h>
SYSTEM_MODE(AUTOMATIC);
SerialLogHandler logHandler(LOG_LEVEL_INFO);
String strJSON = "";
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#if (PLATFORM_ID == 32)
// MOSI pin MO
#define PIXEL_PIN SPI1
// MOSI pin D2
// #define PIXEL_PIN SPI1
#else // #if (PLATFORM_ID == 32)
#define PIXEL_PIN D2
#endif
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812B

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int enA = A2; // PWM Pin
int in1 = D3;
int in2 = D4;

void setup() {
    pinMode(enA, OUTPUT);
    pinMode(in1, OUTPUT);
    pinMode(in2, OUTPUT);
    strip.begin();
strip.show();
int p=0;
    Particle.subscribe("hook-response/get_midwest_wind", lightHandler,   MY_DEVICES);
    Particle.subscribe("hook-response/get_midwest_wind", turbineHandler, MY_DEVICES);
}

void loop() {
    delay(15000);
    Particle.publish("get_midwest_wind");
    delay(60000);
}
void turbineHandler(const char *event, const char *data)
{
    String info = data;
    int mwh=info.toInt();
    Serial.println(mwh);
    int pwn= map(mwh,6000,25000,120,255);
    Serial.println(pwn);
    digitalWrite(in1, HIGH);
    digitalWrite(in2, LOW);
    analogWrite(enA, pwn); 
    delay(2000);
}

void lightHandler(const char *event, const char *data)
{
    String info = data;
    int mwh=info.toInt();
    Serial.println(mwh);
    if(mwh>22875){
        uint32_t h = strip.Color(0, 255, 0);
        for(int i=0; i<=7;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>20750){
        uint32_t h = strip.Color(0, 255, 0);
        for(int i=0; i<=6;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>18625){
        uint32_t h = strip.Color(0, 255, 0);
        for(int i=0; i<=5;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>16500){
        uint32_t h = strip.Color(255, 255, 0);
        for(int i=0; i<=4;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>14375){
        uint32_t h = strip.Color(255, 255, 0);
        for(int i=0; i<=3;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>12250){
        uint32_t h = strip.Color(255, 255, 0);
        for(int i=0; i<=2;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>10125){
        uint32_t h = strip.Color(255, 0, 0);
        for(int i=0; i<=1;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>6000){
        uint32_t h = strip.Color(255, 0, 0);
        for(int i=0; i<=0;i++){
            strip.setPixelColor(i,h);
        }
    }
    strip.show();
}

Test Code

C/C++
This is simply test code that you can use to test the physical aspects of the project without having to pull data from the API. Just change the "mwh" variable on a range of 6000-25000 to change the physical output from the hardware
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
SYSTEM_MODE(AUTOMATIC);
SerialLogHandler logHandler(LOG_LEVEL_INFO);
String strJSON = "";
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#if (PLATFORM_ID == 32)
// MOSI pin MO
#define PIXEL_PIN SPI1
// MOSI pin D2
// #define PIXEL_PIN SPI1
#else // #if (PLATFORM_ID == 32)
#define PIXEL_PIN D2
#endif
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812B

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int enA = A2; // PWM Pin
int in1 = D3;
int in2 = D4;

void setup() {
    pinMode(enA, OUTPUT);
    pinMode(in1, OUTPUT);
    pinMode(in2, OUTPUT);
    strip.begin();
strip.show();
int p=0;
    
}

void loop() {
    int mwh=25000;
    Serial.println(mwh);
    int pwn= map(mwh,6000,25000,120,255);
    Serial.println(pwn);
    digitalWrite(in1, HIGH);
    digitalWrite(in2, LOW);
    analogWrite(enA, pwn); 
    delay(2000);
    Serial.println(mwh);
    if(mwh>22875){
        uint32_t h = strip.Color(0, 255, 0);
        for(int i=0; i<=7;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>20750){
        uint32_t h = strip.Color(0, 255, 0);
        for(int i=0; i<=6;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>18625){
        uint32_t h = strip.Color(0, 255, 0);
        for(int i=0; i<=5;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>16500){
        uint32_t h = strip.Color(255, 255, 0);
        for(int i=0; i<=4;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>14375){
        uint32_t h = strip.Color(255, 255, 0);
        for(int i=0; i<=3;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>12250){
        uint32_t h = strip.Color(255, 255, 0);
        for(int i=0; i<=2;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>10125){
        uint32_t h = strip.Color(255, 0, 0);
        for(int i=0; i<=1;i++){
            strip.setPixelColor(i,h);
        }
    }
    if(mwh>6000){
        uint32_t h = strip.Color(255, 0, 0);
        for(int i=0; i<=0;i++){
            strip.setPixelColor(i,h);
        }
    }
    strip.show();
}

Credits

Nathan Charpentier
2 projects • 0 followers

Comments