Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Incorrect library file for the temperature sensor?

Status
Not open for further replies.

Justinli

Member level 4
Joined
Apr 29, 2021
Messages
76
Helped
0
Reputation
0
Reaction score
2
Trophy points
8
Activity points
413
When I used the display and temperature sensor for the weather station project, I called the "dht11" library while writing the code, and then I got this error, I used the DHT11 temperature sensor.

Code:
Arduino:1.8.13 (Windows 7), Development Boards:"Arduino Uno"
C:\AppData\Local\Temp\ccRJNuOI.ltrans0.ltrans.o: In function `loop':

E:\weather1/weather1.ino:36: undefined reference to `dht::read(int)'

collect2.exe: error: ld returned 1 exit status

exit status 1

Error while compiling for development board Arduino Uno.
 

Code:
int lightState = 0;
bool TemperatureBool = false;
bool HumidityBool = false;
bool illuminationBool = false;
bool illuminationState = false;

uint8_t TemperatureValueInteger = 0;
uint8_t TemperatureValueDecimal = 0;
uint8_t TemperatureValue = 0;

uint8_t HumidityValue = 0;
uint8_t illuminationValue = 0;

uint8_t TemperatureOutput[8] = {0xA5, 0x5A, 0x05, 0x82, 0x00, 0x10, 0x00, 0x00}; //A5 5A 06 83 00 0A 01 00 02
uint8_t HumidityOutput[8] = {0xA5, 0x5A, 0x05, 0x82, 0x00, 0x15, 0x00, 0x00}; //A5 5A 06 83 00 14 01 00 05
uint8_t illuminationOutput[8] = {0xA5, 0x5A, 0x05, 0x82, 0x00, 0x20, 0x00, 0x00}; //A5 5A 06 83 00 18 01 00 08
uint32_t cout_i;
uint8_t RecievedTemp[40];

#include "dht11.h"
dht11 DHT;
#define DHT11_PIN 5
#define PIN_A 3


void setup() {
 
  Serial.begin(115200);
 
}

void loop() {

DHT.read(DHT11_PIN);
 
 if(Serial.available() != 0)
  {
    for(cout_i = 0; cout_i < 9; cout_i ++)
    {
        RecievedTemp[cout_i] = Serial.read();
    }
    switch(RecievedTemp[5])
    {
    case 0x0A://Temperature start
        TemperatureBool = true;
        break;
    case 0x0C://Temperature stop
        TemperatureBool = false;
        TemperatureValue = DHT.temperature;
        TemperatureOutput[7] = TemperatureValue;
        Serial.write(TemperatureOutput, 8);
        break;
    case 0x0E://Temperature back
        TemperatureBool = false;
        break;
    case 0x14://Humidity start
      HumidityBool = true;
        break;
    case 0x16://Humidity stop
        HumidityBool = false;
        HumidityValue = DHT.humidity;
        HumidityOutput[7] = HumidityValue;
        Serial.write(HumidityOutput, 8);
        break;
    case 0x13://Humidity back
        HumidityBool = false;
        break;
    case 0x18://illumination start
      illuminationBool = true;
      illuminationState = false;
        break;
    case 0x19://illumination stop
      illuminationBool = false;
      illuminationValue = analogRead(PIN_A);
      illuminationOutput[7] = illuminationValue;
      Serial.write(illuminationOutput, 8);
        break;
    case 0x17://illumination back
      illuminationValue = 0;
      illuminationBool = false;
      break;
    default:
        break;
    }
}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top