Instructables

How's the world feeling right now? This box tells you.

Powered by: an Arduino, a WiFly wireless module, an RGB LED, Twitter.com and a 9v battery.

I’m a news junkie. I want to know everything that is going on in the world as soon as it happens. I want to wake up and know immediately if something big has happened overnight.

However, I’m an extraordinarily busy man; I don’t have time to read news feeds; reading that headline that I already knew about or don’t care about is time that I’m never getting back!

No. What I need is some way to be constantly in touch with the world's events as they unfold, alerted when something big happens, and to be made aware of it all faster than awareness itself!

...A way to get a glimpse of the collective human consciousness as an extension of my own.  Something that I don't have to continually check or poll, but instead, like a part of my body, it will tell me when it's feeling pain or generally in need of my attention ...leaving me time to get on with other things.

And so, I present: The World Mood in a Box!

The Arduino connects directly to any wireless network via the WiFly module, continually searches Twitter for tweets with emotional content, collates the tweets for each emotion, does some math, and then fades the color of the LED to reflect the current World Mood; Red for Anger, Yellow for Happy, Pink for Love, White for Fear, Green for Envy, Orange for Surprise, and Blue for Sadness.

If an unexpectedly high number of tweets of a particular emotion are found, then the LED will flash to alert us to the possibility of a world event that has caused this unusually strong emotional reaction.

For example, a world disaster and it may flash Blue or Red (sadness or anger), if the strong favourite loses a big football game it may fade to Orange (surprise), …and If it flashes White, the collective human mind is feeling extreme fear, and it's probably best to go hide in a cupboard and sit it out, waiting for sunnier skies and a return to Yellow or Pink.  ...OK, I'm not that busy.

 
Remove these adsRemove these ads by Signing Up
jmccauley22 years ago
The world has changed a bit since this program was first posted.  I finally have my mood light working, but it wasn't always easy.

First, make sure you buy an Arduino Duemilanove.  Yes, there are newer devices out there.  No, you do not want them.  They are all supposed to use the same code, but this code is sensitive to the timing on the Duemilanove.  Use another board and you'll be fighting issues all the way.  After over a year of this, I just switched and I'm glad I did. 

Second, the Twitter world moves much faster than it did.  30 tweets of the original terms go by in less than a second.  Since everything is computed in tweets per minute, this obviously won't do.   Everything registers off the scale. 

You'll have to substitute this code in TwitterParser.cpp to compensate. 

#ifdef DEBUG
    m_printer->println("assuming tweet was from yesterday");
#endif // #ifdef DEBUG
  }

  long seconds = time1 - time2;
  return seconds / 60;
}


with

#ifdef DEBUG
    m_printer->println("assuming tweet was from yesterday");
#endif // #ifdef DEBUG
  }

  long seconds = time1 - time2;
  return seconds;
}


I also had to modify my LED.cpp file to make sure colors showed up properly.  In particular, I had to adjust the array values in the beginning to accurately show colors with my LED -- apparently my red isn't as bright as the blue and green and so full value on all three skews the colors.   I added the following text to the WorldMood.cpe to make it easy to test light colors -- right after the device starts up, it triggers the light to the values specified.  Value range goes from 0 to 255. 

          //a way to quickly test colors and connections
          analogWrite(redPin, 255);
          analogWrite(greenPin, 35);
          analogWrite(bluePin, 0);


It goes immediately after this line:

         LED led(Serial, redPin, greenPin, bluePin, fadeDelay);
 

I am still adjusting my search criteria and making minor adjustments, but this solves most of the "out of the box" issues I've seen people experience. 
RandomMatrix (author)  jmccauley21 year ago
Yes, Arduino, Twitter and the World's Mood have changed a lot since May 2010. I"m afraid this is not an active project of mine, and I rely on great comments like this to keep this 'ible current.

Hey, the new API requires OATH and this project no longer works. It's a little beyond my ability to fix it, but would you like to work with me to provide updated code? This seems to be a fairly popular project and it's really cool when it works.

Also, as of today, the project no longer works.

Twitter has changed its API and now the query returns errors.

Is there a way i can still make it ?

would be a great help if you can sugest a way to do this ?

Unfortunately, no. I've not been able to get it to interface with the new API.

excellent idea, i think the search terms could be 'work in progress' but other than that a really cool idea.

dmagryta1247 months ago
How can I make this without using the WiFly module?

I second you, too.

So can this still be done ?

If yes , do i need to buy the same hardware?

laptopdude908 months ago
What would be better is to have a "mood server" that calculates the mood, and have the Arduino connect to it.

Since all the heavy work runs on the server, the mood could be updated much faster than the Arduino, and it would save battery life.

