Датчик температуры DHT11 и TM1637

SlawonK

✩✩✩✩✩✩✩
19 Янв 2020
1
0
Посмотретите пожалуйста почему не рабоет код
#include <DHT.h>
#include <DHT_U.h>
#include <TM1637.h>



#define DHTPIN 2
#define DHTTYPE DHT11
#define CLK 9
#define DIO 8

TM1637 tm1637 (CLK,DIO);
DHT dht(DHTPIN, DHTTYPE);

void setup() {
// put your setup code here, to run once:
tm1637.init();
tm1637.set(BRIGHT_TYPICAL);

delay(1500);
}

void loop() {
// put your main code here, to run repeatedly:
dht.read(DHTPIN);

int temp = dht.temperature;
int humidity = dht.humidity;

int digitoneT = temp / 10;
int digittwoT = temp % 10;

int digitoneH = humidity / 10;
int digittwoH = humidity % 10;

tm1637.display(1.digitoneT);
tm1637.display(2.digitwoT);
tm1637.display(3.12);

delay (5000);

tm1637.display(1.digitoneH);
tm1637.display(2.digitwoH);
tm1637.display(3.15);

}
Выдает ошибку:
C:\Users\User\Documents\DT11\DT11.ino: In function 'void loop()':

DT11:29:18: error: 'class DHT' has no member named 'temperature'

int temp = dht.temperature;
^
DT11:30:22: error: 'class DHT' has no member named 'humidity'

int humidity = dht.humidity;
^
DT11:38:18: error: unable to find numeric literal operator 'operator""digitoneT'

tm1637.display(1.digitoneT);
^
DT11:39:18: error: unable to find numeric literal operator 'operator""digitwoT'

tm1637.display(2.digitwoT);
^
DT11:40:22: error: no matching function for call to 'TM1637::display(double)'

tm1637.display(3.12);
^
In file included from C:\Users\User\Documents\DT11\DT11.ino:3:0:

C:\Program Files (x86)\Arduino\libraries\TM1637/TM1637.h:51:10: note: candidate: void TM1637::display(int8_t*)

void display(int8_t DispData[]);
^
C:\Program Files (x86)\Arduino\libraries\TM1637/TM1637.h:51:10: note: no known conversion for argument 1 from 'double' to 'int8_t* {aka signed char*}'

C:\Program Files (x86)\Arduino\libraries\TM1637/TM1637.h:52:10: note: candidate: void TM1637::display(uint8_t, int8_t)

void display(uint8_t BitAddr,int8_t DispData);
^
C:\Program Files (x86)\Arduino\libraries\TM1637/TM1637.h:52:10: note: candidate expects 2 arguments, 1 provided

DT11:44:18: error: unable to find numeric literal operator 'operator""digitoneH'

tm1637.display(1.digitoneH);
^
DT11:45:18: error: unable to find numeric literal operator 'operator""digitwoH'

tm1637.display(2.digitwoH);
^
DT11:46:22: error: no matching function for call to 'TM1637::display(double)'

tm1637.display(3.15);
^
In file included from C:\Users\User\Documents\DT11\DT11.ino:3:0:

C:\Program Files (x86)\Arduino\libraries\TM1637/TM1637.h:51:10: note: candidate: void TM1637::display(int8_t*)

void display(int8_t DispData[]);
^
C:\Program Files (x86)\Arduino\libraries\TM1637/TM1637.h:51:10: note: no known conversion for argument 1 from 'double' to 'int8_t* {aka signed char*}'

C:\Program Files (x86)\Arduino\libraries\TM1637/TM1637.h:52:10: note: candidate: void TM1637::display(uint8_t, int8_t)

void display(uint8_t BitAddr,int8_t DispData);
^
C:\Program Files (x86)\Arduino\libraries\TM1637/TM1637.h:52:10: note: candidate expects 2 arguments, 1 provided

exit status 1
'class DHT' has no member named 'temperature'
 

Старик Похабыч

★★★★★✩✩
14 Авг 2019
1,652
409
Москва
Возможно обращаться надо не как к полям, а как к методам, т.е. функциям, тогда вместо
nt temp = dht.temperature;
int humidity = dht.humidity;
следует писать
nt temp = dht.temperature();
int humidity = dht.humidity();
такая ошибка распространенная. Что бы проверить надо ставить библиотеки, пока это не удобно делать