---
title: "Use twitter and weather to post notes and temperature to office door (RE)"
url: "https://maker.wiznet.io/jaden/projects/use-twitter-and-weather-to-post-notes-and-temperature-to-office-door-re/"
markdown_url: "https://maker.wiznet.io/jaden/projects/use-twitter-and-weather-to-post-notes-and-temperature-to-office-door-re/md"
type: "UCC: User Created Content"
author: "bogdanzalmoxis"
author_url: "https://www.instructables.com/Use-twitter-and-weather-to-post-notes-and-temperat/"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "bogdanzalmoxis"
original_url: "https://www.instructables.com/Use-twitter-and-weather-to-post-notes-and-temperat/"
published: "2023-10-05"
language: "en"
hardware: ["Arduino Ethernet Shield", "Arduino UNO"]
likes: 0
views: 216
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Use twitter and weather to post notes and temperature to office door (RE)

> Use twitter and weather to post notes

Original author: bogdanzalmoxis (source: https://www.instructables.com/Use-twitter-and-weather-to-post-notes-and-temperat/)

## Components

- **Arduino Ethernet Shield** x 1 ([docs](https://docs.arduino.cc/retired/shields/arduino-ethernet-shield-without-poe-module))
- **Arduino UNO** x 1 ([docs](https://www.farnell.com/datasheets/1682209.pdf))

## Article

![Use Twitter and Weather to Post Notes and Temperature to Office Door](https://content.instructables.com/F60/ULF7/GPAS2II9/F60ULF7GPAS2II9.jpg?auto=webp&frame=1&fit=bounds&md=c03dc7e9a0cd8a6d29fc2cd9cbd5139b)
**Introducing the Office Door Notification System via Twitter**

This project is an embodiment of the idea to utilize a Twitter account for transmitting memos to an office door equipped with a 20x4 LCD screen. The inception of this concept was presented in an IEEE Spectrum article. Moreover, the system is enhanced to display the current temperature of a specified location.

![Use Twitter and Weather to Post Notes and Temperature to Office Door](https://content.instructables.com/FN1/VE5X/GPAS2IID/FN1VE5XGPAS2IID.jpg?auto=webp&frame=1&width=400&fit=bounds&md=487e21ff89482dc808da919a36e986cb)

The implementation revolves around the combination of an Arduino Uno board paired with an Arduino Ethernet Shield. The total expenditure for the project is roughly estimated at $120. It's prerequisite to be familiar with Arduino tools.

![Use Twitter and Weather to Post Notes and Temperature to Office Door](https://content.instructables.com/FM4/QQLR/GPAS2II3/FM4QQLRGPAS2II3.jpg?auto=webp&frame=1&width=400&fit=bounds&md=d0a1e8887ea47d20ebeea6fa0def44d1)

**Hardware & Software Details:**

- The hardware components encompass the Arduino Ethernet Shield, Arduino Uno, a 20x4 LCD display, a project enclosure, a USB cable, and a 9-pin conductor among others.

- On the software side, you would require the Arduino sketch along with various Arduino libraries.

Functionally, the system selects and displays tweets starting with "BZD" from the user's Twitter account onto the LCD. This allows for notifications such as office hours or coffee breaks to be posted and displayed via tweets.

this is main code of arduino uno

// Get "selected" latest tweet from Twitter account "BZDoor" and display it on the
// LCD display, which I have fixed on my office door. By selected I mean tweets that
// start with the key "BZD" only. I use the Twitter account to post notes on my
// office door about office hours, being out for coffee, etc. :-)
//
// The circuit:
// LCD pins 1,3,5,16 to Arduino digital pin GND
// LCD pin 2 to Arduino digital pin +5V
// LCD pin 15 via Resitor 330 Ohms to Arduino digital pin +5V
// LCD pin 14 to Arduino digital pin 2
// LCD pin 13 to Arduino digital pin 3
// LCD pin 12 to Arduino digital pin 4
// LCD pin 11 to Arduino digital pin 5
// LCD pin 4 to Arduino digital pin 9
// LCD pin 6 to Arduino digital pin 8

#include &lt;SPI.h>
#include &lt;Ethernet.h>
#include &lt;EthernetDHCP.h>
#include &lt;TextFinder.h>
#include &lt;LiquidCrystal.h>

LiquidCrystal lcd(9, 8, 5, 4, 3, 2);

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x4F, 0x8A };
byte ip[] = { 192,168,1,177 };
byte server[] = { 199,59,148,10 }; // twitter.com
byte server_weather[] = { 140,90,113,200 }; // weather.gov

#define NUM_CHAR_USERNAME 7 // "BZDoor:" is username with 6 characters + :
#define TWEET_OFFSET NUM_CHAR_USERNAME + 5 // useful info from tweet to be displayed appears after "BZDoor: BZD "
char tweet[NUM_CHAR_USERNAME + 140]; // 147 = "BZDoor:" + 140 for actual tweet
char old_tweet[] = { "BZDoor: BZD No updates. Have a nice day! Current temp: NA Cris " };
char temperature[8];

Client client(server, 80);
TextFinder finder(client);
Client client_weather(server_weather, 80);
TextFinder finder_weather(client_weather);

void setup()
{
lcd.begin(4,20);
lcd.clear();
lcd.print("BZDoor2LCD");
Serial.begin(9600);
Serial.println("BZDoor2LCD");
Ethernet.begin(mac, ip);
}

void loop()
{
// (1) check if new tweet is present in BZDoor account;
check_for_new_valid_tweet();
// (2) check for temperature; also display signature;
check_for_new_temperature();
// (3) clean up;
client.stop();
client.flush();
client_weather.stop();
client_weather.flush();
// (4) also clear the "tweet" storage array; otherwise if latest tweet is shorter
// than the previous one, remnants from the previous will become part of the latest;
for ( int i=0; i&lt;NUM_CHAR_USERNAME+140; i++) tweet[i] = ' ';
// (5) delay 2 minutes before next update;
delay(120000);
}

void check_for_new_valid_tweet() {
// responsible with 1st and 2nd rows of the 4x20 LCD;
// connect to Twitter (RSS of user BZDoor: 316663659) and get the latest tweet;
// this check will be done every other 2 minutes, so if more tweets have been posted
// have been posted within these 2 minutes only the latest tweet will be processed;
if ( client.connect()) {
client.println("GET http://www.twitter.com/statuses/user_timeline/316663659.rss HTTP/1.0"); // BZDoor;
client.println();
} else {
lcd.setCursor(0,0); lcd.print( "Twitter connection ");
lcd.setCursor(0,1); lcd.print( "failed! ");
Serial.println("Twitter connection failed.");
}
if ( client.connected()) {
// get the last tweet in BZDoor's account by simply parsing the item and title tags;
if ( (finder.find("&lt;item>") && (finder.getString("&lt;title>","&lt;/title>",tweet,140)!=0)) ) {
// only tweets that start with the three characters "BZD" will be displayed
// on the LCD display on the office door; all others will be printed only to
// the Arduino's serial monitor
Serial.println(tweet);
// a regular tweet in BZDoor's account is always in one of two formats:
// 1) "BZDoor: This is a Hello World! tweet!", which is not displayed on LCD;
// 2) "BZDoor: BZD Some update", which is displayed on LCD because starts with key BZD;
if ( tweet[8] == 'B' && tweet[9] == 'Z' && tweet[10] == 'D') {
// this is a tweet that has an update from BZDoor to be displayed on the office door;
display_tweet(tweet);
// also copy this latest twit to old_tweet array;
strncpy(old_tweet, tweet, 80+TWEET_OFFSET);
} else {
display_tweet(old_tweet); // first time this says no new updates;
}
} else {
lcd.setCursor(0,0); lcd.print( "Could not find item ");
lcd.setCursor(0,1); lcd.print( "field in last twit ");
Serial.println("Could not find item field in last twit");
}
} else {
lcd.setCursor(0,0); lcd.print( "Disconnected from ");
lcd.setCursor(0,1); lcd.print( "twitter ");
Serial.println("Disconnected from twitter");
}
}

void display_tweet( char msg[]) {
// display only 40 characters on the first two rows of the
// 20x4 LCD display; the third and fourth rows are used for
// temperature and signature display;
lcd.clear();
// display tweet's first 40 chars;
lcd.setCursor(0,0);
for ( int i=TWEET_OFFSET; i&lt;TWEET_OFFSET+20; i++) {
if (msg[i] != 0) lcd.print(msg[i]);
else lcd.print(' ');
}
lcd.setCursor(0,1);
for ( int i=TWEET_OFFSET+20; i&lt;TWEET_OFFSET+40; i++) {
if (msg[i] != 0) lcd.print(msg[i]);
else lcd.print(' ');
}
// print also to serial monitor;
char buffer_row[20];
strncpy( buffer_row, msg+TWEET_OFFSET, 20); buffer_row[20] = '\0';
Serial.println(buffer_row);
strncpy( buffer_row, msg+TWEET_OFFSET+20, 20); buffer_row[20] = '\0';
Serial.println(buffer_row);
}

void check_for_new_temperature() {
// responsible with 3rd and 4th rows of the 4x20 LCD;
// connect to www.weather.gov and get temperature for Fargo airport;
if ( client_weather.connect()) {
client_weather.println("GET /xml/current_obs/KFAR.xml HTTP/1.0");
client_weather.println();
} else {
lcd.setCursor(0,2); lcd.print( "Weather connection ");
lcd.setCursor(0,3); lcd.print( "failed! ");
Serial.println("Weather connection failed.");
}
if ( client_weather.connected()) {
if ( (finder_weather.getString("&lt;temp_f>","&lt;/temp_f>",temperature,8)!=0) ) {
lcd.setCursor(0,2);
lcd.print("Curr temp: "); lcd.print(temperature); lcd.print(" F");
lcd.setCursor(0,3); lcd.print("Cris ");
// print also to serial monitor
Serial.println("Curr temp: "); Serial.println(temperature); Serial.println(" F");
Serial.println("Cris ");
} else {
lcd.setCursor(0,2); lcd.print("Current temp: NA");
lcd.setCursor(0,3); lcd.print("Cris ");
Serial.println("Couldn't find temp_f in weather stream");
}
} else {
lcd.setCursor(0,2); lcd.print("Current temp: NA");
lcd.setCursor(0,3); lcd.print("Cris ");
Serial.println("Disconnected from weather");
}
}

---

**Twitter를 통한 사무실 문 알림 시스템 소개**

![Use Twitter and Weather to Post Notes and Temperature to Office Door](https://content.instructables.com/F60/ULF7/GPAS2II9/F60ULF7GPAS2II9.jpg?auto=webp&frame=1&fit=bounds&md=c03dc7e9a0cd8a6d29fc2cd9cbd5139b)

이 프로젝트는 Twitter 계정을 사용하여 사무실 문에 장착된 20x4 LCD 화면에 메모를 전송하는 아이디어를 구현합니다. 해당 아이디어는 IEEE Spectrum 기사에서 소개되었습니다. 추가적으로, 특정 지역의 현재 기온도 함께 표시됩니다.

![Use Twitter and Weather to Post Notes and Temperature to Office Door](https://content.instructables.com/FN1/VE5X/GPAS2IID/FN1VE5XGPAS2IID.jpg?auto=webp&frame=1&width=400&fit=bounds&md=487e21ff89482dc808da919a36e986cb)

이 구현은 Arduino Uno 보드와 Arduino Ethernet Shield의 조합을 기반으로 하며, 프로젝트의 총 비용은 약 $120입니다. Arduino 도구에 익숙해야 합니다.

![Use Twitter and Weather to Post Notes and Temperature to Office Door](https://content.instructables.com/FM4/QQLR/GPAS2II3/FM4QQLRGPAS2II3.jpg?auto=webp&frame=1&width=400&fit=bounds&md=d0a1e8887ea47d20ebeea6fa0def44d1)

**하드웨어 및 소프트웨어 정보:**

- 하드웨어에는 Arduino Ethernet Shield, Arduino Uno, 20x4 LCD 화면, 프로젝트 박스, USB 케이블, 9 핀 케이블 등이 포함됩니다.

- 소프트웨어에는 Arduino 스케치 및 여러 Arduino 라이브러리가 필요합니다.

이 시스템은 사용자의 Twitter 계정에서 "BZD"로 시작하는 트윗만을 선택하여 LCD에 표시합니다. 예를 들어, 사무실의 근무 시간이나 커피 시간 등의 알림을 트윗으로 게시할 수 있습니다.

아래는 저자가 공개한 코드입니다.

// Get "selected" latest tweet from Twitter account "BZDoor" and display it on the
// LCD display, which I have fixed on my office door. By selected I mean tweets that
// start with the key "BZD" only. I use the Twitter account to post notes on my
// office door about office hours, being out for coffee, etc. :-)
//
// The circuit:
// LCD pins 1,3,5,16 to Arduino digital pin GND
// LCD pin 2 to Arduino digital pin +5V
// LCD pin 15 via Resitor 330 Ohms to Arduino digital pin +5V
// LCD pin 14 to Arduino digital pin 2
// LCD pin 13 to Arduino digital pin 3
// LCD pin 12 to Arduino digital pin 4
// LCD pin 11 to Arduino digital pin 5
// LCD pin 4 to Arduino digital pin 9
// LCD pin 6 to Arduino digital pin 8

#include &lt;SPI.h>
#include &lt;Ethernet.h>
#include &lt;EthernetDHCP.h>
#include &lt;TextFinder.h>
#include &lt;LiquidCrystal.h>

LiquidCrystal lcd(9, 8, 5, 4, 3, 2);

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x4F, 0x8A };
byte ip[] = { 192,168,1,177 };
byte server[] = { 199,59,148,10 }; // twitter.com
byte server_weather[] = { 140,90,113,200 }; // weather.gov

#define NUM_CHAR_USERNAME 7 // "BZDoor:" is username with 6 characters + :
#define TWEET_OFFSET NUM_CHAR_USERNAME + 5 // useful info from tweet to be displayed appears after "BZDoor: BZD "
char tweet[NUM_CHAR_USERNAME + 140]; // 147 = "BZDoor:" + 140 for actual tweet
char old_tweet[] = { "BZDoor: BZD No updates. Have a nice day! Current temp: NA Cris " };
char temperature[8];

Client client(server, 80);
TextFinder finder(client);
Client client_weather(server_weather, 80);
TextFinder finder_weather(client_weather);

void setup()
{
lcd.begin(4,20);
lcd.clear();
lcd.print("BZDoor2LCD");
Serial.begin(9600);
Serial.println("BZDoor2LCD");
Ethernet.begin(mac, ip);
}

void loop()
{
// (1) check if new tweet is present in BZDoor account;
check_for_new_valid_tweet();
// (2) check for temperature; also display signature;
check_for_new_temperature();
// (3) clean up;
client.stop();
client.flush();
client_weather.stop();
client_weather.flush();
// (4) also clear the "tweet" storage array; otherwise if latest tweet is shorter
// than the previous one, remnants from the previous will become part of the latest;
for ( int i=0; i&lt;NUM_CHAR_USERNAME+140; i++) tweet[i] = ' ';
// (5) delay 2 minutes before next update;
delay(120000);
}

void check_for_new_valid_tweet() {
// responsible with 1st and 2nd rows of the 4x20 LCD;
// connect to Twitter (RSS of user BZDoor: 316663659) and get the latest tweet;
// this check will be done every other 2 minutes, so if more tweets have been posted
// have been posted within these 2 minutes only the latest tweet will be processed;
if ( client.connect()) {
client.println("GET http://www.twitter.com/statuses/user_timeline/316663659.rss HTTP/1.0"); // BZDoor;
client.println();
} else {
lcd.setCursor(0,0); lcd.print( "Twitter connection ");
lcd.setCursor(0,1); lcd.print( "failed! ");
Serial.println("Twitter connection failed.");
}
if ( client.connected()) {
// get the last tweet in BZDoor's account by simply parsing the item and title tags;
if ( (finder.find("&lt;item>") && (finder.getString("&lt;title>","&lt;/title>",tweet,140)!=0)) ) {
// only tweets that start with the three characters "BZD" will be displayed
// on the LCD display on the office door; all others will be printed only to
// the Arduino's serial monitor
Serial.println(tweet);
// a regular tweet in BZDoor's account is always in one of two formats:
// 1) "BZDoor: This is a Hello World! tweet!", which is not displayed on LCD;
// 2) "BZDoor: BZD Some update", which is displayed on LCD because starts with key BZD;
if ( tweet[8] == 'B' && tweet[9] == 'Z' && tweet[10] == 'D') {
// this is a tweet that has an update from BZDoor to be displayed on the office door;
display_tweet(tweet);
// also copy this latest twit to old_tweet array;
strncpy(old_tweet, tweet, 80+TWEET_OFFSET);
} else {
display_tweet(old_tweet); // first time this says no new updates;
}
} else {
lcd.setCursor(0,0); lcd.print( "Could not find item ");
lcd.setCursor(0,1); lcd.print( "field in last twit ");
Serial.println("Could not find item field in last twit");
}
} else {
lcd.setCursor(0,0); lcd.print( "Disconnected from ");
lcd.setCursor(0,1); lcd.print( "twitter ");
Serial.println("Disconnected from twitter");
}
}

void display_tweet( char msg[]) {
// display only 40 characters on the first two rows of the
// 20x4 LCD display; the third and fourth rows are used for
// temperature and signature display;
lcd.clear();
// display tweet's first 40 chars;
lcd.setCursor(0,0);
for ( int i=TWEET_OFFSET; i&lt;TWEET_OFFSET+20; i++) {
if (msg[i] != 0) lcd.print(msg[i]);
else lcd.print(' ');
}
lcd.setCursor(0,1);
for ( int i=TWEET_OFFSET+20; i&lt;TWEET_OFFSET+40; i++) {
if (msg[i] != 0) lcd.print(msg[i]);
else lcd.print(' ');
}
// print also to serial monitor;
char buffer_row[20];
strncpy( buffer_row, msg+TWEET_OFFSET, 20); buffer_row[20] = '\0';
Serial.println(buffer_row);
strncpy( buffer_row, msg+TWEET_OFFSET+20, 20); buffer_row[20] = '\0';
Serial.println(buffer_row);
}

void check_for_new_temperature() {
// responsible with 3rd and 4th rows of the 4x20 LCD;
// connect to www.weather.gov and get temperature for Fargo airport;
if ( client_weather.connect()) {
client_weather.println("GET /xml/current_obs/KFAR.xml HTTP/1.0");
client_weather.println();
} else {
lcd.setCursor(0,2); lcd.print( "Weather connection ");
lcd.setCursor(0,3); lcd.print( "failed! ");
Serial.println("Weather connection failed.");
}
if ( client_weather.connected()) {
if ( (finder_weather.getString("&lt;temp_f>","&lt;/temp_f>",temperature,8)!=0) ) {
lcd.setCursor(0,2);
lcd.print("Curr temp: "); lcd.print(temperature); lcd.print(" F");
lcd.setCursor(0,3); lcd.print("Cris ");
// print also to serial monitor
Serial.println("Curr temp: "); Serial.println(temperature); Serial.println(" F");
Serial.println("Cris ");
} else {
lcd.setCursor(0,2); lcd.print("Current temp: NA");
lcd.setCursor(0,3); lcd.print("Cris ");
Serial.println("Couldn't find temp_f in weather stream");
}
} else {
lcd.setCursor(0,2); lcd.print("Current temp: NA");
lcd.setCursor(0,3); lcd.print("Cris ");
Serial.println("Disconnected from weather");
}
}

---

Source: https://maker.wiznet.io/jaden/projects/use-twitter-and-weather-to-post-notes-and-temperature-to-office-door-re/
