من برای اطمینان از صحت محاسبات و کیفیت محصول «شیلد سنسور دمای DS18B20 برد Wemos Mini D1» رو به همراه Wemos Mini D1 خریداری کردم.(از eca.ir) ولی متاسفانه هیچ دیتاشیتی برای ان ارایه نشد. من با توجه به کدهای دوستان هر چه تلاش کردم موفق به خواندن دما نشدم.
برنامه من خطای
09
06.692 -> Requesting temperatures...DONE
09
06.692 -> Error: Could not read temperature data
میدهد.
لطفا کمک نمایید.
مشکل از کجاست؟ ایا مشکل نرم افزاریه یا سخت افزاری؟
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //Serial connection
sensors.begin();
}
void loop() {
// 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.
float celsius = sensors.getTempCByIndex(0);
// Check if reading was successful
if(celsius != DEVICE_DISCONNECTED_C)
{
Serial.print("Temperature for the device 1 (index 0) is: ");
Serial.println(celsius);
}
else
{
Serial.println("Error: Could not read temperature data");
}
HttpPost(celsius);
delay(1000*(delaytime-1));
Serial.println("LOOP...");
}
برنامه من خطای
09

09

میدهد.
لطفا کمک نمایید.
مشکل از کجاست؟ ایا مشکل نرم افزاریه یا سخت افزاری؟
دیدگاه