Skip to content

Instantly share code, notes, and snippets.

@jorgemaia
Last active August 29, 2015 14:26
Show Gist options
  • Save jorgemaia/32d05f9bb9b0952c4824 to your computer and use it in GitHub Desktop.
Save jorgemaia/32d05f9bb9b0952c4824 to your computer and use it in GitHub Desktop.
#include <UIPEthernet.h>
#include <PubSubClient.h>
// Update these with values suitable for your network.
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
byte server[] = { 104,41,0,81};
void callback(char* topic, byte* payload, unsigned int length) {
// Aqui trataremos o retorno que vier do servidor.
}
EthernetClient ethClient;
PubSubClient client(server, 1883, callback, ethClient);
void setup()
{
Ethernet.begin(mac);
if (client.connect("arduinoClient")) {
client.publish("NOME_DO_TOPICO","UMA MENSAGEM....");
client.subscribe("NOME_DO_TOPICO");
}
}
void loop()
{
client.loop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment