Step 4: Firmware

The latest complete #twatch firmware download is on the project Google Code page. The code is written in C, and is compiled with the Microchip C18 demonstration compiler.

TCP/IP stack and base network functions

Microchip's 'free' TCP/IP stack provides all the network functions we need to exist on a home network and grab data from Twitter. The stack is open source and free-as-in-beer, but the Microchip license prohibits distribution. Due to licensing issues, we're only putting our public domain source code in the project Google Code SVN, learn how to download and compile the source here.

The stack has a Dynamic Host Configuration Protocol client that automatically configures the network settings using the DHCP server on your local network. The #twatch requires a DHCP server, but the vast majority of networks and routers have this enabled. The IP address, mask, gateway, and first DNS server are displayed on the LCD screen until valid Twitter data is available.

The stack also includes Microchip's announce server. When the IP address is acquired by DHCP, the #twatch announces its IP address with a broadcast packet to all computers on the local network. Use the MCHPDetect.exe utility in the project archive to view these packets.

Finally, we included a ping (IMCP) server. Use any ping client to check if the #twatch is alive on the network.

Twitter TCP client

The Twitter trend following program is a simple TCP client, similar to a web browser, that pulls data from web servers. Twitter's API will give us data in a variety of formats. We used the light-weight JSON format because it's easiest for the low-power PIC chip to decode, check out JSONView if you use Firefox.

After the #twatch automatically configures network settings, the Twitter TCP client takes control and grabs the current trending topics. It searches through the this JSON datafeed and looks for the "name" tag. Up to 10 trending topics are copied into a 225byte buffer. A separate array stores the end position of each topic in the buffer so we can retrieve the topics in the next step.

Next, the #twatch searches Twitter for 2 tweets for each topic. It appends each topic to the end of the Twitter JSON search url, special characters like spaces and punctuation are URL encoded.