I'd write the server software myself, except I suck at interfacing with Twitter... :P
bkang12129 months ago
hi so i downloaded the code but it doesn't work with processing or arduino because i have updated versions. Is there an updated version of the code in .pde and .ino format
luckyvictor11 months ago
It is a very nice project however, you constantly search for news, does it consume a lot of battery?

Can you actually make it passively receive the data in a periodical manner? or wait for a device or app to send a 'mood' to it whenever this device receives a twitt? I know it is always possible, but what could be the implementation please? do you have any idea or example?

As I would like to make one that ideally be waiting and be triggered so to consume the minimum power
dmeeker1 year ago
I am not even sure where to start with this comment!  Bottom line, I got this running on newer hardware with a newer IDE.

Long story short: I started working on this using the 1.01 Arduino IDE, an Arduino Uno and an LED "ball" which I found referenced here:
http://hackaday.com/2012/09/08/hacking-a-floating-rgb-led-decorative-ball/

I liked the look of that ball, and thought to myself "what can I do with it that is cool". I bought one, and then decided to see where I could take this instructable.

Like many of you, I ran into all sorts of errors when trying to load up the sketch and libraries to make it work.

After hacking away at it for about 8 hours over the last week, I've gotten it compiling and running on the new version of Arduino, with an Uno and not the Duemilanove. Once I get things a bit cleaner, and I document what changes I actually made,

I will post the full code somewhere and add it to this comment thread.

The quick overview:

1) Wired up my LED. I am using the LED array that came inside the ball. I also wired up a Sparkfun RGB LED Breakout to see if it would work across both. (https://www.sparkfun.com/products/10111). It does. I had to make the code change referenced in the comments and on this blog to make the colors match best with the Sparkfun LED kit. (http://www.stephenhobley.com/blog/2010/06/11/arduino-world-mood-light-using-twitter-and-wishield/)

2) In each of the libraries that were included, I had to update the code to replace: #include "WProgram.h" with #include

3) The timing and error handling are still pretty screwed up, and not where they should be. I am going to work on that next. The code will execute, and throw some errors, but in true arduino fashion, if you let it run, it will power through things and get to the next step.

4) Pay attention to the comments in "step 6", download the code: I HAD to do this. If you have a newer board then you may need to change this struct SPI_UART_cfg SPI_Uart_config = {0x50,0x00,0x03,0x10}; to this: struct SPI_UART_cfg SPI_Uart_config = {0x60,0x00,0x03,0x10};

5) Once I did those things, I got it to compile and pushed to the Arduino.

It would go out and attempt to make a request to twitter, but I'd get a 404 from twitter. This caused me to scratch my head for a day, contemplate rewriting the entire WIFLY library and then it hit me...

The http request had something wrong with it. In the worldmood sketch, you must look at the lines where you define the search request and make a small change, appending HTTP 1.0 to the end of each.

It WILL NOT WORK UNLESS YOU DO THIS.

These lines:

prog_char string_1[] PROGMEM = "GET /search.json?q=\"happiest\"+OR+\"so+happy\"+OR+\"so+excited\"+OR+\"i'm+happy\"+OR+\"woot\"+OR+\"w00t\"&rpp=30&result_type=recent";

Should become:

prog_char string_1[] PROGMEM = "GET /search.json?q=\"happiest\"+OR+\"so+happy\"+OR+\"so+excited\"+OR+\"i'm+happy\"+OR+\"woot\"+OR+\"w00t\"&rpp=30&result_type=recent HTTP/1.0";

I think that is about it, but I need to go back and look at everything to ensure that there weren't other items necessary.

The one item I haven't addressed yet is that when left as-is, the twitter search for "envy" still fails. I can't understand why, but I haven't taken much of a look at it yet.

To get past this, I changed the search string from the original to this:

prog_char string_4[] PROGMEM = "GET /search.json?q=\"i+wish+i\"+&rpp=60&result_type=recent HTTP/1.0";

I basically got rid of the search and just put in "I wish I" for the time being.

So, there you have it. If anyone wants to continue to improve, the army of "modern" Arduino hackers can start from this modified code that indeed works. (yay!)

https://www.dropbox.com/s/ewrbhqphya64dmc/World_Mood_Nowlab.zip

Enjoy, and please share comments as you make progress.

Dave
Hey! I tried going to the dropbox link you gave, but the file is missing. Do you still have it up somewhere? Thanks in advance!
facepalm1 year ago
When running this code I got errors saying "WProgram.h" did not exist. The solution is to replace any instance of

#include "WProgram.h"

with

#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

(source: http://makezine.com/2011/12/01/arduino-1-0-is-out-heres-what-you-need-to-know/)
can we make this using a wifly module rn xv wifly shield
damianest1 year ago
Being fairly new to Arduino and EE / Physical Computing, I am not at the stage where I feel comfortable making my own Circuit Boards. Would anyone mind posting how to wire this via breadboard?
I would love to make one of these... however $70-$100 for the WiFly shield is way too much... any other ideas that would substitute?
I'm in the same dilemma :( Wifly shields are expensive where i come from. I suppose an Ethernet shield would help?
pabhilash1 year ago
So, i have a question. How could i accomplish this project with an Ethernet shield instead of the Wifly shield? (I ask because the Wifly shield is rare and expensive where i come from..)
pwnag31 year ago
a wonderful idea
praveenkm2 years ago
Hi,

I compiled this code and getting me lot of errors..
plz help me!!!
Untitled.png
h00k praveenkm1 year ago
This looks like a fantastic idea.  I'll probably adapt the base and use wood, and maybe allow for USB power instead of the 9V battery as well.  Also, perhaps an on-off switch on the back may be something I'll do.

How long are you experiencing the 9V battery last?

Thanks for this, it's going to get me working with acrylic, something I haven't done yet.
did you ever get the problem fixed? i had the same problem
jmccauley21 year ago
Something else to keep in mind, the Twitter API is about to change. When it does, it appears that after 5 March 2013, this code will no longer work and will require an update.

If I figure out how to make it work again, I'll post the code here. If not..... I guess I'll hope someone else figures it out.


https://dev.twitter.com/blog/changes-coming-to-twitter-api
samirsky2 years ago
The Olympics stole your idea!
http://www.metro.co.uk/olympics/907250-twitters-olympic-mood-beamed-to-world-from-edf-energy-london-eye

I was still excited to see the concept on the international stage.
RandomMatrix (author)  samirsky1 year ago
Ha! Not the first nor the last, i suspect :D
citronella2 years ago
Has anyone tried to make this with processing?
Or perhaps with an ethernet shield? I'm really interested!
dava_22 years ago
Has anyone tried to make it work over USB cable, without Wifi?
Lachee2 years ago
is it possible to use a usb with a processing script?
ilpug2 years ago
I have nowhere near the experience to make one of these things, is it possible that I could buy one from someone, and if so, for how much?
lance_r4 years ago
It would be really sweet to make a desktop version of this you know? so when your doing regular work on the old comp. you can tell the world's mood!
RandomMatrix (author)  lance_r4 years ago
(removed by author or community request)
Much appreciated I tried to take it on myself but got hung up on html parsing haha need to brush up on my c++
check out:
http://www.mathworks.com/matlabcentral/trendy/plots/644

It only updates once/day, but might be interesting to monitor over time.

samirsky2 years ago
Created a plot to track trends (1/day) based on this great project:
http://www.mathworks.com/matlabcentral/trendy/plots/644
madmazelle3 years ago
Hey ! nice project, very inspiring. btw wanna ask (i'm new with this) is it possible to use ARDUINO ETHERNET SHIELD instead of wifly shield?

will the script be different?
Yes, you could go that route, but you will have to rewrite the sections that reference the WiFly Shield. There's no shortcut, I'm afraid. Change the hardware and you have to change the code.
is alright! i bought the wifly shiled.

Thanks for the reply!
brittawater2 years ago
I'm trying to get my twitter mood lamp to work but I keep getting a
'Serial' was not declared in this scope error. Does anyone know how to fix it? When I tried looking online, I came across a blog that suggested to include the Software Serial library, but that didn't seem to do anything.
The fix to that is described over at the Arduino Boards. However, we're still having timing issues to work out among other things. Follow along over here:
http://arduino.cc/forum/index.php/topic,65655.0.html

It also appears that these issues are more common if you're using the Arduino Duo instead of the Duemilanove.
benreed2 years ago
hey awsome project :) but i keep getting error messages on the code? i have never built a project with code before so i have no idea what im doing , i have a fairly good knowladge of computers however , you think you can help?
aattwater3 years ago
I built the device, and it looked like it was working correctly giving me an overall mood of mild love. looking at the serial monitor, after doing the query search it shows a list of results, and on the 29th result it cuts short and says "warning: failed to find EXIT" and gives the line: "love: tweets per min = 29.00". it does this for Love, Joy, Surprise and Anger, all giving a result of 29 tweets per min, which seems odd... I'm using an Uno with th Wifly shield.
santoshx3 years ago
This is amazing. For an Arduino novice like me, It worked in the first go! Thanks for this excellent contribution. I am not that familiar with the Twitter interface, is there a way to specific a country and look at the twitter moods there. It will be like a magic cube during international traveling.
This is so cool, but I'm still not going to get a twitter.
granjef33 years ago
What color did it display when Osama Bin Laden died?

Btw, very nice project/instructable
Haha i never got it too work. amazing idea though
Genzo3 years ago
Hi, nice project. I'm being to buy products to do it.

But I think I won't use a 9V battery I'm interrested by a Lithium battery like http://www.nuelectronics.com/estore/index.php?main_page=product_info&cPath=1&products_id=17 (with a solar panel http://www.nuelectronics.com/estore/index.php?main_page=product_info&cPath=6&products_id=16 ?).

Let's get crazy :)
0ReZ3 years ago
a wonderful project, and as said by many its well executed. i have a few questions. instead of a 4-pin LED can it be run on 3 different 2-pin LED? and when i connected the wires to pins 3,5,6 the LED's dont glow. I'm using a 9v plug instead of buying those cumbersome power hungry batteries. waiting to hear a reply.
manu083 years ago
Nice!! Where do I get the acrylic plates?
MJTH3 years ago
This is a great idea and would really like to build one!

However I dont have the money for an arduino or the wifi adapter.

You should collaborate with someone who knows stuff about microchips and create a microchip and maybe replace the wifi with an ethernet port..

(you could add selective tweets through a lan cord that way, and collect tweets)

that way more people may be able to afford it, and you could even sell it to people like me :)
mdot2theg3 years ago
Could I use a a WiMicro for this project instead of a Wifly? And if so would the coding/libraries be much different?
great job btw :)
Parabola9494 years ago
...  I have to say.... this is simply genius.   I've viewed many projects on here, but this is the first one I had to comment  on just to say how good of an idea it was.  I WILL be building this.
RandomMatrix (author)  Parabola9494 years ago
Thank you!

