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

MQTT for the Netduino Plus


  • Please log in to reply
11 replies to this topic

#1 DanA

DanA

    Member

  • Members
  • PipPip
  • 26 posts

Posted 11 January 2012 - 05:30 AM

Hi,

I received a Netduino Plus for Christmas this year to keep my other Netduino company. After working my way through the "Internet of things" book from O'Reilly, I decided to write a Netduino MQTT client after hearing about MQTT a few weeks earlier.

MQTT is a light-weight protocol for machine to machine communications, or "Internet of things" communications. This seemed like a fun project with my goal being to monitor the temperature, of my desk... Which I sit at... But enough of that! - It's a Netduino with Ethernet! That is cool enough that it doesn't have to be useful yet. :)

I haven't got the temperature bit working (I bought a 1 wire sensor before I learned of the issues that choice brought with it - I'm waiting for an analog solution now :) ), but I have written an MQTT publisher/client that I thought I'd share with you. I've already learned so much from this forum (motor drivers, USB HID, shift registers, etc) that I hope that this might be useful to some of you in your future projects.

I have a page on my blog: http://diabolicalws....tduinomqtt.html

I have this hosted on Github here: https://github.com/d...an/NetduinoMQTT

MQTT operates in a publisher/subscriber model where you either post messages to a named topic or you can subscribe to a named topic. If you publish to that topic, all clients on that broker, who are subscribed to that topic - will get your message. At this point, I have only implemented the publish parts and the most basic QoS level.

If you download the code from GitHub, just add it to a Netduino Plus project, change the Program.cs as needed (IP address, login/passwd, etc), and deploy it, you can send MQTT messages to an MQTT broker (on button press for now).

This project was very fun - I found myself up at 4 in the morning on several occasions - awaiting "one more change". That hasn't happened for me in awhile, so it was quite fun.

Thanks
Dan

#2 NeonMika / Markus VV.

NeonMika / Markus VV.

    Advanced Member

  • Members
  • PipPipPip
  • 209 posts
  • LocationUpper Austria

Posted 11 January 2012 - 07:35 AM

But enough of that! - It's a Netduino with Ethernet! That is cool enough that it doesn't have to be useful yet. :)


It's 8 in the morning and I think your statement already was my daily highlight :D

NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and d
own - and upload files

 

If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype :)

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


#3 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 11 January 2012 - 08:01 AM

Hello Dan. Your implementation is a very great hit! I'm always interested in simple protocols for data exchange, and this looks interesting. I'll take some time to test, though. Thank you very much for sharing, and hoping to improve this lib sooner. Cheers
Biggest fault of Netduino? It runs by electricity.

#4 Spork

Spork

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts

Posted 12 January 2012 - 02:38 AM

I received a Netduino Plus for Christmas this year to keep my other Netduino company. After working my way through the "Internet of things" book from O'Reilly, I decided to write a Netduino MQTT client after hearing about MQTT a few weeks earlier.


Thanks for writing this, Dan. I've been curious to learn more about MQTT and this gives me something concrete to play with on my Netduino.

To date, I've been doing all my Netduino-->iPad/browser communication using HTTP and AJAX, but this is slightly awkward when it comes to event streams from the Netduino to the iPad. I've modified Netduino "http server" code to allow for preemptable HTTP "long polls", but it sounds like MQTT might be a more elegant way to handle the event oriented portion of the communication.

Hopefully there's a JavaScript implementation of subscriber-side MQTT.

#5 DanA

DanA

    Member

  • Members
  • PipPip
  • 26 posts

Posted 11 January 2012 - 07:59 AM

Hi,

Thank you. :)

I'm sure I'll be shaking bugs out of it for awhile (I had kind of an embarrassing one today - too much networking and too little bit counting these days). :)

I hope to have the subscribe part done here in a week or so - I think this will add some interesting options.

@Spork - There is a node.js (server-side JavaScript) broker and client listed here: http://mqtt.org/software I haven't used it, but it seems like you might be able to use something like this. Maybe via a free hosting service like Nodester?

If you want to play with this without setting up a broker - the author of the Mosquitto MQTT broker has recently set up a test broker @ http://test.mosquitto.org/

