Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ACS712 Class Reference
A Hall-Effect sensor for measuring current levels in a given path. More...
#include <ACS712.h>
Public Member Functions | |
ACS712 (PinName _pin, float voltDivRatio=1, short type=5) | |
Create a hall-effect sensor of the specified type. | |
float | read () |
Read the value of the measured current in amps. | |
operator float () | |
Read the value of the measured current in amps Allows the ACS712 object to be used in a float context. |
Detailed Description
A Hall-Effect sensor for measuring current levels in a given path.
Can be used as a current detector
Example:
// Periodically read current levels in a circuit and // send output to PC terminal #include "mbed.h" #include "ACS712.h" // Connect the sensor analog output pin to mbed's AnalogIn pin ACS712 dev(p18); // Connect mbed to pc's USB port Serial pc(USBTX, USBRX); int main() { pc.printf("Sensor Log: \n\n\r"); while (1) { // Read current from sensor and output to pc terminal pc.printf("Sensor Value: %2.2f A\n\r", dev); wait(0.200); } }
Definition at line 30 of file ACS712.h.
Constructor & Destructor Documentation
ACS712 | ( | PinName | _pin, |
float | voltDivRatio = 1 , |
||
short | type = 5 |
||
) |
Create a hall-effect sensor of the specified type.
- Parameters:
-
_pin mbed AnalogIn pin where the analog output of sensor is connected voltDivRatio resistor voltage division ratio at output of the sensor type type of ACS712 sensor used
- Note:
- Supported types of sensors:
Member Function Documentation
operator float | ( | ) |
Generated on Tue Jul 12 2022 12:26:37 by
