iWeather
Smart Weather MBED Application
Our project comprised of processing and analyzing the current weather conditions and informing the user via audio. We used OpenWeatherMap api to pull the current weather data of Atlanta, GA (current location) by using ethernet and the HTTPClient library. We also collected the indoor temperature data and compared it to the outdoor weather data, which will help interpret the data and tailor it to the user (how to dress for the weather). An RGB led will light up indicating if it is raining outside.
Setting up the Hardware
List of hardware needed:
- mbed
- RJ45 Ethernet MagJack
- speaker
- 4DGL-uLCD
- EMIC 2 Text to Speech Engine
- TMP36 Analog Temperature Sensor
- RGB Led
Because the uLCD and the EMIC 2 Text to Speech Engine both require 5V. It is best to utilize an external power source instead of connecting it to the mbed's Vu.
Connections
RJ45 Ethernet MagJack
https://os.mbed.com/cookbook/Ethernet-RJ45
Ethernet MagJack | Connect to mbed |
---|---|
P1 | TD+ |
P2 | TD- |
P7 | RD+ |
P8 | RD- |
Important note: If the ethernet is utilized through campus wifi, the MAC address of the mbed must be registered for the wifi to recognize the hardware.
EMIC2
https://os.mbed.com/users/4180_1/notebook/emic-2-text-to-speech-engine/
EMIC2 | Connect to mbed | Connect to Speaker |
---|---|---|
5V | VU | N/A |
Gnd | Gnd | N/A |
SIN | P13 | N/A |
SOUT | P14 | N/A |
SP+ | N/A | + |
SP- | N/A | - |
uLCD
https://os.mbed.com/users/4180_1/notebook/ulcd-144-g2-128-by-128-color-lcd/
uLCD | Connect to mbed |
---|---|
5V | Vu |
Gnd | Gnd |
RX | P9 |
TX | P10 |
Reset | P11 |
Temperature Sensor (TMP36)
https://os.mbed.com/users/4180_1/notebook/lm61-analog-temperature-sensor/
TMP36 | Connect to mbed |
---|---|
Gnd | Gnd |
Vs | Vout |
Vout | P15 |
RGB LED
https://os.mbed.com/users/4180_1/notebook/rgb-leds/
Some Important Code for the Weather Application
To retrieve the current weather data, we decided to use the OpenWeatherMap api and pull the data from online. One of the biggest challenges was to extract the data that we were going to analyze using XML parsing code. Reading from the sample XML format, we coded accordingly to manipulate with the data inside the rest of our code. Here is an example of the XML format of the api:
Part of the code which handles data from api:
//temperature float temperature = atof(temp->getAttrValue("value"))-273.15; lcd.printf("Outdoor Temp: %.1f C ", temperature ); //humidity SP_XmlElementNode * humidity = rootHandle.getChild(2).toElement(); lcd.locate(0,5); string humid = humidity->getAttrValue("value"); lcd.printf("Humidity: %s%% ", humid); //condition SP_XmlElementNode * condition = rootHandle.getChild(8).toElement(); string cond = condition->getAttrValue("value"); //wind lcd.locate(0,7); SP_XmlElementNode * wind = rootHandle.getChild(4).getChild(0).toElement(); string windy = wind->getAttrValue("name"); lcd.printf("Weather: %s & %s ", cond, windy); //rain SP_XmlElementNode * rain = rootHandle.getChild(7).toElement(); string rainy = rain->getAttrValue("mode");
Another important part of our project was making our application use audio to deliver the weather data, and for this we used the EMIC 2 Text-to-Speech engine as mentioned before. We made the application speak certain strings through the EMIC and the speaker using speakf().
Example of Text-to-Speech Code:
myTTS.volume(10); myTTS.voice(6); myTTS.speakf("SThe current indoor temperature is %5.2f degrees. The current outdoor temperature is %.2f degrees with %s percent humidity. Currently the weather condition is %s with %s\r", mytmp, temperature, humid, cond, windy); myTTS.ready();
The rest of the code can be found here through this link:
Import programiWeather
Weather application for ECE4180 Project.
Demo of iWeather
Ideas and Future Work
Some future work that could be done for this project is making the option to choose or detect the current location of the user and present the weather data accordingly. We could also utilize an additional uLCD screen to portray the weather data visually using pictures and photos.
Please log in to post comments.