Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

ThingSpeak Twitter - Revisited, Cleaned up.


  • Please log in to reply
17 replies to this topic

#1 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 16 April 2011 - 05:38 PM

Here is a post on my blog: http://oz.heliohost....ith-thingspeak/ I plan to make a nice video of it sometime soon, I'll post it here when I do. I like ThingSpeak a lot so I think that I will be making more projects that use this service. If you guys have any requests feel free to ask via reply, and I'll see what I can do. *Updated and cleaned up the code. Please test and let me know if you encounter any bugs.

#2 Terry Massey

Terry Massey

    Advanced Member

  • Members
  • PipPipPip
  • 77 posts
  • LocationPekin, IL

Posted 16 April 2011 - 09:27 PM

very cool....
Thanks,
Terry Massey

#3 nrc

nrc

    Member

  • Members
  • PipPip
  • 11 posts

Posted 17 April 2011 - 07:57 AM

Hi Omar, thank you to share. How can I create a chanel? I din't found.

#4 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 17 April 2011 - 08:05 AM

Hi Omar, thank you to share. How can I create a chanel? I din't found.


Hey nrc,
I will make a few videos to help people out. For now I'll do my best in describing.

1 Log in (https://www.thingspeak.com/login) and click on the 'Channels' link at the top
2 Click the 'Create new Channel' button
3 Fill out the information you wish to enter (lat and log are optional)
4 When done click on the 'Edit Channel' button, that will save it
// done making a channel... to use it do this:
5 Go back to the channels page, select your channel
6 Select your 'Write API Key' and use that to as the 'APIKey' for the class I made.
7. If you wish to send data to field# do this: blah.SendValue(#, "value");

Hope that helps.

#5 tapius

tapius

    Member

  • Members
  • PipPip
  • 11 posts

Posted 10 May 2011 - 03:13 AM

having trouble with sending the twitter message, public static void Main() { InputPort button = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled); TS = new Thingspeak("API KEY","API KEY"); bool buttonState = false; while (true) { if (!buttonState) { Thread.Sleep(1000); TS.SendTweet("Button Pushed! Muhaha I Tweet."); } } } Causes this exception: Thread.Sleep(Timeout.Infinite); #### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) #### #### Message: #### Microsoft.SPOT.Net.SocketNative::connect [IP: 0000] #### #### System.Net.Sockets.Socket::Connect [IP: 001d] #### #### EasyTweet.Thingspeak::ConnectSocket [IP: 001b] #### #### EasyTweet.Thingspeak::sendPOST [IP: 0007] #### #### EasyTweet.Thingspeak::SendTweet [IP: 0083] #### #### EasyTweet.Program::Main [IP: 0032] #### #### SocketException ErrorCode = 10053 #### SocketException ErrorCode = 10053 A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll #### SocketException ErrorCode = 10053 #### SocketException ErrorCode = 10053 Connection Failed. Socket Error Code: 10053 System.Net.Sockets.SocketException Maybe im doing something wrong? This is my first time using the ethernet on my netduino, just got it today. :)

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 10 May 2011 - 05:44 AM

Hi tapius,

Maybe im doing something wrong? This is my first time using the ethernet on my netduino, just got it today. :)

Does your Netduino Plus have an IP address, etc.? You may want to try the SocketClient sample from the .NET MF SDK first...to make sure you're connected correctly.

If DHCP gives you any issues, static IP is a good fallback position.

Chris

#7 tapius

tapius

    Member

  • Members
  • PipPip
  • 11 posts

Posted 10 May 2011 - 11:39 PM

Hi tapius,


Does your Netduino Plus have an IP address, etc.? You may want to try the SocketClient sample from the .NET MF SDK first...to make sure you're connected correctly.

If DHCP gives you any issues, static IP is a good fallback position.

Chris


I removed the DHCP setting, the default ip is set to 192.168.5.100
When I try to ping it, i get no response,
I tried to run the SocketClient from the MF SDK and I got:

The thread '<No Name>' (0x2) has exited with code 0 (0x0).
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::getaddrinfo [IP: 0000] ####
#### System.Net.Dns::GetHostEntry [IP: 0008] ####
#### SocketClientSample.MySocketClient::ConnectSocket [IP: 0005] ####
#### SocketClientSample.MySocketClient::GetWebPage [IP: 0017] ####
#### SocketClientSample.MySocketClient::Main [IP: 0011] ####
#### SocketException ErrorCode = 11001
#### SocketException ErrorCode = 11001
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 11001
#### SocketException ErrorCode = 11001
SocketException when connecting to http://www.msn.com/default.aspx.
If your network uses IPSec, you may need enable the port manually
Socket Error Code: 11001
System.Net.Sockets.SocketException

Any Ideas?

#8 tapius

tapius

    Member

  • Members
  • PipPip
  • 11 posts

Posted 11 May 2011 - 12:16 AM

I got it working, I provided the DNS Address and Default Gateway, and its working now. Yay! Now my new issue: Connected to ThingSpeak... HTTP/1.1 400 Bad Request Server: nginx/0.8.53 Date: Wed, 11 May 2011 00:13:30 GMT Content-Type: text/html; charset=utf-8 Transfer-Encoding: chunked Connection: close Status: 400 Cache-Control: no-cache f Invalid API Key 0 I c/p both keys from respective sites and now it says they are invalid, why?

