Sheik Dawood in MATLAB Answers
上次活动时间: 2022-1-3

My partner has uploaded the DHT 22 sensor details in ThingSpeak,however from there we have no clue on how to retrieve those data into unity. i really hope someone could help me with this
Celso Fernando Baspineiro in Discussions
上次活动时间: 2021-9-21

My goal is to get the data from two DHT22 sensors, with a single sensor I had no problem but with two sensors I get only a few data and then it interrupts reporting "Read DHT22 failed." I share my code, any suggestions I appreciate #include <SimpleDHT.h> #include <ESP8266WiFi.h> String apiKey = "xxxxx"; const char* ssid = "xxxxx"; const char* password = "xxxxx"; const char* server = "api.thingspeak.com"; int pinDHT22 = D0; int pinDHT221 = D1; SimpleDHT22 dht22(pinDHT22); SimpleDHT22 dht221(pinDHT221); WiFiClient client; void setup() { Serial.begin(115200); delay(10); WiFi.begin(ssid, password); Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); } void loop() { byte temperatura = 0; byte humedad = 0; byte temperatura1 = 0; byte humedad1 = 0; if (dht22.read(pinDHT22, &temperatura, &humedad, NULL)) { Serial.print("Read DHT22 failed."); return; } if (dht221.read(pinDHT221, &temperatura1, &humedad1, NULL)) { Serial.print("Read DHT221 failed."); return; } if (client.connect(server,80)) { String postStr = apiKey; postStr +="&field1="; postStr += String((int)temperatura); postStr +="&field2="; postStr += String((int)humedad); postStr +="&field3="; postStr += String((int)temperatura1); postStr +="&field4="; postStr += String((int)humedad1); postStr += "\r\n\r\n"; client.print("POST /update HTTP/1.1\n"); client.print("Host: api.thingspeak.com\n"); client.print("Connection: close\n"); client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n"); client.print("Content-Type: application/x-www-form-urlencoded\n"); client.print("Content-Length: "); client.print(postStr.length()); client.print("\n\n"); client.print(postStr); Serial.println("% send to Thingspeak"); } client.stop(); Serial.println("Waiting…"); delay(120000); } Problem with two (or more) DHT22 sensors connected to nodeMCU problem solved! Thanks for letting us know! dht22
John Park in MATLAB Answers
上次活动时间: 2019-4-24

