Tweeting Weather Station
by Jonathanrjpereira in Circuits > Electronics
18097 Views, 139 Favorites, 0 Comments
Tweeting Weather Station
Ever wanted to monitor your city's Current Weather Conditions, Carbon Footprint, Noise and Pollution levels? Do you want be a Climate Change Crusader or set-up your own Tweeting Weather Station and share your local weather conditions with the world?
Meet Tweeting Weather IoT Station aka TWIST - a DIY, Open-Source Environmental Monitoring and Meteorological Data Acquisition Platform. The purpose of TWIST is so that individuals and communities can collect data of what's actually happening in their environment and share this data on social media such as Twitter.
- TWIST is an Internet of Things (IoT) powered platform.
- The brain of TWIST is an Intel Edison Board.
- TWIST is compatible with a variety of sensors.
- All code, design files(schematics & PCB layout) are Open-Source. This means that anyone can contribute to the TWIST platform by sharing code and schematics for different sensors.
TWIST consists of three technological layers:
The first layer is a hardware board that contains all the weather and environmental sensors known as the 'Sensor Board'. As the name suggests, it carries sensors that measure air composition, temperature, humidity,rain. Additional sensors like seismic activity, UV index, barometric pressure, altitude, lux(luminosity), sound levels, wind speed & direction,etc can also be added. Once it’s set up, the Sensor Board is able to stream data measured by the sensors to the second layer. The second layer is the Intel Edison Board that receives data from the Sensor Board, processes it and sends it to the next layer. The third layer connects your Edison Board to the Internet over Wi-Fi using the wireless module on the Edison board and Tweet's the Current Weather & Environmental conditions.
Power to the device can be provided by a solar panel or an AC Adapter.
Version controlled repositories
All three technological layers of TWIST are Open-Source, and thus all the files we use for code, PCB development, mechanical design,etc are readily available on our Github repository.
Contest Entries
Intel IoT Invitational
I would like to thank Intel+Instructables for providing me with the Intel Edison Board. I plan on making many more IoT related Instructables using the Edison board.
#iotweatherstn
If you make TWIST, don't forget to tweet the weather using #iotweatherstn. #iotweatherstn can be a hashtag used by all IoT powered Tweeting Weather Stations.
Parts and Materials
Intel Edison
with Arduino Breakout Board
1MQ2 Combustible Gas Sensor
1
YL-83
Rain Sensor
1SL-HS-220
Temperature & Humidity Sensor
1Resistor
32K
4.7K
3 Metal Standoff 1inch
1Resistor
32K
4.7K
2Wood Sheet A4 Size
Can later be cut in size
3Metal Standoff
1inch
Electrical Design
Power
The entire system is powered from a 5V 1A power supply. The sensors(Temperature, Humidity, Rain, Gas) draws approximately 200 mA, the Edison around 500 mA, Since the total current required is less than 1amp, a 1 amp supply should work just fine. The inbuilt green LED on digital pin 13 of the Edison Board is used to show the power status.
Control
An Intel Edison runs the show for TWIST. The Edison is mounted on an Arduino breakout board, which makes it easy to read the digital & analog signals from the sensors. The Edison is connected to the 5V rail via a micro USB cable. The Edison has a built-in Wi-Fi radio, which allows it to connect to the Twitter without the need for any additional hardware.
Real Time Clock(RTC)
Since the time-stamping automatically carried out by Twitter for each tweet has a resolution limited to the number of total days since the time of Tweeting, a real-time clock is used to accurately time stamp the date and time in the Hour-Minute-Second format. The real-time clock used in the TWIST platform is the DS-1307 RTC module.
Sensors
The most basic setup of this system has four sensors(Temperature, Humidity, Rain, Gas) that connect to the Edison. Additional sensors can be added such as Noise, Wind, etc. Each sensor is directly powered from the 5V rail and has its signal pin connected respectively to analog pins A0 through A2 and digital pin 2 on the Edison breakout board. The sensors also each have a sensitivity adjustment potentiometer mounted on each sensor board; The MQ-2 is a combustible gas sensor (liquefied petroleum gas, propane, hydrogen, and methane) that outputs an analog voltage proportional to the concentration of gases in parts per million. The SL-HS-220 has a thermistor that gives the temperature value. Since the output of the thermistor is non-linear, the corresponding temperature table is given in the sensor repository. The thermistor requires a voltage divider circuit when connected to the Edison Board as shown in the circuit diagram. The SL-HS-220 also has an inbuilt hygrometer which measures humidity and outputs an analog voltage that corresponds to a fixed humidity value. The humidity-voltage table is also given in the sensors repository. A common substitute to the SL-HS-220 is the DHT11 sensor. The rain sensor/water sensor has a potentiometer which is adjusted to give a digital output for a certain amount of rain whose sensitivity can be adjusted by the user.
Mechanical Design
The body of the TWIST is made out of two plates of wooden sheets. Although I used 1/4" plywood, the design can be assembled out of any sheet material as the spacing (maintained by 1" aluminum standoffs) is the only critical element. I've attached the vector files for download above.
Laser Cutting
For all those who wish to laser cut the two plates, I have attached the laser cutter files for download below. It also includes an additional air quality sensor in its design. So you can either use an MQ2 sensor module or air quality sensor module depending on your choice.
Downloads
Frame Assembly: Face & Base
Faceplate
The Sensors fit into their matching holes and cut-outs and can be fixed using screws or glue.
Baseplate
The standoffs of the Edison board are screwed onto the Baseplate. The analog-to-digital converter(ADC) which is connected to the rain sensor can also be screwed onto the Baseplate.
Additional components like buzzers or the voltage regulator circuit for the solar input can also be screwed onto the Baseplate.
The Baseplate and the Faceplate are both separated by 1" standoffs.
Electronics & Sensor Assembly
Power
The power for the system is provided by a wall adapter with a standard barrel jack which is connected directly to the Edison's Barrel connector. The system can also be powered through the USB port on the Edison board. You can also power the board from an external Solar panel.
Sensors
The sensors are attached to breakout boards with male headers and hence they can be directly connected to the Edison via male-to-female jumper wires.
Twitter Configuration
Inorder to Tweet, we are using a third-party app developed by NeoCat that gets the Twitter token you will need to Tweet with your Edison board. Tokens can also be sourced from Twitter's Developers webpage.
So, to get started, visit NeoCat's website, follow his/her tutorial to get the twitter library and your twitter token. As NeoCat mentioned on their site, please don't abuse the service. Keep your tweets sparse. If you need something that tweets every 6 seconds, you should set up your own server and twitter app and hence the code that I wrote ensures that NeoCat's server doesn't overload(TWIST tweets every 6 hours).
The library uses this NeoCat's website as a proxy server for OAuth stuff. Your tweet may not be applied during maintenance of this NeoCat's website. Twitter seems to reject repeated tweets with the same content (returns error 403).
Software & Configuration
Follow Intel's setup guide for the Intel Edsion before you start coding.
The program is an Arduino sketch running on the Edison. I have explained each of the main blocks of code below.
The code includes some predefined constants, pin declarations and a couple of serial print statements that help in troubleshooting.
Tweet Delay
Since Twitter filters out tweets that have the same content and are tweeted within short periods of time between each of them, a standard 3 hour (10800000 milli second) delay between each tweet has been set.
tweetMessage(); delay(10800000);
Type Casting
A lot of the readings we get from the sensors are in the 'int' or 'float' datatype. But since we are tweeting these values, we need to convert them into a 'String' datatype. For this we use a special Type-casting technique.
char *dtostrf (double val, signed char width, unsigned char prec, char *sout) { char fmt[100]; sprintf(fmt, "%%%d.%df", width, prec); sprintf(sout, fmt, val); return sout; }
Twitter Token
The twitter token is created on NeoCat's website and should be pasted into the token space here.
void tweetMessage() { Twitter twitter(" ENTER TWITTER TOKEN HERE ");
Tweeting Sensor Values
In order to tweet the sensor value we first include the Sensor type; Example: "Humidity". This followed by a character declaration and a line of code required for typecasting. Next we add a statement for the unit of measurement; Example: "%RH". We can keep on adding values of other sensors too in a similar manner.
humidity(); float humid; //Twitter message String stringMsg = "Humidity:"; char tmp[10]; dtostrf(humid, 1, 2, tmp); stringMsg += tmp; stringMsg += "%RH";
Weather Station Location & Tagging
Next we tag the location(City,Locality,etc) and other tags like #iotweatherstn .
stringMsg += " #Mumbai #Bandra #iotweatherstn ";
Real Time Clock (RTC)
As explained earlier TWIST can also Tweet the Real Time Clock Data. Below is an example of the 'day' parameter block of code of the RTC. The Real Time Clock feature is optional in the TWIST platform since the module comes separately. Hence there is a separate branch created in the TWIST repository for the code and schematics of the Real Time Clock branch.
TwistDateTime();<br> DateTime now = rtc.now(); int twistday, twistmonth, twistyear, twisthour, twistmin, twistsec; String stringMsg = ""; char ds1307day[10]; dtostrf(twistday,1,0ds1307day); stringMsg += ds1307day; stringMsg += "/";
140 Character Limit
This block of code coverts the string array to 140 character array ready to tweet.
char msg[140]; stringMsg.toCharArray(msg, 140);
Message & Connection Troubleshooting
This block of code prints out a couple of lines of text in the Serial Monitor to help the user check the message and tweet status.
//Tweet that sucker! if (twitter.post(msg)) { int status = twitter.wait(); if (status == 200) { Serial.println("OK."); Serial.println("Message Tweeted"); } else { //Connection Test Serial.print("failed : code "); Serial.println("Message not Tweeted"); Serial.println(status); } } else { Serial.println("connection failed."); Serial.println("Message not Tweeted"); }
All the other blocks of code simply converts the analog or digital reading from the sensors into usable data.
The code can be dowloaded from here or from the main repository:
Contributing to the Sensor Repository
Are you a programmer, engineer or designer who has a great idea for a new feature in TWIST? Maybe you have a good idea for a bug fix? Feel free to grab our code, schematics & CAD files from Github and tinker with it.