Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arduino-SigFox温度数据问题_Arduino_Arduino Mkr1000 - Fatal编程技术网

Arduino-SigFox温度数据问题

Arduino-SigFox温度数据问题,arduino,arduino-mkr1000,Arduino,Arduino Mkr1000,有人能帮我安装这个Sigfox吗? 我做错了什么?:-) 我唯一想实现的就是将内部温度和状态发布到sigfox后端。 每15分钟,数据就会被公布。 A配置了一封来自服务的电子邮件,以摄氏度为单位显示温度 发布到后端正在工作。 然而,电子邮件消息和数据似乎并不一致。 在调试模式下运行代码时。温度以摄氏度正确显示 有手册吗 代码Arduino MKR FOX 1200 临时工 设置Sigfox后端-电子邮件回调 使用当前的ConvertoFloLatoInt16,无法直接从Sigfox后端在电子邮件

有人能帮我安装这个Sigfox吗? 我做错了什么?:-)

我唯一想实现的就是将内部温度和状态发布到sigfox后端。 每15分钟,数据就会被公布。 A配置了一封来自服务的电子邮件,以摄氏度为单位显示温度

发布到后端正在工作。 然而,电子邮件消息和数据似乎并不一致。 在调试模式下运行代码时。温度以摄氏度正确显示

有手册吗

代码Arduino MKR FOX 1200

临时工

设置Sigfox后端-电子邮件回调

使用当前的ConvertoFloLatoInt16,无法直接从Sigfox后端在电子邮件中显示实际温度

您或者需要使用从Sigfox后端回调到实现ConvertofLatouint16的服务器,然后发送电子邮件,或者以Sigfox后端可以本地解码的格式发送温度(32位浮点可能是最合适的)

#include <ArduinoLowPower.h>
#include <SigFox.h>
#include "conversions.h"

// Set oneshot to false to trigger continuous mode when you finisched setting up the whole flow
int oneshot = false;


#define STATUS_OK     0

/*
    ATTENTION - the structure we are going to send MUST
    be declared "packed" otherwise we'll get padding mismatch
    on the sent data - see http://www.catb.org/esr/structure-packing/#_structure_alignment_and_padding
    for more details
*/
typedef struct __attribute__ ((packed)) sigfox_message {
  int16_t moduleTemperature;
  uint8_t lastMessageStatus;
} SigfoxMessage;

// stub for message which will be sent
SigfoxMessage msg;

void setup() {

  if (oneshot == true) {
    // Wait for the serial
    Serial.begin(115200);
    while (!Serial) {}
  }

  if (!SigFox.begin()) {
    // Something is really wrong, try rebooting
    // Reboot is useful if we are powering the board using an unreliable power source
    // (eg. solar panels or other energy harvesting methods)
    reboot();
  }

  //Send module to standby until we need to send a message
  SigFox.end();

  if (oneshot == true) {
    // Enable debug prints and LED indication if we are testing
    SigFox.debug();
  }

 }

void loop() {
  // Every 15 minutes, read all the sensor and send the data
  // Let's try to optimize the data format
  // Only use floats as intermediate representaion, don't send them directly

  //sensors_event_t event;

  // Start the module
  SigFox.begin();
  // Wait at least 30ms after first configuration (100ms before)
  delay(100);

  // We can only read the module temperature before SigFox.end()
  float temperature = SigFox.internalTemperature();
  msg.moduleTemperature = convertoFloatToInt16(temperature, 60, -60);

  if (oneshot == true) {
    Serial.println("Internal temp: " + String(temperature));
  }

  // Clears all pending interrupts
  SigFox.status();
  delay(1);

  SigFox.beginPacket();
  SigFox.write((uint8_t*)&msg, 12);

  msg.lastMessageStatus = SigFox.endPacket();

  if (oneshot == true) {
    Serial.println("Status: " + String(msg.lastMessageStatus));
  }

  SigFox.end();

  if (oneshot == true) {
    // spin forever, so we can test that the backend is behaving correctly
    while (1) {}
  }

  //Sleep for 15 minutes
  LowPower.sleep(1 * 60 * 1000);
}

void reboot() {
  NVIC_SystemReset();
  while (1);
}
#define UINT16_t_MAX  65536
#define INT16_t_MAX   UINT16_t_MAX/2

int16_t convertoFloatToInt16(float value, long max, long min) {
  float conversionFactor = (float) (INT16_t_MAX) / (float)(max - min);
  return (int16_t)(value * conversionFactor);
}

uint16_t convertoFloatToUInt16(float value, long max, long min = 0) {
  float conversionFactor = (float) (UINT16_t_MAX) / (float)(max - min);
  return (uint16_t)(value * conversionFactor);
}