To connect a device directly to arduino, we can set the digital pins to HIGH and LOW, which will act as VCC and GND
PULL UP resistance connected from the data line can be done internally by arduino.
To do this, set the data pin to INPUT_PULLUP pin mode
#include "DHT.h"
#define DHTPIN 4
#define GNDPIN 3
#define VCCPIN 5
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
pinMode(DHTPIN, INPUT_PULLUP);
pinMode(GNDPIN, OUTPUT);
pinMode(VCCPIN, OUTPUT);
digitalWrite(GNDPIN, LOW);
digitalWrite(VCCPIN, HIGH);
// THIS DOES NOT WORK UNLESS VALUE is 255
// TO make HIGH = 3.3V, usw PWM pin for VCC
// value = (255/5)*3.3
// analogWrite(VCCPIN, 170);
dht.begin();
}
void loop() {
// SAME AS BEFORE
}
The GPIO pins are connected to the MC, unlike the actual VCC pin. Hence take the following precautions,
1) Make sure that your breakout can operate at 5V
2) The current flowing through the circuit should be less than 20mA. For this, check the device current rating, which tells how much current will be drawn maximum at the operating voltage(If you supply 5V to a device which can operate at 3.3V, it will draw more current)
3) Connect the circuit in the breadboard first to double check if the right current is flowing.
Accelerometer is used to measure the orientation of the device. It is an analog device with three analog pins for measuring x, y and z axis orientations
1) It is more common to use an accelerometer fixed on board to the device.
2) But ADXL335 works at 3.3V.
3) Make sure that the breakout you purchase has a voltage regulator in it
Adafruit version has a voltage regulator, but Sparkfun version does not
A voltage adapter will look like the small chip right next to barrel plug on arduino board