Skip to content
shein318 edited this page Nov 22, 2015 · 30 revisions

Selection of the Hardware

The University has a lot of Hardware given to realize our project idea. At the beginning of our project we decided to analyse the temperature, the humidity, the noise and the air quality and control a window. So we need sensors and actors.

The following Sensors are available:


The following Acuator are available at:

  • Servo: SG90 Stepping motor

But to control and analyse physical options, we firstly have to choose a micro controller, that supports the sensors and actors.

The following Microcontroller are available at our university:

At the beginning we are open minded and decide to test both boards. We discount the development of new drivers.

Pysical Size Peripherie Communication
Temperature MPL3115A2 I2C
Humidity SEN0114 ADC
Sound LMV324 Sparkfun Sound detector ADC
Air Quality MQ_135 Gas Sensor ADC
Window DVRobot GPS Receiver UART

As you can see, we need at least I2C, ADC and UART to get the sensors working.

The Atmel board isn't well supported by RIOT. There is no support for the sensors and actors. At the beginning we try to program it by ourselves. But it is hard to find information which registers has to be set and it takes lot of time.
As opposed to this the Phytec board is very well supported by RIOT. The communication methods are implemented for this board. Additional the implementation the board has a couple of sensors (picture above). So we need lesser space.

We prepare a small comparision that shows the actual support of RIOT for the two boards:

Communication Atmel samr21-xpro Phytec PBA-D-01 PhyWave
I2C - X
ADC - X
UART - X

As you can see the Phytec is much easier to use for our project. We decide to develope our solution with the phytec board.


Implementation using phyWAVE-A-Eval-Board with equipped phyWAVE-KW22 processor

As shown below the using of the Phytec board has at the moment a couple of advantages. We can use the pressure sensor MPL 3115A2 to measure the temperature and the humidity sensor hdc 1000 to measure if it is rainy. The drivers for the two sensors are already implemented in RIOT. So we only have to include them in our project.

You can find the drivers in your RIOT Directory:

$(RIOTBASE)/tests/driver_hdc1000
$(RIOTBASE)/tests/driver_mpl3115a2

We copy the code and add it to our main.c .

We add the following lines to our Makefile.c :

FEATURES_REQUIRED = periph_i2c

USEMODULE += mpl3115a2
USEMODULE += hdc1000

ifneq (,$(TEST_MPL3115A2_I2C))
  CFLAGS += -DTEST_MPL3115A2_I2C=$(TEST_MPL3115A2_I2C)
else
  CFLAGS += -DTEST_MPL3115A2_I2C=I2C_0
endif
ifneq (,$(TEST_MPL3115A2_ADDR))
  CFLAGS += -DTEST_MPL3115A2_ADDR=$(TEST_MPL3115A2_ADDR)
else
  CFLAGS += -DTEST_MPL3115A2_ADDR=0x60
endif

ifneq (,$(TEST_HDC1000_I2C))
  CFLAGS += -DTEST_HDC1000_I2C=$(TEST_HDC1000_I2C)
else
  # set random default
  CFLAGS += -DTEST_HDC1000_I2C=I2C_0
endif
ifneq (,$(TEST_HDC1000_ADDR))
  CFLAGS += -DTEST_HDC1000_ADDR=$(TEST_HDC1000_ADDR)
else
  # set random default
  CFLAGS += -DTEST_HDC1000_ADDR=0x43
endif

After that you can compile the code with gcc and you get the temperatur, pressure and humidity.

For measuring the sound and the air quality we use an external sensors. The sensors return an analog signal which has to be converted into an digital value. For the conversion from analog into digital and reverse the Phytec board has special pins. We connect the output of both sensors to the board. We use the "envelope" output of the sound sensor an the "aout" output of the air quality sensor. The envelope output traces the amplitude of the sound. It is simpler to use this completed output as program it by your own. Additionally we connect the power supply of the board to the sensors.
When the sensors are connected to the board, we can begin to include the drivers for the ADC. It is already implemented in RIOT, too.

It can be found under:

$(RIOTBASE)/tests/periph_adc

We add the copy the code and add it to our main.c . Additionally we add the following lines to our existing Makefile.c :

FEATURES_REQUIRED = periph_adc

When you want to use float data you have to add the following line into the Makefile.c :

LINKFLAGS += -u _printf_float

After adding the function printf shows float data.

After compiling and flashing the digital outputs are shown on the shell. We calibrate the sound detector using complex mathematically methods. The digital output is calculated into Dezibel.

At least we have to import the SG90 stepping motor to control our window. The driver is implemented in RIOT, too.
You can find the code, here:

$(RIOTBASE)/tests/driver_server

We copy it and add it to our main.c . Additionally we add the following line to our Makefile.c :

USEMODULE += servo

After compiling and flashing the servo can be used.