Skip to main content

An Introduction To Squirrel Applications

A Series Of Examples Designed To Grow Your Knowledge Of The Electric Imp Platform

An Introduction To Squirrel Applications is intended to help developers quickly become masters of Electric Imp application development. It comprises a sequence of working examples which demonstrate features, functionality, concepts and techniques, and which range from simple to advanced applications. What you learn in a given example builds on the skills learned in the previous example until you have a solid working knowledge of how to assemble production-ready Electric Imp applications.

The examples start with the assumption that you have only a basic familiarity with the Electric Imp Platform — that you have completed the Getting Started Guide to learn how to create an Electric Imp account, to configure your development device with Electric Imp’s BlinkUp™ technology, to use the Electric Imp IDE, impCentral™, and to discover the two-part nature of Electric Imp applications: device-side code and cloud-hosted agent code.

If you are new to the Electric Imp Platform and have not completed the Getting Started Guide, we strongly recommend that you do so now. It should certainly be the first project you attempt after receiving your first Electric Imp development device.

Please note that the first few examples here are not intended to be power efficient and will drain battery powered devices quickly.

The Basics

Example 1 — Reading A Sensor

Begin by learning the basics of programming Electric Imp applications. We will use Electric Imp’s HTS221 library to take temperature and humidity readings from a sensor. We will also use the Initial State library to send the data we collect from the sensor to the cloud.

Go to the Example

Beginner Applications

Example 2 — Simple Refrigerator Monitor

In this example we will create an simple refrigerator monitoring application that takes synchronous readings from a temperature/humidity sensor and the internal light sensor. The light reading is used to determine if the refrigerator door is open or closed. The door status, temperature and humidity readings are sent to the cloud using the Initial State cloud service. We will use a Hardware Abstraction Layer (HAL) to reference all hardware objects. We will use a class to organize our application code.

Go to the Example

Example 3 — Simple Remote Monitoring Application

In this example we will create an simple remote monitoring application that takes synchronous readings from multiple sensors and sends them to the cloud using the Initial State cloud service. We will use a Hardware Abstraction Layer (HAL) to reference all hardware objects. We will use a class to organize our application code.

Go to the Example

Intermediate Applications

Example 4 — Refrigerator Monitor

In this example we will create a remote monitoring application that takes asynchronous sensor readings using Electric Imp’s Promise library. We will conserve power by turning off the WiFi or disconnecting from the cellular network, and taking readings while offline. We then connect periodically to send the readings we have collected.

Go to the Example

Example 5 — Asynchronous Remote Monitoring Application

In this example we will create a remote monitoring application that takes asynchronous sensor readings using Electric Imp’s Promise library. We will conserve power by turning off the WiFi or disconnecting from the cellular network, and taking readings while offline. We then connect periodically to send the readings we have collected.

Go to the Example

Advanced Applications

Example 6 — Power Efficient Remote Monitoring Application

In this example we will create a remote monitoring application that takes asynchronous sensor readings using Electric Imp’s Promise library. We will conserve power by putting the device to sleep between readings and connecting periodically to send the readings we have collected.

Go to the Example

Example 7 — Remote Monitoring Application With An Interrupt

In this example we will create a remote monitoring application that takes asynchronous sensor readings using Electric Imp’s Promise library and detects freefall events. We will conserve power by putting the device to sleep between readings. The device will connect periodically to send readings and will also wake and connect if a freefall is detected.

Go to the Example

Example 8 — Power Efficient Refrigerator Monitor

In this example we will create a refrigerator monitoring application. The application monitors the temperature and humidity of the refrigerator and sends alerts if the temperature or humidity is higher than a set threshold for too long. The application also monitors the refrigerator door using the accelerometer to wake on motion and the internal light sensor to determine the door status. The application saves power by sleeping between readings when the door is closed, and only connecting to WiFi or the cellular network periodically to upload readings or when an alert is triggered.

Go to the Example

Example 9 — Adding Further Cloud Services To The Simple Remote Monitoring Application

In this example we will use the device code from example 3, but adapt the agent code to send data to an additional cloud service, IBM Watson IoT.

Go to the Example