ACS712 Current Sensing Module

The ACS712 Current Sensing module allows for the measurements of both AC and DC currents by a 5V system. The module isolates the reading digital system from the sensed current using an internal hall effect sensor. These modules come in two ranges, a ±5A and a ±30A version

/education/images/acs712_small.jpg
Click Here to View Larger Image

Features

  • Uses the ACS712 measurement IC
  • 5V Operation
  • Analog output voltage varies with measured current

Find In Store

Documentation

Quick Start with Teensy 2.0

  1. Wiring: The ACS712 module must be connected to a 5V power supply. This example will detail the wiring for a Teensy 2.0 microcontroller to the ACS712 module and a CP210x UART to USB module. For this example the CP210x module will be used to power the Teensy 2.0 at 5V after programming. In order to observe varying outputs form the ACS712 module, a variable current is required. Since these modules are rated or high amperage, please pay attention to the test system as it may become very hot and could cause a fire.
    To wire the system, connect a common ground between the CP210x module and the Teensy 2.0. Common grounds must always be used for communication systems to allow for reliable signal transfer. The Teensy 2.0 has two dedicated UART serial pins located on PORT D, pins 2 and 3. Be aware that when using UART serial, the transmit (TXD) pin of the microcontroller should be connected to the receive (RX) pin of the CP2102. The receive (RXD) of the microcontroller then goes to the transmit (TX) pin of the CP2012. Finally since the CP210x module will power the Teensy, connect the 5V pin of the CP210x to the 5V pin of the Teensy 2.0.
    To connect the ACS712 module, connect the power and ground pins as indicated. The 'OUT' pin will be connected to the Teensy 2.0 on pin F0. This is one of the internal Analog to Digital Converter (ADC) pins. The ACS712 module outputs a voltage that is proportional to the current flowing through it.

       

  2. After wiring the unit, you can download the C example code below. This code is tested to compile via avr-gcc under Windows and Linux. You may need to install the avr-gcc compiler prior to using these files. The code initializes the hardware UART on the Teensy 2.0 and transmits the value measured from PORTF, pin 0 (the ACS712 Module) repeatedly over the UART port at a baudrate of 34800. The protocol is set up for 8 data bits, no parity, and one stop bit (8N1). The output will be rather boring unless somethign that draws current is connected to the input pins of the ACS712 Module.

    ACS712 Module Teensy 2.0 Sample Code

  3. The sample code can be compiled from the command-line via the command 'make all' and downloaded to a Teensy 2.0 with the command 'make program' in windows. The Makefile does not currently support download automatically to Linux or Mac machines. If you have one of these platforms, download the loader from the Teensy 2.0 website and program the hex that way.

    Teensy Loader

  4. To be able to fully use a serial (UART) port on a computer a 'terminal program' should be employed. One suggested program for Windows based systems is Termite (Local Copy). Termite is a versatile tool allowing for display and entry of both ASCII characters and raw hex values. Additionally, most operating system installs will need to download and install a driver for the CP210x family of USB to UART devices. These can be downloaded directly from Silicon Labs or local but older versions for Windows, Mac, or Linux (3.x.x). Driver installation will vary system to system but often only involves a simple installer utility. Consult Silicon Labs support if help is needed.
    Please note in the image below, the configuration of Termite is shown for communicating with this example code. However the 'Port' setting for each computer may vary. For this example the operating system chose COM4. On many machines it may be COM1 or COM2. To find the com port to be used in Windows open the Windows 'Device Manager' and look under the 'Ports' section of the devices list.