💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# Tutorial 1 DIY Gas Monitor with open source hardware -Particles Label: DIY Gas Monitor --- We have paid attention to air quality for many years, and there have been many tutorials for DIY Monitor. However, they are all limited to professional fields, and all for specific applications, with Arduino, nodemcu or openwrt which are changed from time to time. So that it is difficult for non-professionals to follow. This year, we get an good idea and are going to make DIY monitor to an open source project with a set of standard hardware and a universal firmware to support different sensors. Firmware is open on github so that experts can help upgrade it together. Meanwhile, non-professionals can also DIY monitors step by step with the tutorials. If you're professnals, you can go to see the source code on GitHub , and we would appreciate it if you could help with new sensor support. github address:[https://github.com/lewei50/NodeMCU-AirMonitor][1] If you are non-professionals, just follow the following steps. > Note: the biggest difference between this open source project and the previous DIY tutorial is the use of a suite of hardware and a firmware to support different gas sensors. Then, the ideal situation is whatever the gas index you want to test, as long as the sensor is supported by the firmware of the project, just buy it and directly plug it in. ## Main Content & Target People ### Main Content To DIY a simple particle monitor with 4 hardware bought online. Please see the following picture. ![1](http://upload-images.jianshu.io/upload_images/5862021-fd0adf822ce6e443.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ### Target People All people who are interested in gas monitor (with no professional limitations). ## Procedures This paper will mainly introduce the following main procedures. 1. Prepare Hardware 1 Nodemcu integrated with IIC OLED development board (will be used evertime later); 1 PM5003 sensor (used in this tutorial, and later each tutorial will use other sensors) ; 1 Adapter board which could connect pm5003 with nodemcu (used in this tutorial, and later tutorial will use other sensor modules). 2. Flash Software It belongs to the essentia skill, and please refer to the following chapter. It will be used in all the later tutorials. 3. Connect Wires It belongs to the essentia skill, and please refer to the following chapter. It will be used in all the later tutorials. 4. Web Configure (optional) Next, we will introduce them step by step. ## Work 1 Prepare hardware The hardware is divided into two categories. One is basic hardware, which should be used in each tutorial, mainly including main control unit, display unit and network unit. One is the sensor hardware, including particle sensors, formaldehyde sensors, carbon dioxide sensors and so on. Different sensors will be used in different tutorials. > In fact, what we have to do is simple, which is to flash the firmware into the basic hardware (to flash the software), and then connect the basic hardware to the sensor. Oview of hardware used in this tutorial, including 4 things altogether: ![2](http://upload-images.jianshu.io/upload_images/5862021-6d3bbaa4b8ffd830.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ### Basic Hardware **The basic hardware is very important in the project and will be used in every tutorial**。 After repeated consideration, we decided to use nodemcu (on 8266) as the control unit and network unit of this open source project, IIC OLED as display unit. Fortunately, some people have integrated nodemcu and OLED together, as shown below. ![3](http://upload-images.jianshu.io/upload_images/5862021-721fdd31d37cf981.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) Recommend Address: [NODEMCU+IICOLED][5] Note that the pin must be soldered properly. ### Sensor The hardware in each tutorial will be different. This tutorial is to teach you how to test particles, so we choose PM5003 as the sensor. ![4](http://upload-images.jianshu.io/upload_images/5862021-cf2786f0ab1185cc.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) Recommend TB address: [PM5003 G5][6] ### Auxiliary Hardware In order to connect the basic hardware to the sensor, some other basic hardware is needed, which will be used in all tutorials. Such as: Double head DuPont line: ![5](http://upload-images.jianshu.io/upload_images/5862021-98c46acfcf987aaf.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) Adapter board for 1.27 plug (plug of PM5003) to 2.54 plug ![6](http://upload-images.jianshu.io/upload_images/5862021-91df0a7a10f513a0.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) There are now many adapter boards for PM5003 to choose from. Here we use DeviceBit adapter board. You can also connect the wires by yourself without adapter board as you like. Recommend TB address: [G5 Adapter board][7] ## Work 2:flash software This is an essential skill and will be used in all of the following tutorials, which will bring you lifelong benefit. This tutorial will introduce how to flash software to nodemcu, refering to the article published in SMZDM by @WEI. Download the latest 4M bin on github: [BIN](https://github.com/lewei50/NodeMCU-AirMonitor/blob/master/ESP8266_SENSOR_DETECTOR.bin) ![7点击download进行下载](http://upload-images.jianshu.io/upload_images/5862021-6ed8e82981863cdf.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) Download the flash tool: [http://pan.baidu.com/s/1qX7EFxi](http://pan.baidu.com/s/1qX7EFxi) Then, use USB line to connect nodemcu with the computer. Normally, at this moment, there will be a notice to ask you install the driver. Usually the driver will be installed automatically , and if there is no automatic installation, please use the driver wizard or other tools to install. Open the flash tool, select the bin you just downloaded. Pay attention to the content in the square frame. The first circle, select the bin file you just downloaded. The second circle, find the COM number according to the driver just installed. ![8](http://upload-images.jianshu.io/upload_images/5862021-83a10437c0b72655.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) Flash bin: When the above configuration is done, hold down the 'FLASH' button on the NODEMCU board, click on the 'START' on the software, press 'RST' again, and when the software is displayed ![9](http://upload-images.jianshu.io/upload_images/5862021-173a0e57e62f8ba6.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) The process will take about 5 minutes, as the progress bar shows. ![10](http://upload-images.jianshu.io/upload_images/5862021-7bb486d604527172.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) When the download is complete, it will be displayed: ![11](http://upload-images.jianshu.io/upload_images/5862021-8cf03be810ea826f.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) After the firmware download is complete, restart the nodemcu and on the screen the following will be shown: ![12](http://upload-images.jianshu.io/upload_images/5862021-8549861c65c29dc2.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ## Work 3: Wire Connection This is also an essential skill and will be used in all of the following tutorials, which will bring you lifelong benefit. Wire connection is a problem for non-professionals. A lot of people can only connect the wire with the tutorial. If there is a little difference, they do not know what to do. In fact, the wire connection is very simple, that is, to provide a reasonable working power (220V, 12V, 5V) to the equipment (circuit boards) , and then connect the right communications interfaces. For this tutorial, the nodemcu+OLED board gets power from the USB line, and then supply 5V power to the particle sensor PM5003. The nodmcu communication pin TX should be connected with PM5003 RX. Connection mode: Nodemcu 5V – Adapter board 5V NodeMcu GND – Adapter board GND NodeMcu SET – Adapter board D4 (Start and stop pms5003) NodeMcu RX – Adapter board TX Using adapter board will make wire connection easier. The specific process is as follows. Nodemcu connected with G5 (5003): first connect the adapter board with G5. ![13](http://upload-images.jianshu.io/upload_images/5862021-2f3b7d750895a945.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) Then connect the Nodemcu and the adapter board with DuPont lines, and pay attention to the positions in the red frames of the following two pictures. ![14](http://upload-images.jianshu.io/upload_images/5862021-9de8e8f94deac861.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![15](http://upload-images.jianshu.io/upload_images/5862021-3d2c09fe8bae5806.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) Overview of all the hardware after wire connection: ![16](http://upload-images.jianshu.io/upload_images/5862021-38c4baa91b72e08d.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) Once power up, the local readings will appear immediately on the LCD screen: ![17](http://upload-images.jianshu.io/upload_images/5862021-2e782d26a970bf44.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) **Theoretically, you can already see the value of the particles on the OLED through previous work, but if you want to see data changesvia WeChat, you can see the following section.** ## Work 4:Monitor online In fact, another original intention for this tutorial is to hope that more people can get the sensor data + approximate location published. Everyone can send the particle data on particle map [Particle Map][9]。 Two steps: 1 Sign up an account on DeviceBit, 2 connect the device with the router so that the data can be sent online. ### Sign up 1 Sign up an account on DeviceBit: [DeviceBit](http://www.devicebit.com/) ![18] 2 Add a new device after login: Click on "My Devices" ->"Devices"->"Add a device", fill in the ID, select the template, tick public, and so on as the following picture shows. At last click on "Save". Note: make sure to select the right template. This time, we should select : "Temperature&Humidity+pm5003 devicebit". The ID you should remember, such as "01" used this time, for it will be used in the later steps. It will be used for GATEWAY later in web configuration. Fill in your favorite name, tick public (so that everyone can see your data online), and then click on Save. ![19](http://upload-images.jianshu.io/upload_images/5862021-eb71d27a614f2778.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) Click on your city on the map (so that everyone can see your data on the map). ![20](http://upload-images.jianshu.io/upload_images/5862021-951375e5b55cd03d.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 3 Go to "My Account"->"Account Settings" to find a USERKEY which would be used in later WiFi configuration. ![21](http://upload-images.jianshu.io/upload_images/5862021-c4de24ec027b7ad9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ### WiFi Configuration 4 Next, we should do WiFi configuration. First hold down the flash key on nodemcu for more than 3 seconds. When the following appear on the OLED screen: ![22](http://upload-images.jianshu.io/upload_images/5862021-45062c1120c64726.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) you can start to configure. Turn on your cell phone, find WIFI and connect: SSID for WIFI of nodemcu is ESP8266_XXXXX. WIFI password: 12345678 Fill in the SSID and the correct password you can access. Enter the address in the browser: 192.168.4.1 The gateway in the picture is the ID "01" of your device above. Fill in your USERSKY. ![23](http://upload-images.jianshu.io/upload_images/5862021-a8d5b6a4070dd92b.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) After saving, if all of these are correct, the ESP8266_XXXXX of this SSID will automatically disappear. It will appear again when there is no Internet connection. That is to say, if you want to change a WIFI connection, then turn off the WIFI that it is connecting and reconfigure it. Go back to DeviceBit, and in a few minutes you'll be able to see the updated data: ![24](http://upload-images.jianshu.io/upload_images/5862021-fc9409c43e55fd6e.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) If you log in to the user center with your cell phone and go to "My Devices", click on "Details", ![25](http://upload-images.jianshu.io/upload_images/5862021-aaa2403b0d2724c3.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) You can see the page below: ![26](http://upload-images.jianshu.io/upload_images/5862021-e8e9675ec260a015.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![27](http://upload-images.jianshu.io/upload_images/5862021-58ce71e455d4ef3f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ### nodemcu particle map If you make your data public and set the location, then visit: [http://ug25.lewei50.com/st/index/9](http://ug25.lewei50.com/st/index/9) ![28](http://upload-images.jianshu.io/upload_images/5862021-400f6ee4c07559a7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) You can see your device on the map: ![29](http://upload-images.jianshu.io/upload_images/5862021-2c27b08eea742a9c.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ## Preview In fact, through this tutorial, if you've learned how to flash software and how to connect wires, then you will almost have no more difficult with the following tutorials. The next tutorial will support data for formaldehyde, temperature and humidity. Coming soon。 For more content, welcome to DeviceBit. ![乐为物联微信公众号][10] [1]: https://github.com/lewei50/NodeMCU-AirMonitor [2]: http://static.zybuluo.com/guanvee/skfnm38umaot5vugm65i3ilm/ug25-xjme-20170620-3.jpg [3]: http://static.zybuluo.com/guanvee/k2n9ovj54y5aex6mweol55d6/ug25-xjme-20170620-1.jpg [4]: http://doc-resources.lewei50.com/lewei50/img/ug25-lewei50-20170517-5.jpg [5]: https://item.taobao.com/item.htm?spm=a1z09.2.0.0.iODwel&id=544594366154&_u=k1jno1fi3480 [6]: https://item.taobao.com/item.htm?ft=t&spm=2013.1.20141001.2.Viodw3&id=543308079843&scm=1007.12144.81309.42296_0&pvid=d999de7c-0620-4118-8fd9-2ecb1f002547 [7]: https://item.taobao.com/item.htm?spm=a230r.1.14.23.dbjfrn&id=551869736605&ns=1&abbucket=3#detail [8]: http://static.zybuluo.com/guanvee/3eeotew3bf5o7ko1l1u6jx6t/ug25-xjme-20170620-2.jpg [9]: http://ug25.lewei50.com/st/index/9 [10]: http://doc-resources.lewei50.com/lewei50/img/lewei50-20170604-4.jpg