Analog pins are used to measure sensors values. It can record a wide range of values compared to Digital pins that are just provide ON/OFF state. By conventional method, each Analog Input pin that is measured by micro controller is only allow to connected and measured from one sensor. If you need to measure values from two sensors (for example, temperature & sun light intensity), you will need to occupy 2 analog input pins at the micro controller.
NodeMCU is a very famous micro controller board with a built-in WiFi module. It is not only an affordable micro-controller, but it also can do a lot of stuff especially for Internet of Thing (IOT) application. The two most common IOT applications are smart home automation such as button-controlled loads through remote execution & monitoring. IOT is also very famous for real time sensor value online display while data-log the historical value on the web server and we can access those data whenever we want.
However, the biggest disadvantage of the NodeMCU board is that it has only one Analog pin. In other words, it only can measure from 1 sensor. If we have projects that require more than one sensor, we will need to find another micro-controller with more Analog Pins such as Arduino UNO or MEGA. But the boards normally exclude built-in WiFi module which may need an additional wiring and WiFi module.
Today we will be using another method which is using an expansion board called Analog Multiplexer Module. It is a microchip that requires 2 to 4 Digital Pins and 1 Analog Pin to convert up to 16 Analog Pins. It may sound complicated at first, but once we know how it works, it will be easy for application.
The NodeMCU micro-controller is similar to Arduino micro-controller board. It is compatible with Arduino IDE software and is built-in with the ESP8266 module which can be connected to the internet. You can grab some at our affiliate link here !!!
Node MCU Micro controller Base
The based below the Node MCU can provide more flexibility on the connection ports to support more sensors. Besides, it also has 12V input port and able to provide 5V power supply to support the sensors. Support us by purchase it from our affiliate link here !!!
16 Channel Analog Multiplexer Module
This module is an extension board that allows micro-controller to have more Analog Pins for sensor measurement. It is very important for NodeMCU as it only has one Analog Pin. Support us by grabbing one at our affiliate link here !!!
Multiplexer Module Concept
Multiplexer Module is a micro chip that requires 1 Analog Pin and 2 to 4 Digital Pins to allow the micro controller to monitor more Analog Pins for sensor readings. The requirement of 1 Analog Pin is actually the output pin shared among all the extension Analog Pins. The module only allow 1 Analog channel or sensor value to be connected to the output Analog Pin each at a time thus they take turns to operate.
To determine which Analog channel to be opened, Micro controller such as NodeMCU needs to send Binary command (a combination of ON/OFF or High/Low) over the Digital Pins to the module so that it allows the selection of the channel to be activated at the specific time. The binary command is operated by the High/Low voltage and each Analog Channel will have its own unique Binary combination. For an example, below is a 16-channel Analog Multiplexer with its Binary Command:
So for example, if we want to measure channel C15, we can program the 4 Digital Pins High (5V) output to the Multiplexer. In reality, we program the NodeMCU to rotate the output command while measuring each channel output using the same Analog Input A0. The entire process happens so fast and we can get all the 16 channel readings from the module.
Dupont line Wires
In order to connect wiring between Arduino board and module fast and easy, you need the dupont line cables. These cables are suitable during testing and troubleshoot where a lot of wire modifications. You can get it at our affiliate link here !!!
1 – SIG Analog pin to A0 of NodeMC
2 – S0 Digital pin to D0 of NodeMCU
3 – Digital pin to D1 of NodeMCU
4 – S2 Digital pin to D2 of NodeMCU
5 – S3 Digital pin to D3 of NodeMCU
6 – EN Digital pin & Ground of NodeMCU
7 – Gnd Power Supply pin to Ground of NodeMCU
8 – VCC Power Supply pin to 5V of NodeMCU base
9 – C0 to C15 will be analog input pins can be defined by user.
The standard ACS712 Current Sensor Module rated at 5A, 20A and 30A which are suitable to most applications. You may get them by our affiliate link here !!! The 5A module has the resolution of 185mV/ampere, 20A module has 100mV/ampere while 30A module has the resolution of 66mV/ampere.
Hall-Effect Split-Core Sensor HSTS016L module can measure DC and AC current ranges from 10A up to 200A. With split core current sensor type, not alteration on the existing system required. You can get it via our affiliate link here !!! The output voltage of this sensor is 2.5V +/- 0.625V with decent accuracy. I highly recommend this sensor for measuring AC current.
The final step would be adding source code onto NodeMCU board. I assume you have installed the Arduino IDE Software. If you have not installed the software, the link here can bring you to the official download site. Once you have downloaded the software, you may download the code file (.ino) for this application below (right click save link).
Before uploading the code to NodeMCU, if this is the first time you are dealing with NodeMCU, you need to add ESP8266 Support file and add NodeMCU board library into IDE software. To add ESP8266 Support file, open Arduino IDE Software, go to files>preferences>Additional Boards Manager URLs, paste this link http://arduino.esp8266.com/stable/package_esp8266com_index.json to the black space and click OK.
After finished this step, go to Tools > Boards > Boards Manager and download the ESP8266 library by ESP8266 Community
Once done, you can start download the .ino code file below and upload to the NodeMCU board. I will not display the code here because it is long. You can download the .ino file to see for your own. Almost all code lines are with explanation.
For this example, we will be using a potentiometer across each Analog Input Pins to verify the functionality of the module. This base code will be often used when NodeMCU board with more Analog Sensors are required. I will be using this method whenever more Analog Pins are required for my future NodeMCU projects.
Relay Switches Module
Relay is often important to enable micro-controller to control larger loads. More relay switches are used especially for smart home remote controlling. You may get one of those at our affiliate link here !!!
Soldering machine is a professional soldering tools that has all the accessories and controllable power source to ensure soldering with ease. Check it out at our affiliate link here for more info !!!
Before we end, we would like to give gratitude to you for taking the time to read the post. We would need readers like you to support us in order to keep growing. You can support us in the following ways :
Donate & Fund Raising
If you like my work, please send me a donation to encourage me to do more. Thanks
We are the member of Aliexpress affiliate marketing. Do support us by clicking the affiliate product links if you do wish to purchase them.
Like and Share
If you like our post, we need your support to like and share our posts or videos so that it can reach more and more people like you !!