This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] 具有 ENERGIA 的 CC3100 PubNub/freeboard

Guru**** 2562840 points
Other Parts Discussed in Thread: CC3120, CC3100

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/588802/cc3100-pubnub-freeboard-with-energia

主题中讨论的其他器件:CC3120CC3100

大家好!!

我有一个小问题、它如下所示:

首先、我将使用近似的随机值模拟传感器、 我需要将这些数据上传到 pubnub 和 freeboard 作为监控平台、我遇到的问题是、在 pubnub 中、我发现这些值是实时更新的、 发生的情况是、当我上传到 freeboard 时、它们不会更新、而是采用固定的数字。  

我对储存这些文件的方式犹豫不决,我认为这是不合适的。

我有公共账户和自由账户之间的良好关联。

 

大家好。 先生

这是我的代码!!  

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include 
#include 
#include "PubNub.h"
#include 

#define NUM_CHANNELS 4 //您希望读取

双随机数(double min、double max、int numCasas)的模拟通道数量{
long _min = min * pow (10、numCasas)+ 0.1;
long _max = max * pow (10、numCasas)+ 0.1;

return (double) random (_min、_max)/numCasas)


int sn=0;

char pubkey[]="***";
char 子项[]="***";
char channel[]="***";
char uuid[]="***";

//您的网络名称也称为 SSID
char sID[]="***";
//您的网络密码
char password[]="***";
静态 int keyIndex = 0;


void setup (


Serial.begin(115200);)
RandySeed (analogRead (0));
PubNub.begin(pubkey,子项);
PubNub.set_uuid(uuid);
Serial.println ("PubNub 设置");
}

void loop()
{
double Freq = RandomDouble(10.71、10.79、2)+1839755.00;
double volte_1 = RandDouble(0.82、0.88、2);
double temperature = RandomDouble(18.30、20.00、2);
double vol = RandomDouble(3.10、3.29、2);

double data[]={Freq、volte_1、temperature、vol};


PubSubClient *客户端;

//创建 JSON 对象
aJsonObject *msg,*dataReadings;
MSG = aJson.CreateObject();
aJson.addItemToObject (msg、"DataReading"、dataReadings = aJson.CreateObject());

//获取最新的传感器值,然后添加到 JSON 消息中
对于(int i = 0;i < NUM_CHANNELS;i++){
字符串通道=字符串(data[i]);
char charBuf[Channel.length ()+1];
channel.toCharArray (charBuf、Channel.length ()+1);
双精度值= DATA[i];
aJson.addNumberToObject (dataReadings、charBuf、Values);
}

//将 JSON 对象转换为字符数组,然后删除 JSON 对象
char *json_String = aJson.print (msg);
aJson.deleteItem(msg);

//将 JSON 格式化字符数组发布到 PubNub
Serial.print ("发布消息:");
Serial.println (json_String);
PubNub.publish (channel、json_String);
FREE (json_String);

延迟(500);
}