Arduino class | input-output devices

Equipment | Software

Arduino board, Breadboard, USB cable, wire harness, LEDs or sensors, resistors Arduino IDE software

First steps with Arduino | principle and procedure of design

Arduino is one of the most common controllers that allow prototyping various electronic devices, the small board like a microcomputer with number of contacts. It is possible to connect with it motors, LEDs, sensors and everything that works by electricity. The final prototypes-devices can be assembled using Arduino board, wires, resistors, special sensors or LEDs. The sensor has 4 outputs – power, data output, unused and GND (ground). A resistor should be between the power and data outputs. After assembling all components according to the specified scheme, you need to connect the Arduino with the computer by USB and open the ‘Arduino IDE’ program. Then it is necessary to wright the cipher (sketch) there for the device ‘working’ (glow of sensors LEDs). So, it is possible to create different unique gadgets just using simple Arduino platform. However, you cannot avoid mistakes during design process – sometimes you able to connect wires with wrong contacts or by wrong ends. It is also important to turn off the USB before creating of sketch.



Arduino for the city ​​project | air humidity sensor

It should be noted that it is possible to program and research various processes such as temperature and humidity of air with Arduino. The micro steam engine and water generator were chosen as city project things examples. The aim of the project is water smart use, the possibilities and saving of this resource. For example, steam engine will absorb excess steam (in bathroom after shower or in the kitchen during cooking) and condense it back as water. Based on the HPP design principle, this element is also capable of steam energy into electrical energy converting and accumulating it with the integrated battery. The device will be checked in places with fast steam streams – above the boiling water in a pot, in a kettle, as well as in places with high humidity. Utility of the device can be evaluated by measuring the air humidity with input-output Arduino’s technology before and after processes. The special humidity sensor DHT11 or DHT-22, 33 and 44 should be used. The last ones differ by a higher level of accuracy and range of measurements. For example, DHT11 determines humidity in the range of 20-80% and temperature until 50°, while DHT22 determines humidity in the range 0-100% and temperature until 125° C. The choice depends on the location where the numbers are evaluated and situation.

It was chosen the DHT11 complex sensor in the plastic box with three outputs, which are numbered from the left to the right, if you look at the sensor body from the grate side and ‘feet’ down. It was necessary to connect the pins to Arduino Uno according to the following diagram: DHT11 sensor 1 2 4 Arduino Genuino 101 + 5V 2 GND Looking at the diagram and website’s picture prototype the device.  When the sensor was connected, the controller was programming. It was necessary to open the Arduino IDE program and checked if the device drivers were installed (install if did not) and installed there the DTH sensor library from adafruit as well. Downloaded it into the Arduino IDE, installed the board (Arduino Genuino 101) through the board manager and checked the port (COM5).  
The diagram was:

A sketch shows how the library can be used to read the sensor:
//   FILE:  dht11_test1.pde
// PURPOSE: DHT11 library test sketch for Arduino

//Celsius to Fahrenheit conversion
double Fahrenheit(double celsius)
	return 1.8 * celsius + 32;

// fast integer version with rounding
//int Celcius2Fahrenheit(int celcius)
//  return (celsius * 18 + 5)/10 + 32;

//Celsius to Kelvin conversion
double Kelvin(double celsius)
	return celsius + 273.15;

// dewPoint function NOAA
// reference (1) :
// reference (2) :
double dewPoint(double celsius, double humidity)
	// (1) Saturation Vapor Pressure = ESGG(T)
	double RATIO = 373.15 / (273.15 + celsius);
	double RHS = -7.90298 * (RATIO - 1);
	RHS += 5.02808 * log10(RATIO);
	RHS += -1.3816e-7 * (pow(10, (11.344 * (1 - 1/RATIO ))) - 1) ;
	RHS += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO - 1))) - 1) ;
	RHS += log10(1013.246);

        // factor -3 is to adjust units - Vapor Pressure SVP * humidity
	double VP = pow(10, RHS - 3) * humidity;

        // (2) DEWPOINT = F(Vapor Pressure)
	double T = log(VP/0.61078);   // temp var
	return (241.88 * T) / (17.558 - T);

// delta max = 0.6544 wrt dewPoint()
// 6.9 x faster than dewPoint()
// reference:
double dewPointFast(double celsius, double humidity)
	double a = 17.271;
	double b = 237.7;
	double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
	double Td = (b * temp) / (a - temp);
	return Td;

#include <dht11.h>

dht11 DHT11;

#define DHT11PIN 2

void setup()
  Serial.println("DHT11 TEST PROGRAM ");
  Serial.print("LIBRARY VERSION: ");

void loop()

  int chk =;

  Serial.print("Read sensor: ");
  switch (chk)
    case DHTLIB_OK: 
		Serial.println("Checksum error"); 
		Serial.println("Time out error"); 
		Serial.println("Unknown error"); 

  Serial.print("Humidity (%): ");
  Serial.println((float)DHT11.humidity, 2);

  Serial.print("Temperature (°C): ");
  Serial.println((float)DHT11.temperature, 2);

  Serial.print("Temperature (°F): ");
  Serial.println(Fahrenheit(DHT11.temperature), 2);

  Serial.print("Temperature (°K): ");
  Serial.println(Kelvin(DHT11.temperature), 2);

  Serial.print("Dew Point (°C): ");
  Serial.println(dewPoint(DHT11.temperature, DHT11.humidity));

  Serial.print("Dew PointFast (°C): ");
  Serial.println(dewPointFast(DHT11.temperature, DHT11.humidity));


Finally, loading the sketch into the controller (in Tools / Serial Monitor) it is possible to see the indicators of temperature and humidity. Temperature was 24C, and humidity was 19% in the Shukhov lab. If the device was moved to the street, these indicators would be changed accordingly. It can be checked even by breathing as breathing increases the humidity. So, after humidity measuring before and after using the device at home and comparing the results, it is possible to make conclusions about the city project success.

Many thanks to Ivan Mitrofanov for supervising and to colleagues for funny atmosphere during the work

Tags: , , ,

Trackback from your site.

address: 20 Myasnitskaya ulitsa
(metro stations ‘Lubyanka’ and ‘Kitay-Gorod’)
Moscow 101000 Russia

phone: +7(495)772-95-90 *15026