Atmel Software Framework Tutorial – ARM Cortex

An Atmel Software Framework Tutorial series that shows how to use Atmel Software Framework (ASF) to program ARM Cortex microcontrollers using Atmel Studio and the C programming language.

About ASF

Atmel Software Framework (ASF) consists of a number of modules that can be added to a C language project in Atmel Studio. Adding ASF modules to a project makes various functions available for initializing and using hardware and software services, cutting down development time.

As an example, adding the IOPORT ASF module to a project allows pins and ports of a microcontroller to be initialized and accessed using functions from the IOPORT module. Functions from the IOPORT module can then be called to set up pins or ports as inputs or outputs and other functions allow the pins or ports to be read or written to without having to use the hardware at a register level.

Atmel Software Framework Tutorial Contents

The ASF tutorial series consists of the following parts thus far. More parts are being added to the tutorial series each week.


Introduces the Atmel software framework tutorial and shows how ASF is structured.


How to create a new ASF project for an Atmel Evaluation board. The example project blinks the on-board LED.


How to create an ASF user board project. If you are going to use ASF on your own custom or user board, you will need to know how to write ASF user board projects from scratch. This type of project can still be created and tested on an Atmel evaluation board. Most of this tutorial series shows how to create various projects from scratch using an ASF user board project as this is what is needed in real world applications that use a custom board.


How to add ASF to an existing project that was not started as an ASF project.


There are slight differences between ASF projects created for Atmel evaluation boards and user board ASF projects. This part of the tutorial shows the differences between the project types such as which files are different and where to changes settings in the files.


How to enable the on-chip oscillators of the microcontroller to use the external crystals instead of the internal R/C oscillators in ASF.


A quick start checklist for creating new ASF user board projects. Where to add code and to change settings in a new ASF project.


Using ASF functions to read and write individual microcontroller pins used for general purpose input/output.


How to write to a microcontroller port or group of pins from a port using ASF functions.


Reading and writing a port or group of port pins rather than individual port pins.


How to configure C standard input/output functions such as printf() and scanf() to use a UART for input/output.

Further Parts of the Tutorial Series

Further parts will be added to the tutorial series until it is complete. Check the index and menu of the tutorial for additional parts.

Arduino Internet Voltage Monitoring

Arduino Internet voltage monitoring can be achieved in several ways. The Arduino can be set up as a client or a server in order to display measured voltage on a web page. In this article an Arduino is set up as web server that hosts a web page stored on SD card. The web page displays the voltage measured on Arduino analog pin A2 in near real-time. The web server also interacts with ThingSpeak, a Internet of Things (IoT) service which logs voltage over time. Voltage is displayed on the hosted web page on a gauge and in a ThingSpeak generated graph or chart.

Arduino Internet Voltage Monitoring

Arduino Internet Voltage Monitoring

How Arduino Internet Voltage Monitoring Works in this Project

The Arduino web server hosts a web page that communicates with the Arduino using JavaScript / Ajax. This allows the voltage to be sent from the Arduino to the web page over the Ethernet connection to update the voltage in the gauge on the web page. A potentiometer is used to vary the voltage on Arduino pin A2 between 0 and 5 volts.

The raw value from the Arduino analog input is sent to the web page and converted to voltage in the JavaScript that runs on the page. The raw analog value is also displayed on the web page and will be between 0 and 1023.

After the voltage is calculated, it is sent to ThingSpeak by JavaScript. ThingSpeak logs the voltage and plots the graph of the voltage. The graph in the above image is created by copying graph code from ThingSpeak which then updates the graph with the data from the ThingSpeak server.

Voltage Update Timing

Voltage is measured by the Arduino and updated on the web page every 200ms. ThingSpeak only updates graph or chart values every 15s (fastest update speed), so the JavaScript code only sends updates to the ThingSpeak server every 20s.

Tutorial for the Project and Other Resources

A full tutorial is available which explains how to set up this project on your own Arduino.

Learn how ThingSpeak works and how to set up a channel to send data from an Arduino to an account on the ThingSpeak server — ThingSpeak is a free service.

Learn about measuring voltage with Arduino.

Arduino Ethernet shield tutorial explains how to set up an Arduino and Ethernet shield as a web server.



How to Plot Sensor Data to a Graph over the Internet with Arduino

Getting sensor data from an Arduino and sending it over the Internet to display the data in a graph can be a rather challenging task. This task is made extremely easy when using a IoT (Internet of Things) web service instead of setting up the Arduino to host a web page that contains the sensor data graph. Any Arduino board that has Ethernet on it or any Arduino board with an Ethernet shield can be used to make an Arduino Internet graph.

Arduino Internet Graph

An Arduino Internet graph can easily be made by using the ThingSpeak platform to do all the hard work like capturing the sensor data and plotting it to a graph. The image below shows Arduino analog pin A0 voltage plotted on a graph that is displayed in an account on the ThingSpeak website.

Arduino Internet Graph

Arduino Internet Graph










How it Works

A ThingSpeak library is installed in the Arduino IDE using the Arduino library manager. The library provides functions that can be used to communicate with the ThingSpeak web server.

A free account can be opened on the ThingSpeak website which allows channels to be created. Data from the Arduino, which can be sensor data, voltage, or any other data, can then be sent to the channel and plotted on a graph at the website. Each channel can have up to eight fields, enabling data from up to eight sensors to be sent over one channel.

When using ThingSpeak, no SD card is needed and the Arduino and Ethernet shield or other Arduino board that has Internet capabilities is set up as a client rather than a server. No special Internet router settings need to be made when the Arduino is used as an Internet client, making setup and use very easy.

Arduino Internet Graph Plotting Tutorial

A full tutorial on how to plot sensor data over the Internet with Arduino is available in the article Logging Data and Displaying Graphs over the Internet with Arduino.


Display Text on Arduino LCD from Web Page

The tutorial on how to send text from a web page to an Arduino LCD sets the Arduino, Ethernet shield and micro SD card up as a web server with LCD attached. Two HTML text inputs allow text to be sent to each line of the LCD from the web page hosted by the Arduino.

The image below shows the web page in a web browser that has sent text to the LCD.

Sending Text from a Web Page to Arduino LCD

Sending Text from a Web Page to Arduino LCD

Text is sent to the Arduino from the web browser over the network with an HTTP GET request when the button on the web page is clicked.

Go to the tutorial now →

Arduino MEGA Ethernet Web Server for Controlling 24 Outputs

In this tutorial, an Arduino MEGA 2560 and Ethernet shield are used to make a web server that hosts a web page that allows 24 outputs to be controlled using checkboxes. The tutorial on the Arduino MEGA web server contains the circuit diagram and all of the source code for the project.

This tutorial was written to answer a question on the blog about the Arduino web server tutorial.

An image of the web server with the web page used to control 24 LEDs is shown below.

24 Output Arduino MEGA Web Server using the Ethernet Shield

24 Output Arduino MEGA Web Server using the Ethernet Shield