16 in 1 Accessory Set with sensors and modules for Raspberry Pi and Arduino Microcontrollers

16 in 1 kit accessory set with sensors and modules

A whole package with sensors and modules is located behind door number 19 of the AZ advent calendar. What can you do with it? A lot. In keeping with the Advent season, search for "Santa Detector" in your trusted search engine. Describing all sensors and presenting projects for them would go beyond the scope of this short article. I will still try to go into all modules. There are already blog posts for some of them, or there are code examples in the data sheets for the individual modules in the shop. First, let's see what's in the set. I wrote you a few more comments on this right away:


KY-015 DHT 11 temperature sensor

Measures temperature and humidity; does not output any decimal places; Operating voltage 3.3V and 5V


DS1302 real-time clock (RealTimeClock, RTC)

Time is kept with a button battery without external power supply; Connection via serial interface; Operating voltage 3.3V and 5V



Flame sensor

Infrared sensor; Sensitivity for switching the digital output signal adjustable with potentiometer; Operating voltage 3.3V and 5V

HC-SR04 ultrasound

Sends an ultrasonic pulse and measures the time to the arrival of the same reflected signal, whereby the distance can be measured; Operating voltage 5V; Measuring distance 2cm - 3m; Measuring angle approx. 15 degrees;

LED traffic light

no further series resistors necessary and can therefore be used directly at the output pins; Operating voltage 3.3V and 5V

KY-038 sound sensor

Microphone for noise detection; Sensitivity for switching the output signal adjustable with potentiometer; Operating voltage 3.3V and 5V; Blog post

LDR5528 light sensor

Light Dependent Resistor; Sensitivity for switching the output signal adjustable with potentiometer; Operating voltage 3.3V and 5V

TCRT5000 line tracker

Infrared light measurement differentiates between light and dark at a very short distance; enables the implementation of a line tracing; Sensitivity for switching the output signal adjustable with potentiometer; Operating voltage 3.3V and 5V

MQ-2 gas sensor

detects LPG, i-butane, propane, methane, alcohol, hydrogen and smoke; Sensitivity for switching the digital output signal adjustable with potentiometer; digital output switches signal, analog output outputs measured values; Operating voltage 5V; Caution: the sensor is heated up!

IR obstacle detection

Detects obstacles through a reflected infrared signal; Sensitivity for switching the output signal adjustable with potentiometer; Operating voltage 3.3V and 5V

HC-SR501 motion sensor

PIR motion detector; Sensitivity and switching time adjustable with potentiometer; can also be used without a microcontroller; CAUTION: Note the pin assignment under the plastic cap - May differ from the information; Operating voltage 5V; Detection distance up to 7m; Blog post or more Blog post

433 MHz radio module

Transmitter and receiver for transmitting signals over the 433MHz frequency band; FS1000A transmitter, XY-MK-5V transmitter; Blog post

rain sensor

Analog and digital output for measured values ​​or as a switch; Sensitivity for switching the digital output signal adjustable with potentiometer; Operating voltage 3.3V and 5V; Data sheet with sample program

YL-69 soil moisture sensor

Hygrometer for measuring the level or moisture in the earth; Analog and digital output for measured values ​​or as a switch; Sensitivity for switching the digital output signal adjustable with potentiometer; Operating voltage 3.3V and 5V; Output voltage drops when the water level rises.

SW520D tilt sensor

Angle sensor; detects change of incline; works with ball switches; Operating voltage 3.3V and 5V; Sensitivity for switching the digital output signal adjustable with potentiometer;

SW420 vibration sensor

detects vibrations; works with ball switches; Operating voltage 3.3V and 5V; Sensitivity for switching the digital output signal adjustable with potentiometer;


In connection with microcontrollers (including from the previous doors of the AZ Christmas calendar) you can measure temperature, air and soil moisture, gases, water levels, vibrations, movements, light, sound, fire, distances to obstacles, record the time of day, danger levels display via traffic light signal and transfer the data to another device via radio. That is already very extensive.

Most of the modules output a digital signal like a switch when something like this is detected. How sensitive the switch reacts can be set with the potentiometer on the module. Some modules also have an analog output. If this is connected to the analog input of the microcontroller, a measured value can be recorded via the analog-digital converter. With the Nano V3.0 or Uno Microcontroller, this is the value range 0 to 1023.

Digital switches

These modules do not require any further libraries. The connection to a microcontroller is largely the same. Pay attention to the operating voltage. With a power supply of 5V you should be on the safe side. The plus pin for the power supply can be named as VDD, VCC, (+) or also as V +, the digital signal pin as OUT, D0 or S. The following circuit diagram shows how to connect the Nano V3.0 to the sensor modules that only have a digital switch output:


You can use this for the following modules:

  • Flame sensor
  • LDR light sensor
  • Line tracker
  • IR obstacle detection
  • Tilt sensor
  • Vibration sensor
  • PIR motion sensor

A short one sketch for the Arduino IDE it looks like this:

int digiPin = 4;
int LEDPin = LED_BUILTIN;

void setup () {
pinMode (digiPin, INPUT);
pinMode (LEDPin, OUTPUT);
}

