Next, let's set up our Electric Imp to tweet its temperature! You'll need a Twitter account, so go ahead and create one of you haven't already. In order to tweet from our Imp's agent, we will need to access the Twitter Developer Center. https://dev.twitter.com/apps/new
Fill out the Name, Description, and Website information. Agree to the terms and conditions, and complete the Captcha. If all is well, Twitter will create an new application for you.
Fill out the Name, Description, and Website information. Agree to the terms and conditions, and complete the Captcha. If all is well, Twitter will create an new application for you.
Take a look at what is on the page. At the bottom, click "Create my Access Token". Twitter will create Access tokens for you.
I have found that I need to click the buttons to create Access Tokens, and to change the Application Type twice before it updates properly. Ensure that you have what you need before moving on.
The token created is read-only, and we need to give it write access. Click on the Settings tab at the top. Scroll down to Application Type, and check "Read and Write". Then click "Update this Twitter application's settings" at the bottom. Make sure it updates to "Read and Write".
Now go back to the Details tab. We need to update our Access Token. Click "Recreate my access token" at the bottom. Make sure it says "Read and Write" after you update it.
We now have all the information we need to tweet. From the Details tab in your Twitter application page, carefully copy the appropriate information into the variables near the bottom of your Agent code in the Electric Imp Web IDE. You'll need to fill out these variables:
_CONSUMER_KEY <- "YOUR KEY"
_CONSUMER_SECRET <- "YOUR SECRET"
_ACCESS_TOKEN <- "YOUR TOKEN"
_ACCESS_SECRET <- "YOUR SECRET"
Paste your information inside the quotes.
_CONSUMER_KEY <- "YOUR KEY"
_CONSUMER_SECRET <- "YOUR SECRET"
_ACCESS_TOKEN <- "YOUR TOKEN"
_ACCESS_SECRET <- "YOUR SECRET"
Paste your information inside the quotes.
Finally, uncomment this line near the end of the Agent code:
//twitter.update_status("The temperature is: " + v + "F.");
//twitter.update_status("The temperature is: " + v + "F.");
If you let this code run, your Imp will tweet every 10 seconds! To avoid spamming your Twitter followers and only execute once, comment out this line in the device code:
imp.wakeup(10, readChip189); //Wakeup every 10 second and read data.
Click "Build and Run" in the web IDE. Check the log, if you don't see any errors you have tweeted successfully. Check your Twitter account for the message.
If you do see error messages, check all of your keys and tokens for accuracy, and try again.
Congrats! Your Electric Imp can tweet! Don't forget to send a tweet to @adafruit and @electricimp!
Stay tuned for an upcoming tutorial on building a dual probe thermocouple temperature monitor with LCD readout using the Adafruit Arduino enclosure.
Click "Build and Run" in the web IDE. Check the log, if you don't see any errors you have tweeted successfully. Check your Twitter account for the message.
If you do see error messages, check all of your keys and tokens for accuracy, and try again.
Congrats! Your Electric Imp can tweet! Don't forget to send a tweet to @adafruit and @electricimp!
Stay tuned for an upcoming tutorial on building a dual probe thermocouple temperature monitor with LCD readout using the Adafruit Arduino enclosure.
Text editor powered by tinymce.