2016:yun_notes
YUN Notes
- Default login is root and password is arduino
In order to use the DD-Wrt side of the YUN with Arduino it is necessary to use the bridge function. This example shows using an MQTT client on the Arduino side hooked to the DD-Wrt side with the bridge.
#include <pubsubclient.h> #include <yunclient.h> void callback(char* topic, byte* payload, unsigned int length) { // handle message arrived } YunClient yun; PubSubClient client("192.168.2.210", 1883, callback, yun); void setup() { 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.txt · Last modified: 2016/04/05 08:26 by 75.177.137.2