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
- 1) Install Arduino IDE. Arduino IDE is an open source platform and it is very friendly to use. After installing the IDE, you need to choose your operation board. For Uno, you can directly to choose the Arduino/Genuino Uno board on IDE tools-> board. For ESP8266 and ESP32, there needs some configuration steps. Please refer to http://blogger.youraisemeup920616.com/2018/11/technique-how-to-install-esp32-and.html.
- 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.
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
- Extracting sensor data from Air Quality Sensor with ESP32. The codes of the air quality sensor can be used with ESP8266 and Uno. Please try it yourself.
- Using ESP8266 to extract the data from the multi-channel sensor. Through testing, the multi-channel sensor is not compatible with ESP32. But Uno works. Here we didn't give the demo with Uno, please try it yourself.
- Extracting sensor data from MQ9 Gas Sensor with ESP32. The codes of MQ9 gas sensor can directly be used with ESP8266 and Uno. Please try it yourself.
- Extracting sensor data from the temperature&humidity sensor with Arduino Uno. This library is not compatible with the ESP8266 and ESP32 board. One potential solution is to modify the source codes.
- Extracting sensor data from the Dust Sensor with ESP32. The codes of the Dust sensor can directly be used with ESP8266 and Uno. Please try it yourself.
No comments:
Post a Comment