使用BlueMix的Node-RED编辑器和MQTT->debugging节点时出现意外的string

我正在学习本教程, http://energia.nu/creating-an-iot-connected-sensor-with-energia-mqtt/

我看到推送的数据,但Node-RED编辑器不断打印“Hello World #XX”。 我没有看到代码中的任何内容,表明它来自哪里:

#include <WiFi.h> #include <PubSubClient.h> #include <SPI.h> //only required if using an MCU LaunchPad + CC3100 BoosterPack. Not needed for CC3200 LaunchPad WiFiClient wclient; byte server[] = { 198, 41, 30, 241 }; // Public MQTT Brokers: http://mqtt.org/wiki/doku.php/public_brokers byte ip[] = { 172, 16, 0, 100 }; char sensorRead[4]; #define WIFI_SSID "SSID" #define WIFI_PWD "WIFIPASSWORD" PubSubClient client(server, 1883, callback, wclient); void callback(char* inTopic, byte* payload, unsigned int length){ // Handle callback here } void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); Serial.println("Start WiFi"); WiFi.begin(WIFI_SSID, WIFI_PWD); while(WiFi.localIP() == INADDR_NONE) { Serial.print("."); delay(300); } Serial.println(""); printWifiStatus(); } void loop() { // read the input on analog pin: int sensorValue = analogRead(24); Serial.println(sensorValue); // convert into to char array String str = (String)sensorValue; int str_len = str.length() + 1; // Length (with one extra character for the null terminator) char char_array[str_len]; // Prepare the character array (the buffer) str.toCharArray(char_array, str_len); // Copy it over // publish data to MQTT broker if (client.connect("LaunchPadClient")) { client.publish("outTopic", char_array); //client.subscribe("inTopic"); Serial.println("Publishing successful!"); client.disconnect(); } } void printWifiStatus() { // print the SSID of the network you're attached to: Serial.print("SSID: "); Serial.println(WiFi.SSID()); // print your WiFi shield's IP address: IPAddress ip = WiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip); } 

NodeRedEditor

这是因为这是一个免费/试用帐户? 顺便说一句,它显示我使用512MB / 2GB,这似乎很高…包括发送的数据,或者是512MB只是应用程序的大小?

您正在使用全球公开的MQTT代理,任何人都可以将数据发布到该代理上的任何主题。 这些消息可能来自其他人正在为自己做类似的实验。

outTopic是很多人可以用来testing的主题名称,尝试将其更改为Node-RED中的发布代码和MQTT In节点中的某个随机string。

至于Bluemix中的大小,这是多less内存分配给您的应用程序,目前不太可能实际使用任何接近该数额的任何东西。