Thanks again!
Dan

#6 JR.NET

JR.NET

    Member

  • Members
  • PipPip
  • 15 posts

Posted 07 February 2013 - 09:56 PM

Hi DanA,

 

Thanks for your contribution. I am testing the MQTT protocol using my netduino 2 + and it seems to work :)

 

However, I would like to be able to access the payloadString (created in "public static int handlePUBLISH(Socket mySocket, byte firstByte)")?

 

The problem is that your classes/methods are declared are static. I would like to be able to access the  payloadString directly in the example program so I can parse/use it in my program.

 

What are your suggestions?

 

Thanks in advance,

 

JR



#7 Mike L

Mike L

    Advanced Member

  • Members
  • PipPipPip
  • 48 posts

Posted 01 March 2013 - 04:08 AM

I love using MQTT myself. I have my home automation system running on MQTT. It only consists of lawn irrigation and garage door controller right now. I also have a home security lab that connects 11 netduinos via MQTT. Take a look at http://cloudhomesecurity.com for details. You can find kinks to the code on the website. The mqtt library needs a lot of work though.



#8 mHammer

mHammer

    Member

  • Members
  • PipPip
  • 23 posts

Posted 08 March 2013 - 08:47 PM

Looking at the cloud home system, what would be the cheapest way to put together a swarm of devices?  I know arduino has some $20 mcu, but then you need another $20 for the ethernet.

 

ND+ are on sale for $50.

 

Is there another option that would have a mcu with ethernet?



#9 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 04 February 2014 - 10:01 AM

I love using MQTT myself. I have my home automation system running on MQTT. It only consists of lawn irrigation and garage door controller right now. I also have a home security lab that connects 11 netduinos via MQTT. Take a look at http://cloudhomesecurity.com for details. You can find kinks to the code on the website. The mqtt library needs a lot of work though.

 

Hi Mike,

 

I saw that you used a LAN cable to connect the netduino to MQTT broker(or maybe internet). Is it possible to use MQTT via GSM/GPRS shield? I dont have idea what MQTT exactly is? if I want to measure an environment in the remote site, which is no 3G connection. but I want to use M2M protocol, what I have to prepare to learn.?

 

Here is My desired topology:

 

Netduino+ --> GSM/GPRS shield .......?....... ----> GSM modem (wavecom etc) --->PC

 

 

can i comunicate between those GSM modem via MQTT? or M2M? is there any special requirements?

*still googling about it....

 

cheers



#10 Mike L

Mike L

    Advanced Member

  • Members
  • PipPipPip
  • 48 posts

Posted 25 February 2014 - 05:23 AM

Hi Mike,

 

I saw that you used a LAN cable to connect the netduino to MQTT broker(or maybe internet). Is it possible to use MQTT via GSM/GPRS shield? I dont have idea what MQTT exactly is? if I want to measure an environment in the remote site, which is no 3G connection. but I want to use M2M protocol, what I have to prepare to learn.?

 

Here is My desired topology:

 

Netduino+ --> GSM/GPRS shield .......?....... ----> GSM modem (wavecom etc) --->PC

 

 

can i comunicate between those GSM modem via MQTT? or M2M? is there any special requirements?

*still googling about it....

 

cheers

 

Hi Fahdil,

I do not have any experience with a GSM Shield but I would think MQTT would work fine over it.  MQTT is just a light weight protocol over TCP/IP.



#11 Fahdil

Fahdil

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts
  • LocationJakarta, Indonesia

Posted 25 February 2014 - 12:06 PM

So as long as... My Netduino has an IP. it is possible to try.hmm

 

and about the broker, do we need a contract with them, or it's just a free service?

 

thanks anyway for your respon



#12 Mike L

Mike L

    Advanced Member

  • Members
  • PipPipPip
  • 48 posts

Posted 26 February 2014 - 02:12 AM

So as long as... My Netduino has an IP. it is possible to try.hmm

 

and about the broker, do we need a contract with them, or it's just a free service?

 

thanks anyway for your respon

 

You can use one of the test brokers out there for development, but once you start getting a commercial product finished you should spin up your own broker.

 

http://test.mosquitto.org/






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.