Whether you’re planning out your day or just running out for a quick errand, one of the most important things to consider is the weather. With a Particle Proton and electron, you can have a system that displays the current weather on an LED ring. The idea being that you can easily assess the weather at a glance.
The project began with creating the circuits necessary for each for a DHT22 humidity sensor and for the Adafruit NeoPixel Ring. After completing the circuits, the next issue to tackle was the code. For this project to work there needed to be a way for the Particle Photon to pull data from a website such as Weather Underground. Local measurements would also be collected by the DHT22 sensor and be relayed by the Particle Electron. Both readings can be seen recorded in the below Thing Speak charts.
Once the information was compiled, the code arranged for it to be displayed on the NeoPixel Ring. For this code to work, every weather condition available was included. The weather readings also included wind speeds. Using The Beaufort Scale, the wind speeds were able to translated into more intuitive ranges and displayed to the NeoPixel ring as well.
The outcome of this project is a system that will allow you at a glance, to accurately assess the weather outside. By simply looking at the ring you will be able to gauge the overall weather for your area and for your immediate surroundings. The temperature will be displayed by the color of the variation from blue (colder temps) to red (warmer temps). The wind speed will be shown by the speed of the of the rotation around the ring.
VideoStep 1A large part of this project was being able to handle the large amount of possible data that Weather Underground could provide us in their API. Particularly the huge list of possible weather conditions (about 120 possible returns) I approached this by first organizing all the possible conditions into a 2D array where each sub array associated with a more simplified type of weather. (Rain, Clear, Snow, Clouds, Bad Stuff, and unknown):
String conditions[x][y]={
{"RAIN","Light Drizzle","Drizzle","Heavy Drizzle","Light Rain","Rain","Heavy Rain","Light Mist","Mist","Heavy Mist","Light Rain Showers","Rain Showers","Heavy Rain Showers","Light Thunderstorm","Thunderstorm","Heavy Thunderstorm","Light Thunderstorms and Rain","Thunderstorms and Rain","Heavy Thunderstorms and Rain","Light Rain Mist","Rain Mist","Heavy Rain Mist","Light Freezing Drizzle","Freezing Drizzle","Heavy Freezing Drizzle","Light Freezing Rain","Freezing Rain","Heavy Freezing Rain","Squalls","Light Spray","Spray","Heavy Spray"},
{"CLEAR","Clear","Partly Cloudy","Scattered Clouds","Shallow Fog","Patches of Fog"},
{"SNOW","Light Snow","Snow","Heavy Snow","Light Snow Grains","Snow Grains","Heavy Snow Grains","Light Ice Crystals","Ice Crystals","Heavy Ice Crystals","Light Ice Pellets","Ice Pellets","Heavy Ice Pellets","Light Hail","Hail","Heavy Hail","Light Low Drifting Snow","Low Drifting Snow","Heavy Low Drifting Snow","Light Blowing Snow","Blowing Snow","Heavy Blowing Snow","Light Snow Showers","Snow Showers","Heavy Snow Showers","Light Snow Blowing Snow Mist","Snow Blowing Snow Mist","Heavy Snow Blowing Snow Mist","Light Ice Pellet Showers","Ice Pellet Showers","Heavy Ice Pellet Showers","Light Hail Showers","Hail Showers","Heavy Hail Showers","Light Small Hail Showers","Small Hail Showers","Heavy Small Hail Showers","Light Thunderstorms and Snow","Thunderstorms and Snow","Heavy Thunderstorms and Snow","Light Thunderstorms and Ice Pellets","Thunderstorms and Ice Pellets","Heavy Thunderstorms and Ice Pellets","Light Thunderstorms with Hail","Thunderstorms with Hail","Heavy Thunderstorms with Hail","Light Thunderstorms with Small Hail","Thunderstorms with Small Hail","Heavy Thunderstorms with Small Hail","Small Hail"},
{"CLOUDY","Light Fog","Fog","Heavy Fog","Light Fog Patches","Fog Patches","Heavy Fog Patches","Light Freezing Fog","Freezing Fog","Heavy Freezing Fog","Partial Fog","Overcast","Mostly Cloudy"},
{"BAD","Light Smoke","Smoke","Heavy Smoke","Funnel Cloud","Light Volcanic Ash","Volcanic Ash","Heavy Volcanic Ash","Light Widespread Dust","Widespread Dust","Heavy Widespread Dust","Light Sand","Sand","Heavy Sand","Light Dust Whirls","Dust Whirls","Heavy Dust Whirls"},
{"??","Unknown","Unknown Precipitation"}
};
I then ran through the array in two loops and determend the color of the traveling LED by the category of weather our current condition was.
for(int i=0;i<x&& !done;i++){
for(int j=0;j<y&&conditions[i][j]!="";j++){
if(current==conditions[i][j]){
done=true;
if(conditions[i][0]=="RAIN"){
return CYAN;
}else if(conditions[i][0]=="CLEAR"){
return YELLOW;
}else if(conditions[i][0]=="SNOW"){
return WHITE;
}else if(conditions[i][0]=="CLOUDY"){
return BLACK;
}else if(conditions[i][0]=="BAD"){
return PEACH;
}else if(conditions[i][0]=="??"){
return PEACH;
}else{
return RED;
}
}
}
}
Step 2The next big part of the ring was to come up with a schema for color to temperature. I initially thought of just doing blue for cold weather green for comfortable weather and a orange for hot weather but decided it would look nicer and be a but more useful if I had a full gradient, so I went about figuring out how to do that.
Ultimately I ended up fitting a gradient (blue to green to red) into an array of colors and then using the temperature to determine where to display the color (currently it can only distinguish temperatures from 0-100 I do intend to change that but here in Charlotte I shouldn't have to worry about it for a while. )
Step 3Then for the display I wrote this simple animation function:
void Cycle(uint32_t conditionTemp, uint32_t colorTemp,int wSpeed){
for(int i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, conditionTemp);
strip.show();
delay(wSpeed);
strip.setPixelColor(i, colorTemp);
strip.show();
}
}
Which goes around the ring first displaying the condition color then displaying the temperature color it then leaves the temperature color in place and moves on the next LED in the ring creating the effect of a single off colored LED traveling around the ring.
Comments