#9 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 11 May 2011 - 02:14 PM

I got it working, I provided the DNS Address and Default Gateway, and its working now. Yay!
Now my new issue:

Connected to ThingSpeak...

HTTP/1.1 400 Bad Request
Server: nginx/0.8.53
Date: Wed, 11 May 2011 00:13:30 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Status: 400
Cache-Control: no-cache

f
Invalid API Key
0

I c/p both keys from respective sites and now it says they are invalid, why?


I can take a look at it... I suggest you change your api key for twitter and also remove it from the thread here to prevent a bot or someone from tweeting in your name. I think I am going to update the code this weekend, I've found improvements i can make. So I will try to get the same error as you and see if I can help.

#10 tapius

tapius

    Member

  • Members
  • PipPip
  • 11 posts

Posted 14 May 2011 - 01:09 AM

I can take a look at it... I suggest you change your api key for twitter and also remove it from the thread here to prevent a bot or someone from tweeting in your name. I think I am going to update the code this weekend, I've found improvements i can make. So I will try to get the same error as you and see if I can help.


Yeah, good point, Thanks. I think i'll probably still use the same keys anyway.. tltr; (too lazy to (re)register)

#11 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 14 May 2011 - 07:44 PM

Yeah, good point, Thanks. I think i'll probably still use the same keys anyway.. tltr; (too lazy to (re)register)


Well I hope you aren't too lazy to press a button ;) :
Attached File  newkey.PNG   10.61KB   16 downloads

#12 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 15 May 2011 - 10:13 PM

I c/p both keys from respective sites and now it says they are invalid, why?


Alright I dont know what caused your issue, but I updated the code... Test it out and if it doesnt work we'll go from there. If you go to my twitter you'll see my tweet that I sent a little ago using the new code. Here is my output...

EDIT: It seems your API key was wrong somehow. I made a public netduino twitter bot:

http://twitter.com/#!/NetTweetBot
This is the API I set up for it: E3MXW8V95ZEO6QTQ

Try: new Thingspeak("", "E3MXW8V95ZEO6QTQ");
Leave the channel key as "" if you will only send tweets.

Using:
TS.SendTweet("Updated @netduino @ThingSpeak twitter class. 'tis a bit cleaner, hope it works for you! [Sent from N+]");

HTTP/1.1 200 OK
Server: nginx/0.8.53
Date: Sun, 15 May 2011 22:12:55 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
Status: 200
ETag: "c4ca4238a0b923820dcc509a6f75849b"
Cache-Control: max-age=0, private, must-revalidate

1
1
0


...disconnected.



#13 tapius

tapius

    Member

  • Members
  • PipPip
  • 11 posts

Posted 16 May 2011 - 06:50 PM

Alright I dont know what caused your issue, but I updated the code... Test it out and if it doesnt work we'll go from there. If you go to my twitter you'll see my tweet that I sent a little ago using the new code. Here is my output...

EDIT: It seems your API key was wrong somehow.



Awesome, I will check it out again tonight, thanks for the help :)

#14 ThingSpeak

ThingSpeak

    Member

  • Members
  • PipPip
  • 13 posts

Posted 18 May 2011 - 03:04 AM

@OZ Where do you have to updated code? I will add a link on the tutorials page.

#15 tapius

tapius

    Member

  • Members
  • PipPip
  • 11 posts

Posted 18 May 2011 - 07:00 PM

FYI - i got it to work, i did something silly probably from not reading things through, the reason the API key didn't work was because it was directly a Twitter API key, not one generated via ThingSpeak. Once I generated a thingspeak(twitter) api key it worked flawlessly :)

#16 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 18 May 2011 - 08:43 PM

@OZ Where do you have to updated code? I will add a link on the tutorials page.


Ah.. I forgot to fix link, sorry about that. here it is: http://oz.heliohost....ith-thingspeak/

Thanks for linking!

#17 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 18 May 2011 - 08:45 PM

FYI - i got it to work, i did something silly probably from not reading things through, the reason the API key didn't work was because it was directly a Twitter API key, not one generated via ThingSpeak. Once I generated a thingspeak(twitter) api key it worked flawlessly :)


Good to hear! You can get the new code here: http://oz.heliohost....ith-thingspeak/ (i forgot to fix the link up there...) and that might be smaller than my old code, by a byte or two ;) . Have fun

#18 Mark Anderson

Mark Anderson

    Member

  • Members
  • PipPip
  • 25 posts
  • LocationChciago

Posted 02 January 2014 - 07:32 PM

Here is a post on my blog: http://oz.heliohost....ith-thingspeak/ I plan to make a nice video of it sometime soon, I'll post it here when I do. I like ThingSpeak a lot so I think that I will be making more projects that use this service. If you guys have any requests feel free to ask via reply, and I'll see what I can do. *Updated and cleaned up the code. Please test and let me know if you encounter any bugs.

Can't find on your site. is it still there?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.