Depending on what libraries and features are used in your source code you may be able to re-build exactly the same source code to run on either the Uno or the ESP(32 etc) by changing Tools / Board. If there is something incompatible with your code for the selected board you should get a build error.The code programmed for the ESP by using the Arduino IDE can be applied directly to the Arduino UNO?
Yes, thanks a lot, I've received some error alerts.Depending on what libraries and features are used in your source code you may be able to re-build exactly the same source code to run on either the Uno or the ESP(32 etc) by changing Tools / Board. If there is something incompatible with your code for the selected board you should get a build error.
C:\Users\Stone-6\AppData\Local\Temp\ccRJNuOI.ltrans0.ltrans.o: In function `loop':
E:\document\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.
All I use in my project are sensors and I don't think I need to define any output pins in setup.hi Y2,
Please post your full Arduino sketch, I will try it out on my setup.
E
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;
}
}
}
Thank you so much! I have corrected my mistake, maybe I added the incorrect library for the temperature sensor, I have added a correct library.The same error is reported here and a solution is offered but there's no feedback about whether the solution worked
https://forum.arduino.cc/t/error-compiling-dht11/476667
by Jake Hertz
by Aaron Carman
by Robert Keim