Do contact me if you have any issues building it. Having had the thing running for a while, I must suggest using rechargeable batteries. I will be very interested to see how yours works out, and if you think of any improvements, do let me know.
Possibly a modification to use a simple 9v plug? I'm not sure of the exact name, but I have a lot of them for my synthesizers, and they're all 9.0v. It should be a pretty simple and cheap mod, yes?
I completely agree. This is an excellent idea, carried out very well... Building one as soon as possible.
I have made a much simplified version of this that reads twitter posts looking for numbers rather than moods. Thanks for the inspiration to make something much less inspiring :) http://www.instructables.com/id/Twitter-Controlled-Light-Bot/
I love this, and would love this next to my bed! One thing though. To keep cost down, how hard would it be to program the Arduino to read the information straight from the computer via USB connection?
jamilm94 years ago
and would this work instead of an arduino http://asynclabs.com/store?page=shop.product_details&flypage=flypage.tpl&product_id=23&category_id=11
jamilm94 years ago
How many ma does this need. Thanks
shobley4 years ago
I built the device, but noticed something strange in the LED library,. When you call analogWrite you are subtracting the values from 255, and yet the array of values is written to be applied directly. i was getting strange colors until I removed the "255 -" from each call to analog write. The movie here shows how it is responding before the fix: http://www.stephenhobley.com/blog/2010/06/11/arduino-world-mood-light-using-twitter-and-wishield/
frenzy shobley4 years ago
Congrats!

This project has won the "I Made It" Challenge for today. For that you will receive a 3 month pro membership!

http://www.instructables.com/community/June-is-I-Made-It-Challenge-Month-Win-a-Pro-Mem/
RandomMatrix (author)  shobley4 years ago
Thanks for making my project! Interesting ...I was getting the strange colors before adding the "255 -". Could it be that one of us is using a cathode LED, and the other is using an anode LED? I see you found a cheaper alternative the to the WiFly, and from your blogpost, look to have improved on the code too :) I'll be very interested to hear if you find any further improvements, bug fixes or think of ways to extend the project!
That would probably explain it - my LED has a common ground connection - so does yours have a +5v common? I think I got my LEDs from Sparkfun originally - it's been stuck in a drawer for a couple of years, so I don't know the model. It was fairly easy to make it work with the WiShield, although I am having some problems keeping it connected to the network. Sometimes it just comes back with "0.00" results for each of the emotional states. I was going to implement the web server functionality - the WiShield has additional ram available to store page templates that can be served up by filename. Great project BTW!
Zenix4 years ago
WOW! Absolutely brilliant project, well done!
 What an excellent project RandomMatrix, you should be proud! Excellent project and presentation. I hope I get a chance to build this, what an awesome idea! 
hogofwar4 years ago
Can you mod this to just connect from usb to get the network connection instead of from wireless and get the power from the usb connection instead? maybe a mini version?
Awesome Idea, We Could Have Various Boxes with a Demographic Filter Showing the Moods of various countries :)
such vision! as your life is so busy, one is surprised you found time to geek this together! are you busy doing what you love or busy fulfilling somebody elses dreams? with this kinda skill perhaps a career in electronics is calling?
jackminardi4 years ago
 Step 13
... Make it tweet what the world mood is so as to complete the circle.

So you are the guy who made twitter self aware?
Brooks.B.J4 years ago
 Yes, agree, this is a superbly analysed and executed project.  Solved all sorts of interesting problems to reach the end result.  First class!  Congrats.
chilll20094 years ago
You should add codes for other sites feelings to :)
chilll20094 years ago
Wow!
hotLatte4 years ago
"Awesome" is so overused -- but not for this idea! If I had a relationship with things techy, I would definitely construct it, but alas... 

Anyway, pjamestx: I like your webcam and "Happy Tweet Day" suggestions. 
Ward_Nox4 years ago
some ware a green lantern fan with more tech know how than me just got a REALLY cool idea from this
Killer! I really like this. Wait, will 'killer' register as positive. Brilliant friend. Brilliant.
jamilm94 years ago
next make a physical one of these
http://gcpdot.com/ 
RandomMatrix (author)  jamilm94 years ago
...interesting... Thanks for the link!
Wait, what does that gcpdot do exactly?? By the way amazing instructable!!
Arbitror4 years ago
This is possibly the coolest device that interacts with the web, that I've ever seen! This is a very detailed Instructable, which deserves more than five stars!

(How's the world feelin' right now?!)
RandomMatrix (author)  Arbitror4 years ago
 Wow. Thank you.

(Mildly sad. ...Perhaps it's the pre-Monday-morning feeling?!)
RandomMatrix (author)  RandomMatrix4 years ago
 ...oh, and the ash cloud is back over the UK.
Wow, this is very cool.
I wonder what else we could apply the same system to?

Maybe link it to your significant other's facebook status updates? LOL.

RandomMatrix (author)  TheWomanMonster4 years ago
 :D ...i do think there is more to be done here... look out for TML 2.0!
chrism23524 years ago
This is a really impressive project, but it's pretty ironic that you're extraordinarily busy yet still have time to build this device and write up the instructible for it. Spend a little time to save a lot, I guess ;)
RandomMatrix (author)  chrism23524 years ago
Hahah, yes, i might not be quite as busy as i say. Thanks chrism!
jamilm94 years ago
This is just truly amazing 
RandomMatrix (author)  jamilm94 years ago
Very kind of you to say. Thanks!
reviver4 years ago
Has anyone thought about recreating this in electronic form?  For example, a desktop widget or some type of wallpaper application?
RandomMatrix (author)  reviver4 years ago
I may have :)

I'll let you know when it's done. 
conmac8634 years ago
Great idea and great instructable....

All said and done what was the total cost?

RandomMatrix (author)  conmac8634 years ago
Thanks! It cost about $175 (see above for a rough breakdown)
Oliveman4 years ago
 Two questions:

1st, How much did it cost to make this? I totally want to build one now.

2nd, Could we get a video of it in action?

RandomMatrix (author)  Oliveman4 years ago
1.  About $175. The big expenses are the WiFly shield ($90), Arduino board ($30), and acrylic ($30). And this is assuming you have all the tools already (soldering iron, wire cutters, etc). Also, I'd actually recommend using a rechargeable battery as it is quite power hungry.

2. Great idea. I'll do one soon.
What a brilliant idea!  Would love to see it in action
zascecs4 years ago
Gee, I could really use one of these sometimes... 
brunoaco4 years ago
cool project.

your work is awesome!
I would like to try that with cheap router that runs linux and bypass the need for an arduino
Cabe4 years ago
That's properly awesome. Cheers.
darkclaw424 years ago
 Wow! Nice one. This would be a project I would do, if I had the time and a free arudinio. If only there was a way to sync this up with Facebook..
pjamestx4 years ago
Wow, great write-up!  It's rare to see Arduino code with good comments, much less a detailed description of what it does.  From what I've seen with Twitter, you might get more hits if you slightly misspelled your search terms...  Now you're going to have to get a webcam going on this so we can all watch it.  Maybe you can even organize a world "happy tweet" day to try to get it as yellow as possible :D
scoochmaroo4 years ago
I don't understand the code, but this sounds incredible.  I can look at a box and it tells me what the world is feeling?  Now I can blame this when I don't want to leave my house!!