Hardware components | ||||||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
![]() |
| × | 3 | |||
| × | 1 | ||||
![]() |
| × | 1 | |||
| × | 1 | ||||
Software apps and online services | ||||||
![]() |
| |||||
| ||||||
Hand tools and fabrication machines | ||||||
![]() |
| |||||
![]() |
| |||||
![]() |
| |||||
Back View
Front View
So the way this works is that using data pulled from Opendata - U.S. Energy Information Administration (EIA), the speed of the turbines and the amount/color of the lights in the background will change according to the hourly generated amount of Megawatt hours (Megawatts generated each hour) from wind turbines from MISO (Midcontinent Independent Service Operator)
// 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();
}














Comments