I am trying to write humidity and temperature data from DHT22 to thingspeak channel. I installed Arduino support package and additional library for DHT (FYI: I haven't set myself any directory when I install the package & library) Then I get the error message as below: C:/ProgramData/MATLAB/SupportPackages/R2019a/3P.instrset/arduinoide.instrset/idepkgs/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -std=gnu++11 -fno-threadsafe-statics -fno-rtti -fno-exceptions -Os -c -g -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -DARDUINO=10801 -MMD -MP -MF"MW_thingspeak.dep" -MT"MW_thingspeak.o" -MMD -mcpu=cortex-m0plus -fpermissive -DF_CPU=48000000L -DARDUINO_SAMD_MKR1000 -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x824e -DUSBCON -DUSB_MANUFACTURER=\""Unknown\"" -DUSB_PRODUCT=\""Genuino MKR1000\"" -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_MKR1000_ -D_RTT_THINGSPEAK_WIFI_=1 -D_RTT_USE_SERIAL0_ -DMODEL=dht22_iot_demo -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DON_TARGET_WAIT_FOR_START=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DXCP_CUSTOM_PLATFORM -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DRT -DMW_TIMERID=9 -DMW_PRESCALAR=256 -DMW_TIMERCOUNT=46875 -DMW_SCHEDULERCOUNTER=2 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_ANALOG_REF_=0 -D_RTT_WIFI_Local_IP1=192 -D_RTT_WIFI_Local_IP2=168 -D_RTT_WIFI_Local_IP3=1 -D_RTT_WIFI_Local_IP4=20 -D_RTT_WIFI_SSID="Park1Suite0404" -D_RTT_WIFI_WPA_PASSWORD=jj12190516P -D_RTT_WIFI_WPA=1 -D_RTT_DISABLE_Wifi_DHCP_=0 -D_RTT_ThingSpeak_IP1=184 -D_RTT_ThingSpeak_IP2=106 -D_RTT_ThingSpeak_IP3=153 -D_RTT_ThingSpeak_IP4=149 -D_RTT_ThingSpeak_Port=80 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DON_TARGET_WAIT_FOR_START=1 -DXCP_CUSTOM_PLATFORM -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=dht22_iot_demo -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -IC:/Users/JOHNPA~1/DOCUME~1/MATLAB/DHT_v2 -IC:/PROGRA~3/MATLAB/SupportPackages/R2019a/toolbox/target/supportpackages/arduinobase/include -IC:/Users/JOHNPA~1/AppData/Roaming/MATHWO~1/MATLAB Add-Ons/Collections/Arduino Additional Sensors Library (DHT, LPS331)/roslovets-Arduino_Additional_Sensors_Simulink_Library_DHT_LPS331-7d4fe21/drivers/DHT/include -IC:/Users/JOHNPA~1/DOCUME~1/MATLAB/DHT_v2/dht22_iot_demo_ert_rtw -IC:/PROGRA~1/MATLAB/R2019a/extern/include -IC:/PROGRA~1/MATLAB/R2019a/simulink/include -IC:/PROGRA~1/MATLAB/R2019a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2019a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2019a/rtw/c/ert -IC:/PROGRA~1/MATLAB/R2019a/toolbox/coder/rtiostream/src -IC:/PROGRA~1/MATLAB/R2019a/toolbox/coder/rtiostream/src/utils -IC:/ProgramData/MATLAB/SupportPackages/R2019a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include -IC:/ProgramData/MATLAB/SupportPackages/R2019a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/CMSIS-Atmel/1.1.0/CMSIS/Device/ATMEL -IC:/ProgramData/MATLAB/SupportPackages/R2019a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.20/cores/arduino -IC:/ProgramData/MATLAB/SupportPackages/R2019a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.20/variants/mkr1000 -IC:/PROGRA~3/MATLAB/SupportPackages/R2019a/toolbox/target/supportpackages/arduinotarget/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2019a/toolbox/target/supportpackages/arduinotarget/scheduler/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2019a/toolbox/target/supportpackages/armcortexmbase/scheduler/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2019a/toolbox/target/shared/externalmode_daemon/include -IC:/Users/JOHNPA~1/DOCUME~1/Arduino/libraries/WiFi101/src -IC:/Users/JOHNPA~1/DOCUME~1/Arduino/libraries/WiFi101/src/bsp/include -IC:/Users/JOHNPA~1/DOCUME~1/Arduino/libraries/WiFi101/src/bus_wrapper/include -IC:/Users/JOHNPA~1/DOCUME~1/Arduino/libraries/WiFi101/src/common/include -IC:/Users/JOHNPA~1/DOCUME~1/Arduino/libraries/WiFi101/src/driver/include -IC:/Users/JOHNPA~1/DOCUME~1/Arduino/libraries/WiFi101/src/driver/source -IC:/Users/JOHNPA~1/DOCUME~1/Arduino/libraries/WiFi101/src/socket/include -IC:/Users/JOHNPA~1/DOCUME~1/Arduino/libraries/WiFi101/src/socket/source -IC:/Users/JOHNPA~1/DOCUME~1/Arduino/libraries/WiFi101/src/spi_flash/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2019a/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.20/libraries/SPI -o MW_thingspeak.o C:/ProgramData/MATLAB/SupportPackages/R2019a/toolbox/target/supportpackages/arduinobase/src/MW_thingspeak.cpp arm-none-eabi-g++: error: Add-Ons/Collections/Arduino: No such file or directory arm-none-eabi-g++: error: Additional: No such file or directory arm-none-eabi-g++: error: Sensors: No such file or directory arm-none-eabi-g++: error: Library: No such file or directory arm-none-eabi-g++: error: (DHT,: No such file or directory arm-none-eabi-g++: error: LPS331)/roslovets-Arduino_Additional_Sensors_Simulink_Library_DHT_LPS331-7d4fe21/drivers/DHT/include: No such file or directory gmake: *** [MW_thingspeak.o] Error 1 The make command returned an error of 2 ### Build procedure for model: 'dht22_iot_demo' aborted due to an error. Error(s) encountered while building "dht22_iot_demo": ### Failed to generate all binary outputs. Please advise how to resolve it.

关于 ThingSpeak

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.