Arduino Sensor Modules
Arduino Sensor Modules
photos
Cataloging modules from the dx.com ARDUINO Compatible 37-in-1 Sensor Module
Kit (DX SKU 142834.) which was used in the first MHV arduino workshops.
http://www.arduinosale.com/buy-arduino/arduino-sensors.html (individual
sensors for sale)
http://club.dx.com/forums/Forums.dx/threadid.1202308 (DealExtreme forum
thread)
These boards are all a common pattern, on a red circuit board. They have two outputs,
one is a digital output that triggers Low→High based on the sensor level and the other
is an analog output that is the exact level of the sensor.
The boards have two LEDs - one for power (L1) and one connected to the digital
“trigger” output (L2.)
Turn the screw on the potentiometer (blue module) to tune in the level that the digital
output triggers on.
Sample code
Reads the analog and digital outputs and prints them to the serial port.
void setup() {
pinMode(DO_pin, INPUT);
Serial.begin(115200);
}
void loop() {
Serial.print(digitalRead(DO_pin));
Serial.print("-");
Serial.println(analogRead(AO_pin));
delay(5);
}
Our module has a different pinout to the bare sensor - pin 1 (S) is data signal, pin 2 is
5V power, pin 3 is GND.
Has pin 1 (marked S) (GND), pin 2 (5v power) and pin 3 (marked -) (analog signal.)
EDIT 2014/05/23 by Philips I just want to share what I have encountered as a thank you
for your providing all this information. I have these KY-013 temperature sensors too
(ordered from banggood.com). As of the date of this edit, I have discovered that my
units have the labels NOT reversed, i.e. mark S is the analog signal, and mark - is the
ground. Center pin remains as the 5V power. Hope this helps.
You can think of the 2-color LED like 2 separate LEDs (a green one and a red one) in
one package, sharing one negative lead (this lead is the cathode so these are called
'common cathode' LEDs.)
Pins are 1 (-) ground, 2 green, 3 red. There are no current limiting resistors on the
modules, you need to add resistors.
You can follow the steps for the Arduino blink tutorial. First connect the red resistor,
pin 3 (+) & 1 (-) and then once that works try to expand the sketch to also blink green
on pin 2 (+) & 1 (-).
The positive pins are numbers 1,2,3 and pin 4 Ground. There are no current limiting
resistors on the modules, you need to add resistors.
If you wire up 1 & 2 to power, pin 3 (signal) will alternate between 5V (HIGH) and 0V
(LOW) as you tilt the module.
If you connect a current limiting resistor to L2, you can use it as a blinking LED.
You might also be able to have the LED automatically blink with the sensor…
Has pin 1 (marked S) (GND), pin 2 (5v power) and pin 3 (marked -) (digital signal.)
The digital signal changes when you move a magnet close to it.
… that's what this is. My quick tests didn't reveal how it worked, though…
On the other side of the relay are screw terminals that the relay switches between when
it changes.
There are some good tips about using relays to drive higher power devices like 12V
pumps or solenoids here: http://blog.trossenrobotics.com/2012/07/27/howto-controlling-
solenoids-pumps-and-more-from-your-arduino/
Pin
Label Signal Connect To
Number
1 GND Ground
2 +5V 5V
Voltage proportional to X
3 VRx An analog input pin
position
Voltage proportional to Y
4 VRy An analog input pin
position
Shorts to ground when switch is
5 SW Joystick pushbutton
pushed
Sample Code
This code reads the switch and the position of the joystick and prints it to the Arduino
serial port.
void setup() {
pinMode(SW_pin, INPUT);
digitalWrite(SW_pin, HIGH);
Serial.begin(115200);
}
void loop() {
Serial.print(digitalRead(SW_pin));
Serial.print(" @ ");
Serial.print(analogRead(X_pin));
Serial.print("x");
Serial.println(analogRead(Y_pin));
delay(10);
}
void setup() {
pinMode(DO_pin, INPUT);
digitalWrite(DO_pin,HIGH);
Serial.begin(115200);
}
void loop() {
Serial.println(digitalRead(DO_pin));
delay(5);
}
Obstacle avoidance sensor module KY-032
There seem to be two of these, one with 4 pins and one with 3 pins. They both use an
infrared beam to detect proximity of obstacles.
4 pin version
Pin 1 is Ground, pin 2 is 5V power, pin 3 is digital output (on/off depending on the
beam), 4 is enable (don't know what it does.)
3 pin version
Pin 1 is ground, pin 2 is 5V, pin 3 is digital output (on/off depending on the beam.)