page_type | languages | products | name | urlFragment | extendedZipContent | description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
Azure Sphere – ADC |
ADC |
|
Demonstrates how to do analog-to-digital conversion on the MT3620 high-level core. |
This sample application demonstrates how to do analog-to-digital conversion in a high-level application.
The application samples and displays the output from a simple variable voltage source once per second. It uses the MT3620 analog-to-digital converter (ADC) to sample the voltage.
The sample uses the following Azure Sphere libraries.
Library | Purpose |
---|---|
adc | Manages the analog-to-digital converters (ADCs). |
eventloop | Invokes handlers for timer events. |
log | Displays messages in the Device Output window during debugging. |
File/folder | Description |
---|---|
app_manifest.json |
Application manifest file, which describes the resources. |
CMakeLists.txt |
CMake configuration file, which Contains the project information and is required for all builds. |
CMakePresets.json |
CMake presets file, which contains the information to configure the CMake project. |
launch.vs.json |
JSON file that tells Visual Studio how to deploy and debug the application. |
LICENSE.txt |
The license for this sample application. |
main.c |
Main C source code file. |
README.md |
This README file. |
.vscode |
Folder containing the JSON files that configure Visual Studio Code for deploying and debugging the application. |
HardwareDefinitions |
Folder containing the hardware definition files for various Azure Sphere boards. |
The sample requires the following hardware:
-
An Azure Sphere development board that supports the Sample Appliance hardware requirements.
Note: By default, the sample targets the Reference Development Board design, which is implemented by the Seeed Studios MT3620 Development Board. To build the sample for different Azure Sphere hardware, change the value of the TARGET_HARDWARE variable in the
CMakeLists.txt
file. For detailed instructions, see the Hardware Definitions README file.
- Ensure that your Azure Sphere device is connected to your computer, and your computer is connected to the internet.
- Ensure that you have Azure Sphere SDK version 24.03 or above. At the command prompt, run
az sphere show-sdk-version
to check. Upgrade the Azure Sphere SDK for Windows or Linux as needed. - Ensure that the Azure CLI is installed. At a minimum, the Azure CLI version must be 2.45.0 or later.
- Install the Azure Sphere extension.
- Enable application development, if you have not already done so, by entering the
az sphere device enable-development
command at the command prompt. - Clone the Azure Sphere samples repository and find the ADC_HighLevelApp sample in the ADC folder or download the zip file from the Microsoft samples browser.
- Connect MT3620 dev board pin H2.2 (GND) to an outer terminal of the potentiometer.
- Connect both pin 1 and pin 2 of jumper J1 to the other outer terminal of the potentiometer. This connects the MT3620 2.5 V output to the ADC VREF pin and to the potentiometer.
- Connect MT3620 dev board pin H2.11 (GPIO41 / ADC0) to the center terminal of the potentiometer.
To build and run this sample, follow the instructions in Build a sample application.
The ADC output is displayed in the output terminal or Device Output window during debugging. Adjust the potentiometer and observe that the displayed value changes, as shown in the following example output.
Show output from: Device Output
The out sample value is 2.500 V
The out sample value is 2.483 V
The out sample value is 2.337 V
The out sample value is 2.055 V
- For an overview of Azure Sphere, see What is Azure Sphere.
- To learn more about Azure Sphere application development, see Overview of Azure Sphere applications.
- To learn more about how to interact with an ADC peripheral by using the simplified Azure Sphere functions or the advanced Linux IOCTLs, see the ADC code snippets.
- For information about using ADCs, see Use ADCs in high-level applications.