void loop () {
if (digitalRead (digiPin)) {
digitalWrite (LEDPin, LOW);
  }
else {
digitalWrite (LEDPin, HIGH);
  }
}

The onboard LED on the Nano V3.0 or Uno Microcontroller is switched depending on the status of the sensor module. The digital outputs of most modules are low active, are therefore by default on HIGH and in the active state on LOW.

The vibration sensor should be programmed a little differently. You can find an example sketch in data sheet, which is also linked in the AZ shop.

Additional analog values

For the modules that also have an analog output, expand the circuit as follows:


Modules with an additional analog signal are:

  • Sound sensor
  • Gas sensor
  • rain sensor
  • Soil moisture sensor

 

Note: Some of the modules have a status LED so that the function can only be tested without programming by connecting a power supply.

We add the for reading in the analog signal Source code by one line:

int digiPin = 4;
int LEDPin = LED_BUILTIN;

void setup () {
pinMode (digiPin, INPUT);
pinMode (LEDPin, OUTPUT);
Serial.begin (115200);
}

void loop () {
if (digitalRead (digiPin)) {
digitalWrite (LEDPin, LOW);
  }
else {
digitalWrite (LEDPin, HIGH);
  }
Serial.println (analogRead (A0));
}

For the output on the monitor, open the serial monitor of the Arduino IDE (CTRL + SHIFT + M).

Note: I used a lighter to test the flame and gas sensors. Such experiments should then not be carried out by unsupervised children!

With these two simple sketches, we were able to try out 11 of the modules. For the rest you will either need a different circuit or even an additional library.

Traffic light module

This component can e.g. can be used as an optical addition to the gas or water level sensor. In the blog post on the Plant guardian it also shows how to use the three LEDs as a warning. You change the source code so that three outputs are used instead of one digital output. Then you use the analog signal as a reference and divide the value range into three parts, which in turn are assigned to one of the colors.

Model railroaders could also simply use these traffic lights for miniature road traffic. Here is the circuit diagram and an example sketch (Due to the missing Fritzing component for the traffic light, only a schematic representation here):

  • G = Green
  • Y = Yellow
  • R = Red
  • GND = Ground (ground / negative pole)

Download traffic light sketch

The switching of the traffic light phases works non-blocking. So you can e.g. add a button to switch the traffic light for pedestrians. The duration of the respective phases can be set using the values ​​of the intervals.

HC-SR04 ultrasonic sensor

For this module I would like to refer to the blog posts Simple sonar on TFT and Proximity sensor with ultrasound and servo control (automatic waste bin) from Albert Vu, in which the commissioning of the sensor is described. If you use several of these sensors, here is a note that the sound waves will interfere with each other.

433 MHz radio module

There is also a blog post for this module called What's on there? 433Mhz modules by Moritz Spranger. To do this, however, you need two microcontrollers for sending and receiving the radio signal.

DHT11 temperature and humidity sensor

For the advent calendar door number 15, I introduced you to the DHT22 sensor. It works in a very similar way. It delivers higher resolution values ​​(decimal places) and larger value ranges. The programming is otherwise the same. The DHTNEW library, which I presented there, automatically recognizes the sensor type. So you can use the same sketch or the supplied example dhtnew_minimum try. If there are problems with the library, try the SimpleDHT library from Winlin. There are explicit example sketches for the DHT11 included.

DS1302 RTC serial real-time clock module

You need a button cell battery CR2032 3V to operate this module. This ensures that the time is saved even if no external power supply is connected. The time can be set and called up with a microcontroller. This makes it possible to save the appropriate time for the sensor data, or to read out sensor data depending on the time.

in the AZ shop you can also find the module individually. The data sheet, circuit diagram and libraries for Arduino IDE and Raspberry Pi are stored there.

The module is connected as follows:


You can use the same pins on the Nano microcontroller:

RTC module

Uno / Nano MC

VCC

+ 5V

GND

GND

CLK

6

DAT

7

RST

8

I have the library in the library management of the Arduino IDE Rtc by Makuna Installed:


There are several other libraries available. When searching, make sure that the DS1302 module is supported and that, ideally, you can determine the pins yourself. It is possible here.

You can also use other RTC modules with the same library. How to program the microcontroller and some other information can be found on Github. The documentation is very good in my opinion.

An included example sketch called DS1302_Simple can serve as a basis for your own projects. Change this line there as follows:

ThreeWire myWire (6,7,8); // IO, SCLK, CE

and load the program onto the microcontroller you have selected. The serial monitor should then show which date and time were read out of your system and written to the RTC. Possible sources of error can be incorrect cabling or an empty or missing battery.

If everything works properly, the system time should be displayed at the beginning during the compilation process, and then the current date and time every 10 seconds.

Tip: If you want to display this information on an LCDisplay, look at the printDateTime() at the end of the sketch. There, a string is created, which is output at the piece. You can also output the same string on the display. Or you put the string together differently according to your own desire and then output it.

 

We wish you a happy Advent season.

Andreas Wolter

for AZ-Delivery Blog

Specials

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN