dhtxx | A Swift library for DHTXX temperature & humidity sensors
kandi X-RAY | dhtxx Summary
kandi X-RAY | dhtxx Summary
A Swift library for reading temperature and humidity from DHTXX sensors (DHT11, DHT22, AM2303).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dhtxx
dhtxx Key Features
dhtxx Examples and Code Snippets
Community Discussions
Trending Discussions on dhtxx
QUESTION
Hello I wanted to change some voids to bools and I am a little lost. I understand if you write a void or a bool and want to add the values to the next void you just insert the code to add the previous function
I don't know how to explain it I am just gonna tell you what I want to do:
created a new bool getValues and added all the value getting code from the sensors then I wanted to send the data to void loop that will send the data through mqqt to raspberry.
I understand that bool is for true and false. but I don't really understand the etiquette of using it
so the problem I am getting 'temp' was not declared in this scope
at the void loop function
I highlighted the function with // where I get the error it's almost at the bottom
...ANSWER
Answered 2020-Dec-04 at 12:28By moving your code to getValues
, you also changed the scope in which your temp
variable exists in. Variables are not automatically globally available. If you declare a variable inside a function (which getValues
is), it's only available in this function.
When you try to access the temp
variable in your loop
function, the compiler rightly tells you, that there is no such variable available.
You could solve the problem by declaring temp
as a global variable, which you would do by adding float temp = 0
up on top where you also declare variables like soilMoistureValue
. Make sure not to redeclare the variable in getValues
then, so instead of declaring like so float temp = dht.readTemperature();
you just assign a new value like so temp = dht.readTemperature();
A quick note on your first paragraph: The voids and bools how you call it, define the return type of a function. If your function does not return anything, you define it as void. If it returns a boolean value (so true or false), you define so bool. In the case of your getValues
function, since it does not return anything, it should be void getValues
.
QUESTION
I have a weird phenomenon that when I add the WiFi library and all the settings, 2 out of 3 sensors stop working. When I remove the WiFi code it works like it used to.
I have an esp32 devkit v1 board and connected 3 sensors which are photoresistor (ky-018), dht-11, and capacitive soil moisture sensor.
- dht-11 is connected to D14 (works);
- photoresistor(ky-018) connected to D13 (doesn't work);
- capacitive soil moisture sensor connected to D15 (doesn't work).
I tried changing pins; didn't help.
Here is the code:
...ANSWER
Answered 2020-Dec-03 at 14:16The problem is probably that, according to this comment on this issue on GitHub:
ADC2 pins can not be used when WiFi is used. On the other hand, ADC1 pins can be used even when WiFi is enabled.
This is probably because the ADC2 is used by the WiFi firmware running on the core that has the ADC2 peripheral.
This doesn't explain why GPIO14 is working for you, though, but still, you could try using only GPIO pins that use ADC1 and see if that works for you.
Also, WiFi can pull quite a bit of current; make sure the power supply is up to it so you don't get voltage drops.
QUESTION
I connect DHT11 to pin D2 ESP8266. Use this code. In the console displays "Read fail". How can I fix it?
DHT11 tested on Arduino, it is working properly.
...ANSWER
Answered 2017-Jun-16 at 07:10There is no D2 pin in Esp8266. It is an nodemcu definition. So you can use
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dhtxx
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page