February 9, 2016

643 words 4 mins read

Arduino Basics

Arduino Basics

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It’s intended for anyone making interactive projects. Arduino senses the environment by receiving inputs from many sensors, and affects its surroundings by controlling lights, motors, and other actuators. You can tell your Arduino what to do by writing code in the Arduino programming language and using the Arduino development environment. Several Arduino-Board variants exist e.g.: UNO, NANO, MEGA, DUE, YUN, etc.

Arduino Basics:

IoT Protocols

The IoT needs standard protocols. Two of the most promising for small devices are MQTT and CoAP.

MQTT gives flexibility in communication patterns and acts purely as a pipe for binary data.

CoAP is designed for interoperability with the web.

Both MQTT & CoAP:

  • Are open standards
  • Are better suited to constrained environments .uline[than] HTTP
  • Provide mechanisms for asynchronous communication
  • Run on IP
  • Have a range of implementations

See: MQTT and CoAP, IoT Protocols


CoAP is the Constrained Application Protocol from the CoRE (Constrained Resource Environments) IETF group. Like HTTP, CoAP is a document transfer protocol. Unlike HTTP, CoAP is designed for the needs of constrained devices.

CoAP packets are much smaller than HTTP TCP flows. Bitfields and mappings from strings to integers are used extensively to save space. Packets are simple to generate and can be parsed in place without consuming extra RAM in constrained devices.

CoAP runs over UDP, not TCP. Clients and servers communicate through connectionless datagrams. Retries and reordering are implemented in the application stack. Removing the need for TCP may allow full IP networking in small microcontrollers. CoAP allows UDP broadcast and multicast to be used for addressing.

CoAP follows a client/server model. Clients make requests to servers, servers send back responses. Clients may GET, PUT, POST and DELETE resources.

CoAP is designed to interoperate with HTTP and the RESTful web at large through simple proxies.

Because CoAP is datagram based, it may be used on top of SMS and other packet based communications protocols.


MQTT is a publish/subscribe messaging protocol designed for lightweight M2M communications. It was originally developed by IBM and is now an open standard. It was designed in 1999 for use on satellites and as such is very light-weight with low bandwidth requirements making it ideal for M2M or IoT applications.

MQTT has a client/server model, where every sensor is a client and connects to a server, known as a broker, over TCP.

MQTT is message oriented. Every message is a discrete chunk of data, opaque to the broker.

Every message is published to an address, known as a topic. Clients may subscribe to multiple topics. Every client subscribed to a topic receives every message published to the topic.

The publish / subscribe (often called pub-sub) pattern lies at the heart of MQTT. It’s based around a message broker, with other nodes arranged around the broker in a star topology. This is a very different model to the standard client/server approach, and at first it might seem a little strange, but the decoupling it provides is a huge advantage in many situations.

Clients can publish or subscribe to particular topics which are somewhat like message subjects. They are used by the broker to decide who will receive a message.

Topics in MQTT have a particular syntax. They are arranged in a hierarchy using the slash character (/) as a separator, much like the path in a URL. So a temperature sensor in your kitchen might publish to a topic like sensors/temperature/home/kitchen.

See: Zoetrope


  1. Arduino - Official Site | Tutorials
  2. Guide - Getting Started | Windows
  3. Tutorials - WebClient | WebClientRepeating | EthernetBegin
  4. Playground - WebClient POST
  5. MQTT and CoAP, IoT Protocols
  6. A Brief, but Practical Introduction to the MQTT Protocol and its Application to IoT | Zoetrope
  7. Earthshine Design, Arduino Starter Kit Manual: A Complete Beginners Guide to the Arduino
comments powered by Disqus