close
KnowledgeBase

Remote Current Consumption Monitoring of Appliances using ACS712, SIM800C, Arduino Uno and Blynk

32130559_2069555103057877_4947819414666870784_n

Overview

Electric current is the flow of electric charge in a medium. Its strength depends on the potential difference and the electrical properties of the medium. Amperes (A) is the unit that measures electric current.

An electric current is classified into two types: direct and alternating. In direct current (DC), the electrons flow in one direction only, going from the positive charge to the negative charge. On the other hand, the electrons in alternating current flow in one direction, then in the opposite direction.

In this project, we will measure the alternating current flow in a particular load. To measure the current, an ACS712 current sensor is used. The gathered data will be sent to Blynk. According to its founders, Blynk is an Internet of Things platform with a drag-n-drop mobile application builder that allows the users to visualize sensor data and control electronics remotely in minutes.

Hardware Used

Software Used

  • Arduino IDE
  • Blynk mobile application (Android or iOS)

Arduino Libraries Used

  • TinyGsmClient.h
  • BlynkSimpleSIM800.h
  • SoftwareSerial.h

Application Description

This project measures the current flow across a load. In this case, a lamp is connected to the mains voltage, and the current flow is measured. Then, the obtained data is transmitted to the Blynk cloud by using the SIM800C GSM module. The user can access the data through the mobile application of Blynk.

Set-Up the Hardware

Figure 1 – Schematic Diagram

 

Figure 2 – SIM800C GSM Module Front View

Figure 3 – SIM800C GSM Module Back View

Figure 4 – ACS712 Current Sensor

Figure 1 shows the connections between the Arduino Uno, SIM800C GSM module, and the ACS712 current sensor. Furthermore, the RX and TX pins of the GSM module are connected to the assigned TX and RX pins of the Arduino Uno, respectively.

Also, it is vital to be extra cautious when connecting the ACS712 current sensor and the lamp because the lamp is connected to the mains voltage of 220V. Soldering together the connections of the lamp to the mains voltage is an important task to ensure safety when used.

Set-Up the Software

 

The code needed for this project is shown above. It is divided into five major parts. These are the declaration of variables, setup function, loop function, sendSensor() function and the getVPP() function. These five major parts of the code will be thoroughly explained below

The snippet of code shown above is the first major part of the program. This is where the variables are first initialized and the libraries are defined and declared. In this project, the program uses three libraries, These are the TinyGsmClient, BlynkSimpleSIM800, and the SoftwareSerial library.

The TinyGsmClient library is used for the SIM800C GSM module. This library contains the code needed for initializing the modem used for transmission and reception of data. On the other hand, the BlynkSimpleSIM800 library is utilized to connect the GSM module and the Blynk cloud. The Blynk is where the data is stored and accessed using its mobile application. Lastly, the SoftwareSerial library is used for serial communication. Serial communication is a type of communication wherein data is transmitted and received using a communication channel one bit at a time.

Also, the declaration of pins is found here. In this project, digital pins 2 and 3 of the Arduino Uno are used for serial communication. In addition, the analog pin A0 is utilized for the acquisition of data from the ACS712 current sensor.

Lastly, the authentication token needed to connect this project to the Blynk server is located in this part. The token is acquired through an e-mail sent by Blynk. This will be discussed in the latter parts of this tutorial.

The second major part of the code is the setup function. This function contains the framework of the code since this is where the important aspects of the code are assigned. These aspects include the baud rate, modem, and the timer. The baud rate is the speed of transmission of data in a certain communication channel. The modem is referred to as the GSM module, while the timer is used by Blynk as the clock which allows the data to be transmitted and received in a synchronous manner. In this project, the obtained data is transmitted to Blynk every 2 seconds.

The third part – and perhaps the shortest one, is the loop function. The Arduino Uno does the processes involved in the loop function repeatedly. In this project, the processes involved in the loop function are the Blynk and timer. These two processes allow the Blynk and timer to operate per reiteration of the loop function.

The fourth major part of the code is the getVPP() function. This function is used for measuring the current from the ACS712 current sensor. This is where the mathematical process of ratio and proportion is used, wherein the minimum and maximum value are compared to the acquired value from the sensor to get an approximate value of the peak-to-peak voltage. The conversion of current to voltage will be explained in the last part of the code.

The final part of the code is the sendSensor() function. This function converts the acquired data from the previous function to the appropriate data. In this project, the obtained data is the peak-to-peak voltage. Converting it to the RMS current requires a mathematical process as shown above.

Lastly, this function allows the Arduino Uno to print the converted data to Blynk using the virtualWrite() function. It is important to know that this function should not be used in the loop function, as it would cause errors in sending the data to the server. This function uses virtual pins to transmit and receive data. Virtual pins are a concept invented by Blynk to display and send data from the hardware to Blynk.

In this project, it is vital to know the fundamentals of Blynk. According to its founders, Blynk is an Internet of Things platform with a drag-n-drop mobile application builder that allows the users to visualize sensor data and control electronics remotely in minutes. The Blynk mobile application is available on Google Play Store for Android users.

The first step in incorporating Blynk into this project is to create a new file for it. The picture shown above is the menu used to create the new file. The device should be the Arduino Uno and the connection type should be the GSM module.

After creating the file, an authentication token is sent to the user’s email. The email is asked when starting the app for the first time. The token should be included in the Arduino code, as shown in the earlier parts of this tutorial.

The picture shown above displays the workspace. This is where the user can add different components to display the gathered data in a way that is visually pleasing.

To add different widgets, click the add button in the upper right corner of the screen. The picture shown above displays the different widgets and components available for data display. In this project, the gauge is used to display the data since it varies per second and it is an analog value.

The gauge is shown above. It displays the current across the lamp through the different connections and code used.

Clicking the gauge displays this menu as shown above. This is where the user can assign the virtual pin and the reading rate. In this project, the V5 is utilized as the virtual pin. Also, the reading rate is at PUSH. This means that the Arduino will constantly send data to the Blynk server. Thus, the gauge changes its value for each time the Arduino sends data to the server.

Conclusion

This project utilizes the SIM800C GSM module to send data to the Blynk server. The Internet of Things (IoT) is an easy task thanks to the founders of Blynk. Anyone can use Blynk to send and receive data in any sensor and using any connection type.

Download Links

References

 

Tags : ACacs712arduinoblynkcloudcurrentcurrent sensorGSMlampmeasurementSIM800Cuno

Leave a Response