---
title: "Alarming Tweet"
url: "https://maker.wiznet.io/nagamma06/projects/alarming-tweet/"
markdown_url: "https://maker.wiznet.io/nagamma06/projects/alarming-tweet/md"
type: "UCC: User Created Content"
author: "willnue"
author_url: "https://www.instructables.com/AlarmingTweet/"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "willnue"
original_url: "https://www.instructables.com/AlarmingTweet/"
published: "2022-11-29"
language: "en"
hardware: ["Arduino UNO", "Arduino Ethernet Shield", "Adafruit 9V regulated DC wall-power adapter", "SparkFun Arduino Project Enclosure", "GE 45142 Choice-Alert Wireless Control Center with Door or Window Sensor Kit"]
likes: 2
views: 623
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Alarming Tweet

> This project will add tweeting capabilities to the GE 45142 Choice-Alert Wireless Control Center Alarm system.

Original author: willnue (source: https://www.instructables.com/AlarmingTweet/)

## Components

- **Arduino UNO** x 1 ([docs](https://www.farnell.com/datasheets/1682209.pdf))
- **Arduino Ethernet Shield** x 1 ([docs](https://docs.arduino.cc/retired/shields/arduino-ethernet-shield-without-poe-module))
- **Adafruit 9V regulated DC wall-power adapter** x 1 ([docs](https://www.adafruit.com/product/63))
- **SparkFun Arduino Project Enclosure** x 1 ([docs](https://www.sparkfun.com/products/retired/10088))
- **GE 45142 Choice-Alert Wireless Control Center with Door or Window Sensor Kit** x 1

## Article

### **Background:**

This project will add tweeting capabilities to the GE 45142 Choice-Alert Wireless Control Center Alarm system. The alarm system allows you to connect up to 16 different sensors across 4 zones and with the addition of the Arduino powered AlarmingTweet you can enable it to keep you informed of it's status anytime anywhere.

### **Components:**

- 1 x[GE 45142 Choice-Alert Wireless Control Center with Door or Window Sensor Kit](http://www.amazon.com/gp/product/B0013V1T2I) from Amazon, Lowes or Home Depot ($30 -$40) - Comes with a single magnetic sensor for doors/windows many other sensors can be added ($15-$25 each)

- 1 x [Arduino UNO](http://www.adafruit.com/products/325) from Adafruit ($30)

- 1 x [Arduino Ethernet](http://www.adafruit.com/products/201) Shield from Adafruit ($45)

- 1 x [9V regulated DC wall-power adapter](http://www.adafruit.com/products/63) from Adafruit ($7)

- 1 x [Arduino Project Enclosure](http://www.sparkfun.com/products/10088) from Sparkfun ($12)

- 1 x [Right Angle Male Header strip](http://www.sparkfun.com/products/553) from Sparkfun ($2)

- Length of Cat 5 cable

- Heat shrink tubing

## **Step 1: Open the Control Center Case** ![](https://content.instructables.com/FQW/88E3/GPBDFPRF/FQW88E3GPBDFPRF.jpg?auto=webp&frame=1&fit=bounds&md=fb54a4964a4c712366b15e4187150be7) ![](https://content.instructables.com/F7Y/HNAV/GPBD39FD/F7YHNAVGPBD39FD.jpg?auto=webp&frame=1&fit=bounds&md=1ea152448adbc046b539d4f70b077930) ![](https://content.instructables.com/FQS/YWQE/GPAS2N3I/FQSYWQEGPAS2N3I.jpg?auto=webp&frame=1&fit=bounds&md=15f36eb8a2f3f46d9853270ba3c225b2) ![](https://content.instructables.com/FMJ/LXJP/GP7IFFDD/FMJLXJPGP7IFFDD.jpg?auto=webp&frame=1&fit=bounds&md=15f36eb8a2f3f46d9853270ba3c225b2) ![](https://maker.wiznet.io/upload/ckeditor5/740233503%5F1669731965%2Epng) Remove the 4 screws holding the Control Center case together then remove the 2 screws holding the circuit board onto the case. Be careful not to pull of the antenna or speaker wires. We are interested in the LED leads protruding from the bottom of the circuit board.

## **Step 2: Prepare the Control Center ** ![](https://content.instructables.com/FIA/N3EB/GP7IFFDE/FIAN3EBGP7IFFDE.jpg?auto=webp&frame=1&fit=bounds&md=15f36eb8a2f3f46d9853270ba3c225b2) ![](https://content.instructables.com/FQ7/TSYG/GPBD39G3/FQ7TSYGGPBD39G3.jpg?auto=webp&frame=1&fit=bounds&md=01fce8934eb90fa7691a10dfd193551b) ![](https://content.instructables.com/FBA/4IEW/GP7IFFDF/FBA4IEWGP7IFFDF.jpg?auto=webp&frame=1&fit=bounds&md=41b8b1240aaa5e958466da372804cf86) ![](https://content.instructables.com/F5K/DCBH/GPAS2N3J/F5KDCBHGPAS2N3J.jpg?auto=webp&frame=1&fit=bounds&md=1ea152448adbc046b539d4f70b077930) ![](https://maker.wiznet.io/upload/ckeditor5/740233503%5F1669732359%2Epng) ![](https://content.instructables.com/FR4/00CK/GPBD39H6/FR400CKGPBD39H6.jpg?auto=webp&frame=1&fit=bounds&md=32eaafd7aba9d9a4abe673a550965081) ![](https://content.instructables.com/F8J/CMBU/GPBDFPRU/F8JCMBUGPBDFPRU.jpg?auto=webp&frame=1&fit=bounds&md=160f8e1ae0d89110e0a737be7fad9845) **Step 3: Connect the Arduino** ![](https://content.instructables.com/FZF/JXKP/GPBD39HW/FZFJXKPGPBD39HW.jpg?auto=webp&frame=1&fit=bounds&md=32eaafd7aba9d9a4abe673a550965081) ![](https://maker.wiznet.io/upload/ckeditor5/740233503%5F1669734320%2Epng) ![](https://maker.wiznet.io/upload/ckeditor5/740233503%5F1669734401%2Epng) ![](https://content.instructables.com/FL4/E4TR/GPAS2N3M/FL4E4TRGPAS2N3M.jpg?auto=webp&frame=1&fit=bounds&md=160f8e1ae0d89110e0a737be7fad9845) ![](https://content.instructables.com/FZ4/X489/GPBD39JG/FZ4X489GPBD39JG.jpg?auto=webp&frame=1&fit=bounds&md=32eaafd7aba9d9a4abe673a550965081) ![](https://content.instructables.com/FXJ/JMCS/GPBDFQAD/FXJJMCSGPBDFQAD.jpg?auto=webp&frame=1&fit=bounds&md=742b4610296d7517e6d89525dc89c682) ![](https://maker.wiznet.io/upload/ckeditor5/740233503%5F1669734567%2Epng) ![](https://maker.wiznet.io/upload/ckeditor5/740233503%5F1669734602%2Epng) ![](https://content.instructables.com/F56/SO7A/GPBD39KJ/F56SO7AGPBD39KJ.jpg?auto=webp&frame=1&fit=bounds&md=064299ccc09fc7533e24b29062599e68) ![](https://content.instructables.com/FTR/BOU5/GPBD39L3/FTRBOU5GPBD39L3.jpg?auto=webp&frame=1&fit=bounds&md=017a737eac2836f4ddc3bfc4081f3545) **Step 4: Close Up the Cases  **![](https://content.instructables.com/F31/MPMF/GPBD39LP/F31MPMFGPBD39LP.jpg?auto=webp&frame=1&fit=bounds&md=017a737eac2836f4ddc3bfc4081f3545) ![](https://content.instructables.com/F1B/B5W6/GPBD39MC/F1BB5W6GPBD39MC.jpg?auto=webp&frame=1&fit=bounds&md=017a737eac2836f4ddc3bfc4081f3545) ![](https://content.instructables.com/F5G/8KCJ/GPBD39MZ/F5G8KCJGPBD39MZ.jpg?auto=webp&frame=1&fit=bounds&md=a12ed3a2e00e22b883b60b6485ece37b) ![](https://content.instructables.com/FT4/9JU9/GPBD39NN/FT49JU9GPBD39NN.jpg?auto=webp&frame=1&fit=bounds&md=a12ed3a2e00e22b883b60b6485ece37b) ![](https://content.instructables.com/FUF/86QZ/GPBD39OC/FUF86QZGPBD39OC.jpg?auto=webp&frame=1&fit=bounds&md=3d071020cab3462d2015de37249729f1) **Step 5: Configure ThingTweet ** For my project I chose to use ThingTweet from ThingSpeak as the proxy between my Arduino and Twitter, mostly because I already had a ThingSpeak account and enjoy the service. Getting the Arduino to send it's first tweet took me only a few minutes to implement with ThingTweet. To get set up yourself check out the great [Update Twitter with ThingTweet and Arduino + Ethernet Shield](http://community.thingspeak.com/tutorials/arduino/update-twitter-with-thingtweet-and-arduino-ethernet-shield/) tutorial the ThingSpeak team created, which also includes a sample Arduino sketch.

## **Step 6: Upload the Arduino Code**

Edit the the following sketch being sure to update it for your network settings as well as your ThingTweet API key. See the comments inline to get a better understand about what it going on.

```c
###### Start Sketch ######

// AlarmingTweet by willnue - www.nuewire.com
// Adds tweet capabilties to the GE 45142 Choice-Alert Wireless Control Center
// Requires Ethernet Shield for sending tweets

//ThingTweet code details
//-----------------------
/*
ThingTweet App to Update a Twitter Status

The ThingTweet sketch is designed for the Arduino + Ethernet Shield.
This sketch updates a Twitter status via the ThingTweet App
(http://community.thingspeak.com/documentation/apps/thingtweet/) using HTTP POST.
ThingTweet is a Twitter proxy web application that handles the OAuth.

Getting Started with ThingSpeak and ThingTweet:

* Sign Up for a New User Account for ThingSpeak - https://www.thingspeak.com/users/new
* Link your Twitter account to the ThingTweet App - Apps / ThingTweet
* Enter the ThingTweet API Key in this sketch under "ThingSpeak Settings"

Created: March 7, 2011 by Hans Scharler (http://www.iamshadowlord.com)
*/

//Libraries
//------------------------
#include <SPI.h>
#include <Ethernet.h>

//Ethernet shield Settings
//------------------------
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xB2, 0xAD, 0xEF, 0xEF }; // Must be unique on local network
byte ip[] = { 192, 168, 1, 5 }; // Must be unique on local network
byte gateway[] = { 192, 168, 1, 1 };
byte subnet[] = { 255, 255, 255, 0 };

//Define pins used
//-----------------------
#define pinPwr 5 //Analog pin for Power LED on control center
#define pinArm 4 //Analog pin for Armed LED on control center
#define pinZn1 0 //Analog pin for Zone 1 LED on control center
#define pinZn2 1 //Analog pin for Zone 2 LED on control center
#define pinZn3 2 //Analog pin for Zone 3 LED on control center
#define pinZn4 3 //Analog pin for Zone 4 LED on control center


//Global variables
//-----------------------
boolean prevPwr = false; // Last state of LED (ON = true, OFF = false)
boolean prevArm = false; // Last state of LED (ON = true, OFF = false)
boolean prevZn1 = false; // Last state of LED (ON = true, OFF = false)
boolean prevZn2 = false; // Last state of LED (ON = true, OFF = false)
boolean prevZn3 = false; // Last state of LED (ON = true, OFF = false)
boolean prevZn4 = false; // Last state of LED (ON = true, OFF = false)

String ledReport = ""; // string for storing LED status message
boolean pinAlerts[] = {false, false, false, false, false, false}; //Alert Status of pins
int i=0; //Counter

//Twitter options
//-----------------------
unsigned long tweetInterval = 300000; //Minimum to wait between sending tweets (in milliseconds) - 60000 per minute
unsigned long LastTweet = 0; //Variable to hold last tweet time (in milliseconds)
boolean sendTweet = true; //Flag for sending tweet
String tweetText = ""; //string for storing tweet


// ThingSpeak Settings
//-----------------------
byte server[] = { 184, 106, 153, 149 }; // IP Address for the ThingSpeak API
String thingtweetAPIKey = "YOUR API KEY HERE"; // Write API Key for a ThingSpeak Channel
Client client(server, 80);
long lastConnectionTime = 0;
boolean lastConnected = false;
int resetCounter = 0;

//Debug options
//-----------------------
boolean debugMode = true; //Enable to debug readings to serial console


void setup() {

Ethernet.begin(mac, ip, gateway, subnet); //Start up the Ethernet shield
delay(1000);

// Update Twitter via ThingTweet
if(!client.connected())
{
updateTwitterStatus("AlarmingTweet Started up!");
}

if (debugMode == true) {
Serial.begin (9600); //Open the serial port for debug output
tweetInterval = 60000; //Overide the tweet interval for testing
}
}


void loop() {

if (sendTweet == true){
if (millis() >= (LastTweet + tweetInterval)){ //Check to see if enough time has passed to send again

tweetText = "AlarmingTweet ALERT : ";
if (pinAlerts[0] == true){
tweetText += "Zone 1 / ";}
if (pinAlerts[1] == true){
tweetText += "Zone 2 / ";}
if (pinAlerts[2] == true){
tweetText += "Zone 3 / ";}
if (pinAlerts[3] == true){
tweetText += "Zone 4 / ";}
if (pinAlerts[4] == true){
tweetText += "ARM State / ";}
if (pinAlerts[5] == true){
tweetText += "ALARM State / ";}

// Update Twitter via ThingTweet
if(!client.connected())
{
updateTwitterStatus(tweetText);
if (debugMode == true) { // Print values out to the console
Serial.print("Tweeting : ");
Serial.println(tweetText);
Serial.println();
}
}

// Disconnect from ThingSpeak
if (!client.connected() && lastConnected)
{
if (debugMode == true) { // Print values out to the console
Serial.println();
Serial.println("...disconnected.");
Serial.println();
}
client.stop();
}

lastConnected = client.connected();

LastTweet = millis(); //Reset the time of the last tweet
for( i = 0; i < 6; i++) { //Clear the alert flags
pinAlerts[i] = false;
}
}
}

sendTweet = false; //Reset Tweet flag before checking LEDs

prevPwr = checkLED(pinPwr, prevPwr); //Check LED status
prevArm = checkLED(pinArm, prevArm); //Check LED status
prevZn1 = checkLED(pinZn1, prevZn1); //Check LED status
prevZn2 = checkLED(pinZn2, prevZn2); //Check LED status
prevZn3 = checkLED(pinZn3, prevZn3); //Check LED status
prevZn4 = checkLED(pinZn4, prevZn4); //Check LED status

// Print Update Response to Serial Monitor
if (client.available())
{
char c = client.read();
Serial.print(c);
}


delay(500); // General delay between loops
}


boolean checkLED(int ledPin, boolean prevVal){
boolean curVal = false; // Current state of LED (ON = true, OFF = false)
int ledReading = 1023; // variable to store reading from LED (set to 5v/1023 by default)

ledReading = analogRead(ledPin); // read the value of the LED
delay(10); // delay 10ms to let the ADC recover

if (ledReading < 100){ //Check the LED to see if it is ON (reading < 0.5v)
curVal = true;
}

if (prevVal != curVal){ //Check to see if the value changed from the previous reading
sendTweet = true; //Set the flag to send a tweet
pinAlerts[ledPin] = true; //Flag an Alert for this pin
}

if (debugMode == true) { // Print values out to the console
Serial.print("Pin ");
Serial.print(ledPin);
Serial.print(" : ");
Serial.print(ledReading);
Serial.print(", ");
if (prevVal == true)
Serial.print("ON");
else
Serial.print("OFF");
Serial.print("/");
if (curVal == true)
Serial.print("ON");
else
Serial.print("OFF");
Serial.print(", ");
if (sendTweet == true)
Serial.print("TWEET");
else
Serial.print("-----");
Serial.println();

Serial.print("Alerts : ");
for( i = 0; i < 6; i++) {
if (pinAlerts[i] == true)
Serial.print("Y");
else
Serial.print("N");
Serial.print(", ");
}
Serial.println();

//Un-comment below to check each LED individually
//sendTweet = false; //Reset Tweet flag individually for testing
}

return curVal; //Return the current reading
}

void updateTwitterStatus(String tsData)
{
if (client.connect() && tsData.length() > 0)
{
// Create HTTP POST Data
tsData = "api_key="+thingtweetAPIKey+"&status="+tsData;

if (debugMode == true) { // Print values out to the console
Serial.println("Connected to ThingTweet...");
Serial.println();
}

client.print("POST /apps/thingtweet/1/statuses/update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(tsData.length());
client.print("\n\n");

client.print(tsData);
}
else
{
if (debugMode == true) { // Print values out to the console
Serial.println("Connection Failed.");
Serial.println();
}
}
}

###### End Sketch ######
```

---

Source: https://maker.wiznet.io/nagamma06/projects/alarming-tweet/
