小编Ana*_*har的帖子

带有 Arduino Uno 的 RabbitMQ

我是第一次在 Arduino 上使用 RabbitMQ,我需要发布数据。所以我使用了 PubSubCLient 类。这是代码:

#include <SPI.h>
#include <PubSubClient.h>
#include <Dhcp.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <Dns.h>
#include <EthernetServer.h>
#include <EthernetClient.h>

//declare variables
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xDE, 0xDE, 0xDD };
byte server[] = { 127, 0, 0, 1 };
byte ip[] = { 192, 168, 1, 22 };
String stringone = "localhost";

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.println(topic);
  //convert byte to char
  payload[length] = '\0';
  String strPayload = String((char*)payload);
  Serial.println(strPayload);
  int …
Run Code Online (Sandbox Code Playgroud)

arduino rabbitmq consumer producer arduino-uno

4
推荐指数
1
解决办法
4149
查看次数

标签 统计

arduino ×1

arduino-uno ×1

consumer ×1

producer ×1

rabbitmq ×1