The TCP client parses through the search results and looks for tweets that follow the "text" tag. Tweets have multiple layers of encoding. We decode HTML reserved characters like ampersand (&) and quotes (") because the LCD screen can display them. We remove UTF8 international characters because the HD44780 LCD doesn't have them in its character set.

The parsed, decoded tweets are stored in a 2100byte buffer, an additional array marks the beginning and end of each tweet in the buffer. RAM space was a big problem on the 18F67J60 chip, it only has about 4000bytes total, but the 2100byte buffer seems big enough to handle 20 average-sized tweets. We took special care to protect against out of memory problems, and we tested the client under reduced RAM conditions to ensure that it fails gracefully during errors.

Twitter is well known for its occasional down-time. If the #twatch can't connect to Twitter, it displays a connection error message and the retries twice. If it can't connect after three tries, it waits five minutes before trying again. This gives Twitter a chance to fix their problems without being hammered by #twatch queries.

The #twatch grabs fresh trend and tweet feeds every five minutes. Twitter puts a limit on the number of queries a client may make, so be careful about refreshing more often. Twitter allows 150 trending topic updates per hour, and "significantly more" search queries.

Network LCD backpack mode TCP server

The #twatch can also display system status information from programs like LCD Smartie. The #twatch has a TCP server on port 1337 that accepts Matrix Orbital formatted commands. This also provides control over the LCD backlight. We'll show you how to redirect LCD Smartie from a COM port to the #twatch TCP server in part two of our #twatch article.
<p>Do you have method to update firmware without the need of manually restart the device? My device is installed at location where accessible is very low,</p><p>Regards,</p><p>Neverlog</p>
This would be perfect if there was a way to hook it up to a LED ticker.would be great for people who want a ticker in their homes to update onsports, news, stocks, etc.
This is cool. Anyone know if there are any plans for a wireless network connection? The picture frame idea is kinda cool, but it would require you to be close to your router/PC to work.
I've seen wireless access points that are just a WIFI card with an ethernet jack output, that would probably work.
you could use a modded router as an access point and do it that way, but you would still have to have some cable
I have a similar device I built from a kit. Ybox2 by Ladyada:<br/><a rel="nofollow" href="http://www.ladyada.net/make/ybox2/">http://www.ladyada.net/make/ybox2/</a><br/>I love it.<br/>
Part 2: ethernet LCD backpack, is now online:<br/><a href="https://www.instructables.com/id/Networked-LCD-backpack-with-LCD-Smartie/">https://www.instructables.com/id/Networked-LCD-backpack-with-LCD-Smartie/</a><br/>
I don't use Twitter at all, but this thingy peaked my interest. Nice gadget. I would suggest a name change though. Twatch sounds abit nasty IMHO...maybe Twitcher would be better.
Would it be possible for this to show facebook's rss feed instead of twitter's?
Somewhat off topic... This almost fits function I need to fill. Can anyone suggest something that would be perfect? I organize a vanpool commuting to work. We normally communicate via text messages if someone is not coming, but there's no central location to text into because someone texting in doesn't know if the person they're sending to is riding that day. I'd like a central message station sitting in the van to receive the various messages and scroll them during the morning. We have WiFi/ethernet fed from a Verizon card plugged into a Cradelpoint CTR500 router. I'd like something small (not old laptop sized) and cheap (sub-$100). The backend could be anything that a text message could be routed to... The phone number for my Verizon Card, Twitter, email, etc... I would just need a small unit that could access it and scroll the data. This would be perfect if this device could do twitter feed watching, but as is noted in step 6, additional hardware/hacking would be needed and I'm short on soldering/hacking time for this project. Can anyone suggest a mostly off the shelf solution? Thanks
Mike wrote me with a comment that didn't show up for some reason:<br/><br/><em>I'm wondering, would it be possible to set up your device to receive content from LCD Smartie other than machine status i.e. anything one could set LCD Smartie up to display?</em><br/><br/>My specific interest is in RSS news.<br/><br/>Thanks!<br/><br/>Mike<em></em><br/><br/>The #twatch shows anything LCD Smartie (or LCDproc, or LCDC, etc) can output, I just showed the default demo. The #twatch has a generic 'ethernet LCD backpack' mode that imitates a serial or USB Matrix Orbital compatible controller, only over the network. Matrix Orbital is pretty popular, so most LCD control software supports it. I'm going to publish the second part of my article today, it will cover this part of the design and how to use it.<br/>
Thanks! Mike
Would it be possible to configure the unit to display RSS feed data from LCD Smartie instead of system stats?
so basicly its a stock tikker for twitter trends...you know a site like hollywood stock exchange for twitter trends could be interesting
If its a tikker for twitter, dont that make it a Twikker?
where did you get the vfd display?
The VFD is a Futaba screen that’s HD44780 compatible. I got it on eBay, but you can find various types on the internet.
Have you come across <a rel="nofollow" href="http://www.sciencemuseum.org.uk/visitmuseum/galleries/listening_post.aspx">Listening Post</a>? It's an art installation at the London Science Museum that my girlfriend introduced me to- a wall of about 270 of these VFD displays grabs text off public online chatrooms and displays what it finds in a number of modes. In spirit it's pretty much the big brother of your design.<br/><br/>Standing in the dark watching a large wall of clicking, glowing green displays showing, <em>in real time</em>, a visual waterfall of communication that is at that moment flying around the internet made me feel like I was in The Matrix. I even got to compliment the designer via a transatlantic Skype video chat. We live in the future :)<br/>
hey this is cool but is there any way to make it to display music from playlist and without the Ethernet plug i know this is a little off topic but hanks any way
It can display playlists, songs, PC stats, Folding @ Home, game stats, etc. Check out LCD Smartie, it's a program that does this for LCD screens. The #twatch does it over a network, though, instead of a serial, USB,or parallel port.
Drop vfd-tweets450.jpg into the intro as image #1 it looks better than what's currently showing in the thumbnail? L
Thanks. Done.

About This Instructable




More by ian:Thermal Tweeter networked Twitter printer @tweet_tree: Twitter controlled Christmas tree Hackable Christmas card & ornament 
Add instructable to: