vrijdag 9 september 2016


KY-015 37-1 Temperature and humidity sensor module (DHT11)


Connections between the Arduino for this temperature and humidity sensor from the 37in1 sensor kit with the KY-015 DHT11 module
  • Arduino pin 8 --> Pin S module
  • Arduino GND --> Pin - module
  • Arduino +5    --> Pin Middle


The temperature and humidity values are displayed on the Serial monitor (To use the Codebender Serial monitor you need to connect it !)

Serial monitor

More info

// ** Arduino KY-015 Temperature and humidity sensor module ** /* ** HARDWARE Arduino pin 8 --> Pin S module Arduino GND --> Pin - module Arduino +5 --> Pin Middle DHT11 Temperature and humidity sensor */ int DHpin = 8; byte dat [5]; byte read_data () { byte data; for (int i = 0; i < 8; i ++) { if (digitalRead (DHpin) == LOW) { while (digitalRead (DHpin) == LOW); // wait for 50us delayMicroseconds (30); // determine the duration of the high level to determine the data is '0 'or '1' if (digitalRead (DHpin) == HIGH) data |= (1 << (7 - i)); // high front and low in the post while (digitalRead (DHpin) == HIGH); // data '1 ', wait for the next one receiver } } return data; } void start_test () { digitalWrite (DHpin, LOW); // bus down, send start signal delay (30); // delay greater than 18ms, so DHT11 start signal can be detected digitalWrite (DHpin, HIGH); delayMicroseconds (40); // Wait for DHT11 response pinMode (DHpin, INPUT); while (digitalRead (DHpin) == HIGH); delayMicroseconds (80); // DHT11 response, pulled the bus 80us if (digitalRead (DHpin) == LOW); delayMicroseconds (80); // DHT11 80us after the bus pulled to start sending data for (int i = 0; i < 4; i ++) // receive temperature and humidity data, the parity bit is not considered dat[i] = read_data (); pinMode (DHpin, OUTPUT); digitalWrite (DHpin, HIGH); // send data once after releasing the bus, wait for the host to open the next Start signal } // *** SETUP *** void setup () { Serial.begin (9600); pinMode (DHpin, OUTPUT); } // *** LOOP *** void loop () { start_test (); Serial.print ("Current humdity ="); Serial.print (dat [0], DEC); // display the humidity-bit integer; Serial.print ('.'); Serial.print (dat [1], DEC); // display the humidity decimal places; Serial.println ('%'); Serial.print ("Current temperature ="); Serial.print (dat [2], DEC); // display the temperature of integer bits; Serial.print ('.'); Serial.print (dat [3], DEC); // display the temperature of decimal places; Serial.println ('C'); delay (700); }

donderdag 8 september 2016


BMP180 barometric pressure sensor tested with Arduino.
This is a sensor for air pressure and temperature. Do not connect +5V to +/VDD  of this sensor!
Sensor will be damaged!

Hardware connections

  • Vin     +3v3
  • SCL  SCL
  • SDA  SDA

Program on Codebender


// 2016 JanJeronimus copy from

/* BMP180 Absolute Pressure
Mike Grusin, SparkFun Electronics

This sketch shows how to get an absolute pressure reading from the BMP180
barometric pressure sensor. https://www.sparkfun.com/products/11824

Hardware connections:

-/GND to GND
+/VDD to 3.3V

(WARNING: do not connect +/VDD to 5V or the sensor will be damaged!)

You will also need to connect the I2C pins (SCL and SDA) to your
Arduino. The pins are different on different Arduinos:

Any Arduino pins labeled:  SDA  SCL
Uno, Redboard, Pro:        A4   A5
Mega2560, Due:             20   21
Leonardo:                   2    3

Leave the IO (VDDIO) pin unconnected. This pin is for connecting
the BMP180 to systems with lower logic levels such as 1.8V

// Include the needed libraries. The SFE_BMP180 library will need to be
// added to your arduino/libraries folder

#include <SFE_BMP180.h>
#include <Wire.h>

// You will need to create an SFE_BMP180 object, here called "pressure":

SFE_BMP180 pressure;

void setup()

  // Initialize the sensor (it is important to get calibration values stored on the device).

  if (pressure.begin())
    Serial.println("BMP180 init success");
    // Oops, something went wrong, this is usually a connection problem,
    // see the comments at the top of this sketch for the proper connections.

    Serial.println("BMP180 init fail\n\n");
    while(1); // Pause forever.
  Serial.println("deg C, deg F, abs press mbar, abs press inHg");

void loop()
  char status;
  double T,P;

  // You must first get a temperature measurement to perform a pressure reading.
  // Start a temperature measurement:
  // If request is successful, the number of ms to wait is returned.
  // If request is unsuccessful, 0 is returned.

  status = pressure.startTemperature();
  if (status != 0)
    // Wait for the measurement to complete:

    // Retrieve the completed temperature measurement:
    // Note that the measurement is stored in the variable T.
    // Function returns 1 if successful, 0 if failure.

    status = pressure.getTemperature(T);
    if (status != 0)
      // Print out the measurement:
      Serial.print(", ");
      Serial.print(", ");
      // Start a pressure measurement:
      // The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
      // If request is successful, the number of ms to wait is returned.
      // If request is unsuccessful, 0 is returned.

      status = pressure.startPressure(3);
      if (status != 0)
        // Wait for the measurement to complete:

        // Retrieve the completed pressure measurement:
        // Note that the measurement is stored in the variable P.
        // Note also that the function requires the previous temperature measurement (T).
        // (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
        // Function returns 1 if successful, 0 if failure.

        status = pressure.getPressure(P,T);
        if (status != 0)
          // Print out the measurement:
          Serial.print(", ");
        else Serial.println("error retrieving pressure measurement\n");
      else Serial.println("error starting pressure measurement\n");
    else Serial.println("error retrieving temperature measurement\n");
  else Serial.println("error starting temperature measurement\n");

  delay(1000);  // Pause for one second.


BMP180 init success
deg C, deg F, abs press mbar, abs press inHg

24.68, 76.42, 1018.39, 30.08


The barometric pressure sensor is an I2C device found at address 0x77
(You can check this using an I2C scan program https://codebender.cc/sketch:358105



woensdag 7 september 2016


Arduino KY-017 Mercury open optical module

Mercury tilt switch that allows you to detect the tilt of your object.
Module also contains a status led.
One bad thing about this module is the toxic mercury.
As long as the glass bulb is closed it will give no problems.
This module needs to be disposed as toxic waste !


  • S           Arduino Pin 3
  • middle   +5V
  • -           GND


Arduino led (Pin 13) displays tilt status.

More info


// ** Arduino KY-017 Mercury open optical module ** /* ** HARDWARE ** S Pin 3 middle +5V - GNF int buttonpin = 3; // define the mercury tilt switch sensor interface int Led = 13 ; // define LED Interface int val ; // define numeric variables val // *** SETUP *** void setup () { pinMode (Led, OUTPUT) ; // define LED as output interface pinMode (buttonpin, INPUT) ; // define the mercury tilt switch sensor output interface } // *** LOOP *** void loop () { val = digitalRead (buttonpin) ; // read the values assigned to the digital interface 3 val if (val == HIGH) // When the mercury tilt switch sensor detects a signal, LED flashes { digitalWrite (Led, HIGH); } else { digitalWrite (Led, LOW); } }

dinsdag 6 september 2016


The MQ2 gas sensor is sensible to Methane, Butane, LPG and Smoke and is the first sensor from the Arduino Gas sensor kit for Arduino that i tested.

The script below (also avalable as codebender to run immediate) is used to read the analog value (A0) and the digital signal (connected to D12)

/* 2016 MQ-2 GAS Sensor  JanJeronimus
Gets digital and analog value from gas sensor every second
Writes time [ uptime millis() ]  , 
 digital gas sensor and
 analog gas sensor value to the serial port

const int gasPinA = A0 ; //GAS sensor Analog output pin to Arduino analog A0 pin
const int gasPinD = 12; //GAS sensor Digital output pin to Arduino

int val = 0;     // variable to store the Digital read value

void setup()
pinMode(gasPinD, INPUT);
Serial.begin(9600); //Initialize serial port - 9600 bps

void loop()
Serial.print( "Time " ) ;
Serial.print( millis() ) ;
Serial.print( " , Digital " ) ;
Serial.print( val ) ;
Serial.print( " , Analog " ) ;
Serial.println( analogRead(gasPinA) );
delay(1000); // Print value every 1 sec.
To get a reliable signal a burn-in time is needed.
When using the sensor for the first time (without burn-in time) the analog signal indicates a value of 130 and in a few minutes dropping to 80 and slowly dropping more.
If opening gas from a cigarette lighter near the sensor the signal rises to +/- 340. This indicates that the sensor is working. After a few hours the analog signal has dropped to 27. If spraying some aftershave on my hand and immediate putting my hand near the sensor the signal also rises to this value. In this case it takes more time before the signals drops down again.

maandag 5 september 2016


Received a set of 9 gas sensor for Arduino from Aliexpress ( China ).
You can find a table with some details of the gas sensors in this post.
MQ-8 MQ-9 MQ-135

MQ-4 MQ-5 MQ-6

MQ-2 MQ-3 MQ-4

The  PCBs for the sensors all look the same with pins
  • A0 Analog signal
  • D0 Digital signal (treshhold controlled by pot meter)
  • GND Ground
  • VCC Power (+5V)
The PCB has a pot meter and two leds
  • Power led
  • D0 level led
The D0 level led turns on if the analog signal comes above the threshold regulated by the pot meter. 
< ThresholdLed OffD0 pin signal  1
>ThresholdLed OnD0 pin signal 0

Quick scanning the info also learned me that the MQ-7 needs alternating 60 seconds 5v, 90 seconds 1.4 volt ( http://forum.arduino.cc/index.php?topic=239693.0 ) . The hardware for all the sensors looks the same but it seem there are some differences! 
Also storage conditions (when not in use) of these sensors seem to be important.
When starting this project i expected that i could test some of these sensors and publish this the same day on my blog. After collecting some info i decided to make this a general info start article and publish the test in separated articles.

Burn-in time

Reading more information i found that also  burn-in time is needed for this sensors Some datasheets use the term "preheat", but it is the time to burn-in the sensor. This is meant to make the sensor readings more consistent. 
A time of 12 or 24 hours is usually used for the burn-in time.The Burn-in is achieved by applying normal power to the sensor (to the heater and with the 'A' and 'B' pins connected, and with a load-resistor). In some special cases a specific burn-in is needed. See the datasheet if the sensor needs such a specific burn-in.
After the "burn-in time", the heater needs to be on for about 3 minutes before the readings become stable.
The sensors that use 5V or 6V for the internal heater do get warm. They can easily get 50 or 60 degrees Celsius. If it is used in a battery operated device, a transistor or logic-level mosfet could also be used to switch the heater on and off. I also want to "burn-in" with a power supply and not with batteries
After creating the circuit it could take more than 24 hours to get the first consistent measurements. 
As details can be found in the datasheets of the sensors (Links included in the table in this article).

Test gas

To test the sensors some gasses would be needed. Some ideas to test:
Ethanol (Alcohol) 
Butane (Weed burner gas)
Gas from a cigarette lighter
Smoke ( from a fire )
Perfume / Aftershave
Car exhaust
Car fuel
Hydrogen (created by electrolysis or metal with strong acid)

My gas sensors:

MQ2Methane, Butane, LPG, Smoke Datasheet
MQ3Alcohol, Ethanol, SmokeDatasheet
MQ4Methane, CNG GasDatasheet
MQ5Liquified gas, Coal gasDatasheet
MQ6LPG, Isobutane, PropaneDatasheet
MQ7Sensitive Detector CO gas
(Needs alternating 60 seconds 5v, 90 seconds 1.4 volt)

MQ9CO, Flammable gassesDatasheet
MQ135Air quality / Hazardous gas
(Benzene, Alcohol, smoke, NH3)

Item in the first column "Sensor" will links to the "blog label" of the sensor to find all articles in this blog labeled with this sensor
"Datasheet" will link to a datasheet of the sensor.
"Tested" will updated with a link to the blog article with the test.
I hope to publish in the next blog article a small test of the MQ2 sensor!


vrijdag 2 september 2016


Tested a voice record and playback module 1820 that i want to use in a domotica project.
I provided power to the module with an Arduino.
  • Red REC button needs to be pressed to record a message ( 10 seconds max)
  • Black PLAYE button plays the recorded message (complete)
  • Black PLAYL button plays the recorded message until released.

On the module are also REC, PLAYE and PLAYL pins to use a micro-controller ( e.g. Arduino. or ESP8266  )

Both 5V and 3V3  (to use in a ESP8266 project) give reasonable voice quality however the volume is quite low.

Changing from 5V to 3V3 gives no significant difference in playback volume.
After switching the power on and off the module still can playback the recorded message.
When recording it is best to speak close to the microphone (on the PCB board.)
Especially for playback outdoor or with background noise more volume would be needed.
I had planned to make Wifi controlled voice recorder with ESP8266. However due to the low output volume i decided to not (yet) permanent create this project. Perhaps i need to add a (cheap) amplifier.

donderdag 1 september 2016

Homewizard elektrisch rolgordijn.

kwam precies na 3 dagen. De dag voor de bezorging een mail ontvangen dat pakket was overgedragen aan transporteur en de volgende dag tussen 8 en 10 een mail zou komen met bezorgtijdstip. Een mail van 8:38 ontvangen dat pakket tussen 13:04 en 15:04 bezorgd zou worden. Om 14:04 stopte een grote vrachtauto voor de deur en een paar minuten later kon het pakket met daarin het rolgordijn in ontvangst genomen worden. Een lange houten lat was langs de doos geplakt om het rolgordijn te beschermen. Het rolgordijn zat in de doos in plastic verpakt met ophangbeugeltjes, netvoeding, handleidingen en een doosje met afstandsbediening en een ophangbeugeltje voor de afstandsbediening met bijbehorende schroefjes. Het enige wat nog ontbrak waren schroeven voor het ophangen van het rolgordijn zelf. (Er moet natuurlijk wat te klagen over blijven.)
Het ophangen zelf ging iets lastiger dan verwacht. Nadat het oude rolgordijn weggehaald was gaatjes voorgeboord en ophangbeugeltjes volgens de handleiding geplaatst. Soms toch nog lastig te schroeven (vooral als er ook een boortje breekt en in het gaatje blijft zitten.) Bovendien merkte ik dat het kozijn (vooral) op de plaatsen waar ik de beugeltjes wilde schroeven niet helemaal vlak was. De maat van het rolgordijn wist ik maar van te voren weet je natuurlijk niet waar de gaatjes in de beugeltjes zitten. Een ringetje zou niet niet voldoende helpen, uiteindelijk een paar moertjes als afstandhouders misbruikt om voldoende ruimte te hebben dat het rolgordijn in de beugeltjes kon klikken.
Geprobeerd in mijn eentje het gordijn in de beugeltjes te klikken. Dat lukte dus helemaal niet.
Volgens de handleiding moet het rolgordijn tegen de onderkant van de bevestigingsclips gedrukt worden zodat deze in het profile valt. Daarna bovenkant omhoog duwen tot deze vastklikt. De achterkant waar de beugeltjes in moeten klikken goed bekeken met een los beugeltje. Het blijkt dat dis dus helemaal niet gaat. Wel kan het beugeltje omgedraaid worden en dan kan je het er wel in klikken. Dus beugeltjes op de muur omgedraaid en dan zitten ze net te hoog tegen het plafond waardoor het rolgordijn kantelen om er in te hangen niet lukt. Dus beugeltjes uiteindelijk iets lager geplaatst en dan gaat het wel.
Voor gebruik moet motor eerst opgeladen worden. De adapter blijkt rood licht te geven als teken dat de accu nog niet voldoende opgeladen is. Volgens handleiding opladen tot groen. Na tijdje geen rood meer maar blauw licht. (Groen heb ik nog niet gezien.)
Dan de afstandbediening koppelen met het rolgordijn. Achterop zit gaatje met knopje P2. Bij het koppelen van de afstandbediening met het rolgordijn een kleine schroevendraaier gebruikt om het in te drukken. Koppelen ging goed en ook het daarna instellen van hoogste en laagste stand. Ook nog een voorkeur stand volgens de handleiding toegevoegd.
Daarna afstandsbediening koppelen met de Homewizard. Was even puzzelen om te ontdekken dat op de Homewizard het rolgordijn als “Zonweringen & gordijnen” - “Brel” moest worden aangemeld. Hierbij een een pen gebruikt om P2 achter op de afstandsbediening in te drukken. Echter het knopje blijkbaar wat scheef ingedrukt waardoor het onder het gaatje schoof en P2 altijd ingedrukt bleef! Dit was niet dus de bedoeling. Batterij verwijderd en knopje weer voorzichtig terug geschoven....
Uiteindelijk functioneert dit mooie (maar helaas prijzige) systeem naar tevredenheid !


Homewizard shop elektrisch rolgordijn