Arduino Nano BLE 33 Sense和DS18B20无法正常工作

时间:2020-03-27 12:17:14

标签: c++ arduino nano

我的问题与Arduino Nano Sense BLE和DS18B20传感器(防水版本)无法一起使用有关。

到目前为止我尝试过的。我对UNO进行了测试,以隔离可能的供电和传感器故障。测试如下:

DS18B20的连接

黑色> GDN

红色> 3V

黄色> D2

最后两个通过2k2电阻连接(当我使用3V时,将2k2改为4k7)。

然后,为排除可能的编码错误,我使用了现成的示例:

// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

/*
 * The setup function. We only start the sensors here
 */
void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
}

/*
 * Main function, get and show the temperature
 */
void loop(void)
{
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  // After we got the temperatures, we can print them here.
  // We use the function ByIndex, and as an example get the temperature from the first sensor only.
  Serial.print("Temperature for the device 1 (index 0) is: ");
  Serial.println(sensors.getTempCByIndex(0));
  delay(1000);
}

结果?效果很好。

然后我切换到Nano Sense BLE板。在不断开传感器的情况下,我只是切换了板端的连接并连接了GDN,3.3V和D2。

结果-127。尝试查找DS18B20地址时,结果为无。我怀疑电路板的引脚顺序问题或Dallas / OneWire lib问题。

我还尝试了其他库来处理DS18B20,但没有用,我尝试了其中的3-4个。我注意到互联网上有关纳米系列的话题很少,而且都没有解决。我发现IoT和Every也有相同的问题。

0 个答案:

没有答案
相关问题