User Tools

Site Tools


2016:yun_notes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
2016:yun_notes [2016/04/05 08:22] 75.177.137.22016:yun_notes [2016/04/05 08:26] (current) 75.177.137.2
Line 7: Line 7:
      #include <pubsubclient.h>      #include <pubsubclient.h>
      #include <yunclient.h>      #include <yunclient.h>
- 
      void callback(char* topic, byte* payload, unsigned int length) {      void callback(char* topic, byte* payload, unsigned int length) {
      // handle message arrived      // handle message arrived
Line 17: Line 16:
      Bridge.begin();      Bridge.begin();
            
 +
 +
 +==== The aha Moment ====
 +
 +----
 +
 +Instead of doing this with EthernetClient, on say, a Duemilanove with an Ethernet shield:
 +
 +     #include <Ethernet.h>
 +     ...
 +     EthernetClient eth;
 +     PubSubClient mqtt(MQTT_SERVER, MQTT_PORT, callback, eth);
 +     ...
 +     Ethernet.begin(mac);
 +     ...
 +     mqtt.connect(MQTT_CLIENTID, ....);
 +
 +you do this with the Yun:
 +
 +     #include <YunClient.h>
 +     ...
 +     YunClient yun;
 +     PubSubClient mqtt(MQTT_SERVER, MQTT_PORT, callback, yun);
 +     ...
 +     Bridge.begin();
 +     ...
 +     mqtt.connect(MQTT_CLIENTID, ....);
 +
 +The bridge opens the connection to the outside world from the Arduino via the OpenWRT host.
2016/yun_notes.1459858952.txt.gz · Last modified: 2016/04/05 08:22 by 75.177.137.2