Gidday fellas
I'm currently working on some code to read an AM2302 sensor:
// Adafruit Unified Sensor - Version: Latest
// This library is required to get the sensor working(?)
#include <Adafruit_Sensor.h>
// DHT sensor library - Version: Latest
#include <DHT.h>
#include <DHT_U.h>
//#define DHTPIN 2 (may not need this)
//#define DHTTYPE DHT22 (may not need this)
//This is some WIP code for getting the Arduino to read the AM2302 sensor
//Based off the code dancili used in his project "Test DHT22 Sensors with Arduino and MATLAB © CC BY-SA"
//URL: https://create.arduino.cc/projecthub/dancili/test-dht22-sensors-with-arduino-and-matlab-74e81d?f=1
DHT dht1(2, DHT22); //This line defines "dht1", a DHT22 sensor on Pin 2.
//Defining the variables used
float hum; //Humidity variable
float temp; //Temperature variable
//Starting up the sensor and serial port
void setup() {
Serial.begin(9600);
dht1.begin();
}
//This code reads dht1's temp and hum, t prints it to serial.
void loop() {
hum = dht1.readHumidity();
Serial.print(hum);
Serial.print(":");
temp = dht1.readTemperature();
Serial.print(temp);
Serial.print(":");
}
The code is verified to be working and I'm currently in the process of uploading it to the Arduino. Only problem is that this is taking forever! E.g. I've been waiting for 10 minutes so far.
This is the (last 10 lines) of the verbose output from the Cloud IDE:
/home/builder/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-objcopy -O ihex -R .eeprom /tmp/281342784/build/sketch_apr18a.ino.elf /tmp/281342784/build/sketch_apr18a.ino.hex
Multiple libraries were found for "DHT.h"
Used: /home/builder/opt/libraries/latest/dht_sensor_library_1_3_4
Not used: /home/builder/opt/libraries/latest/nanoplayboard_0_1_1
Not used: /home/builder/opt/libraries/latest/grove_temperature_and_humidity_sensor_1_0_0
Using library adafruit_unified_sensor_1_0_3 at version 1.0.3 in folder: /home/builder/opt/libraries/latest/adafruit_unified_sensor_1_0_3
Using library dht_sensor_library_1_3_4 at version 1.3.4 in folder: /home/builder/opt/libraries/latest/dht_sensor_library_1_3_4
/home/builder/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-size -A /tmp/281342784/build/sketch_apr18a.ino.elf
Sketch uses 6054 bytes (12%) of program storage space. Maximum is 49152 bytes.
Global variables use 194 bytes (3%) of dynamic memory, leaving 5950 bytes for local variables. Maximum is 6144 bytes.
The serial tab is unusable, "Serial port temporarily busy". Here is a screenshot: