ThingSpeak IoT Blog

Building a Dynamic and Self-organizing Network of Devices


Anders Sollander, a principal technical consultant at MathWorks, and his team put together a project to determine what demo was the most popular at one of our demo showcases. Anders made an assumption that if your demo was popular, you would have a lot of visitors. If you have a lot of visitors, your demo would be the loudest.

Anders was determined to measure sound from over 20 demo stations at the same time and figure out who the the winner is. This turns out to be a complicated challenge and he used our tools such as MATLAB, Simulink, and ThingSpeak, to produce some interesting results. Here’s what the raw data looks like from just five sound sensor nodes at the demo stations.

The sensor nodes uses the Arduino Nano devices because they’re small, low-cost, and Simulink has an Arduino support package. Arduino Nano’s both low cost and energy efficient which is great, but it doesn’t have Wi-Fi. They connect the sensor nodes to an Internet-connected Raspberry Pi using an RF mesh network with the nRF24l01+ radio. The RF24 solution is both very cheap and energy efficient, which is valuable if you’re running them with battery power. Simulink Coder has a Raspberry Pi Support Package which simplified the workflow.

When you follow the tutorial, you are going to learn many things and experience their analytic workflow as they decide how to develop an algorithm to normalize sound levels, determine which data to send to ThingSpeak, and build visualizations to see the results of the project.

Anders also shared a library on File Exchange that allows users to communicate with RF24 chips on Raspberry Pi and Arduino boards. The library relies on the RF24Mesh library, and has S-functions that interact with the classes there. The File Exchange submission includes an example for the Arduino to read sensor data from a temperature sensor and sends it to the gateway Raspberry Pi and then sends the data to ThingSpeak. In order to download the File Exchange, you need to sign in with your MathWorks account. This would be the same account that you use on ThingSpeak.com.

Visit ThingSpeak Tutorials, to see the complete tutorial for Building a Dynamic and Self-organizing Network of Devices.

Cadmus Collects and Analyzes IoT Data Using MATLAB and ThingSpeak


The Internet of Things (IoT) enables power producers, public utilities, and other companies in the energy sector to collect energy power consumption data from hundreds of factories and thousands of homes in near real time. This wealth of information has opened opportunities to evaluate energy efficiency initiatives, predict power demand, and perform energy audits.

Consulting firm Cadmus provides full-spectrum energy-efficiency support services to energy utilities throughout North America. These services include studies of energy use that require extensive data collection and analysis.

To make the most of the opportunities presented by the IoT, Cadmus engineers used MATLAB® and the ThingSpeak™ IoT platform to develop a workflow for collecting, storing, analyzing, visualizing, and interpreting data from sensors in homes and businesses distributed across wide geographic areas.

“In just a few months, we implemented a new service that measures and analyzes temperature and humidity changes in dozens—and soon hundreds—of homes,” says Dave Korn, vice president of engineering at Cadmus. “Without MATLAB and ThingSpeak, we would still just be talking about it. Instead, we’re already pitching this service to utilities. That is a huge competitive advantage for our company.”

Solution

Cadmus used MATLAB and ThingSpeak to develop and deploy two systems of cloud-connected sensors for the near-real-time measurement and analysis of energy data, while establishing a workflow for rapidly implementing similar systems.

The first system, designed for an energy efficiency study of residential homes, used custom sensors to send temperature, relative humidity, and device battery voltage measurements to ThingSpeak every five minutes. The second, designed to monitor loads of HVAC systems and large appliances, used off-the-shelf home automation hardware to send power usage data, captured at residential circuit breakers and individual outlets, every minute.

Using the ThingSpeak web application, the engineers created new channels to collect data from the sensors and to quickly verify that each new sensor added to the system was reliably sending data.

Working in MATLAB, the team analyzed the collected data, using standard statistical techniques to identify outliers and calculate means and standard deviations. For example, they calculated and plotted power load profiles by the hour and correlated the load data with weather data from an outside source.

They created a variety of data visualizations, including interactive maps, which they shared with clients and prospects.

Cadmus engineers are currently using MATLAB and Statistics and Machine Learning Toolbox™ to develop predictive algorithms based on machine learning and advanced classification and regression techniques. These algorithms are designed to predict and model load based on weather conditions and sensor data collected via ThingSpeak.

Results

  • Market opportunity seized. “In our industry, many utilities are looking to design better energy efficiency programs and to lower the costs of those programs,” says Korn. “MATLAB and ThingSpeak enabled us to develop solutions rapidly, which meant we could capitalize on these demands this fall. Without MATLAB and ThingSpeak we would have had to wait until spring and miss numerous opportunities in the market.”
  • Development effort cut by two-thirds. “With MATLAB and ThingSpeak, our team of five engineers was collecting and analyzing data in a matter of months. We could not have met our deadlines without them,” says James Kennedy, energy analyst at Cadmus. “With other tools we would probably have needed 15 engineers to complete the work in the same time amount of time—if we could have done it at all.”
  • Sensor networks quickly deployed. “On our first project with ThingSpeak, it took just over three months to implement a network that we quickly scaled from 50 operational sensors to 500,” says Kennedy. “In a very short period we had another complete network set up and collecting data, and that one was deployed at an even faster rate than the first.”

Create a GPS Tracker with MATLAB Mobile and ThingSpeak


Takuji Fukumoto, an Application Engineer at MathWorks, shared a project with me that he created that uses capabilities of MATLAB Mobile™, MATLAB Drive™, MATLAB Online™, and ThingSpeak™. His project uses MATLAB Mobile to send its position and sensor data to ThingSpeak. He then uses MATLAB® to process the data and generate maps of his position.

You might have noticed recently on ThingSpeak that you can link your ThingSpeak user account to a MathWorks Account. By doing so, you have access to other MathWorks products and services that you can use with the same user account. MATLAB Mobile is a native Apple or Android app that allows you to evaluate MATLAB commands, create and edit files, view results, acquire data from sensors, and visualize data. MATLAB Mobile also has thingSpeakRead and thingSpeakWrite functions built-in. One exciting aspects of MATLAB Mobile is that you can capture the sensor data of the mobile device and send it to MATLAB Online.

To take the project further, you can use additional toolboxes from MathWorks to preprocess the data and do advanced mapping. Takuji demonstrates using the Signal Processing Toolbox™ to filter, down sample, and remove outliers from the incoming data from the MATLAB Mobile sensors. Using the Mapping Toolbox™, he plots the latitude and longitude of his mobile device on a WPS map and displays the map on a ThingSpeak channel.

Takuji has shared all of the source code and steps on File Exchange so you can replicate this project on your own mobile device. Check out his project on File Exchange and see his raw data and visualizations on ThingSpeak.

Use MQTT to Send IoT Data to ThingSpeak


MQTT is a common protocol used in IoT systems to connect low-level devices and sensors. MQTT is used to pass short messages to and from a broker. ThingSpeak has recently added an MQTT broker so devices can send messages to ThingSpeak. A message might contain the current temperature in an office collected by a sensor. ThingSpeak takes the message and stores its content in a ThingSpeak channel. Once the data is in a channel, you can easily visualize and analyze the data with MATLAB code.

The ThingSpeak MQTT broker is available now to all ThingSpeak users!

To help users get started using MQTT to send data to ThingSpeak, we have created some examples for common devices and applications that support MQTT.

If your device or application is not able to use MQTT directly, we have also enabled WebSockets. Using MQTT over WebSockets allows devices to use the MQTT protocol to send messages behind a firewall. We also support secure sockets to encrypt the messages that are being sent to ThingSpeak.

To learn how to use MQTT with ThingSpeak, please review our documentation. Let us know what you build with this new capability.

ThingSpeak Adds Paid Options to Its IoT Analytics Service


ThingSpeak has experienced tremendous growth over the past 6 years and we continue to add new users from all over the world who are building amazing IoT projects that use ThingSpeak and MATLAB.

As the ThingSpeak user community grows, we have been hearing requests for sending many millions of messages to ThingSpeak, connecting more devices, and building scalable commercial solutions. To address these requests, we are releasing new paid options for ThingSpeak. For more information, see the How to Buy page and the ThingSpeak licensing FAQ.

ThingSpeak users can continue to send up to 3 million messages per year for free (about 8200 messages per day). That satisfies the needs of 99.5% of the user community. To determine how many messages you are using, you can login and look at your account usage.

ThingSpeak IoT Analytics Platform