Monday 19 November 2018

[Tutorial] How to extract the data from sensors using three different MCUs (Uno,ESP8266 and ESP32) With Arduino IDE

1. Introduction

Arduino Uno, ESP8266 and ESP32 are three very prevalent MCUs. Uno is the most used and documented board of the whole Arduino family which is based on the ATmega328P. It is very friendly to use but there are no built-in wireless modules. ESP8266 is one kind of NodeMCU, which is also an open source IoT platform. The firmware of ESP8266 is based on the ESP-12 module. Compared to the Arduino Uno, it is equipped with the ESP8266 Wi-Fi SoC from Espressif Systems which supports WiFi wireless communication. ESP32 is another board also based on the ESP module. The size of ESP8266 and ESP32 is similar and it is smaller than Uno. Compared to ESP8266, ESP32 has WiFi modules and Bluetooth Low Energy module. That strengthens the wireless communication ability of MCUs. 
So, in this lab, we will have a close at these three different MCUs and learn to how to use them to extract the data from external sensors. Here we provide some air quality sensors including the air quality sensor, the dust sensor, the gas sensor (MQ-9), the temperature&humidity sensor and the multi-channel sensor. The details of these air quality sensors please refer to the links.

2. Operation Process

  • 2) Basic knowledge for the communication between MCUs and air quality sensors. The wire connection between a MCU and a sensor is realized by General Purpose Input Output (GPIO) pins on the board. The external sensor inputs its data to the MCU via the GPIO pin whose mode is INPUT. This communication way is also based on the I2C or SPI protocol but simplified. Most of air monitoring sensors support this way. 
Related image
For example, the figure shown above is a typical external sensor. The pins on it are generally four: VCC to connect power (3V3 or 5V); GND to connect GND; A* means analog output; D* means digtal output. As the output of sensor data is analog (the digital output is also possible), we only need to connect the other three pin for except the D*.  Sometimes, the labels on the sensor are a little different like, SIG (analog output), NC(no connection), VCC and GND. this is easier to see. 
  • 3) Set the pin mode. As said above, we need to let the analog output pin of an external sensor connect the pin of MCU whose mode should be INPUT. Here are two choices for us, one is directly to use analog pins; the other is to use digital pins but to reset their mode, using pinMode(pin_number, INPUT).   
  • 4) The communication of some devices is properly different, as the multi-channel gas sensor (shown below). The labels of pins are GND, VCC, SDA and SCL. SDA and SCL mean it is based on I2C protocol. The reason why it uses I2C is in this sensor, there are 8 air detection modules that output the data at the same time. For this case, we just need to connect SDA and SCL pins on the external sensor with the corresponding pins on MCU. Besides, you can skip the step 3).     

3. Demos

No comments:

Post a Comment

[Research] Recurrent Neural Network (RNN)

1. Introduction As we all know, forward neural networks (FNN) have no connection between neurons in the same layer or in cross layers. Th...