Tag Archives: SAM D21 Xplained Pro

Building a realtime temperature sensor with Atmel and PubNub


PubNub’s Bhavana Srinivas demonstrates how to build a realtime temperature sensor with PubNub and Atmel.


With the buzzword being Internet of Things (IoT), PubNub recently wanted to build something simple, yet powerful, that could extend beyond the hackerspace and be applied to the real world. It had to combine software and hardware, and allow people at home to build it and try it themselves.

Arduino came to mind, but seeing as though the team has already written a great deal of realtime tutorials using the Arduino board, they sought out to try something a bit different. Instead, the group decided upon employing Atmel | SMART SAM D21 Xplained Pro and PubNub to devise a realtime temperature sensor.

Project Overview

The Atmel temperature sensor monitors temperatures and streams the data to a live-updating dashboard, in realtime, anywhere in the world. The temperature sensor measures the ambient temperature and publishes it as a data stream to a channel via the PubNub Data Stream Network. A web browser that subscribes to this channel displays the data stream on a live visualization dashboard.

The Concept

demofunctionality

  • The Atmel I/O1 Xplained Pro sensor measures the ambient temperature.
  • This connects to the Wi-Fi using the ATWINC1500 module.
  • The PubNub code running on the Atmel chip enabled the team to publish the temperature in realtime to anyone subscribing to the same channel as a data stream.
  • Through the PubNub Developer Console, you can receive this stream of information from as many sensors as you like in realtime.

What Will You Need?

Hardware

components-1024x576

Software

  • Windows PC
  • To get your unique pub/sub keys, you’ll first need to sign up for a PubNub account. Once you sign up, you can get your unique PubNub keys in the PubNub Developer Dashboard. PubNub’s free Sandbox tier should give you all the bandwidth you need to build and test your messaging app with the web messaging API.
  • Install Atmel Studio 6.2
  • Install updates to Atmel Studio as suggested during installation
  • Install terminal software like putty or teraterm

A prerequisite is that you upgrade the firmware for SAMD21 using the .bat file provided with the PubNub Atmel example before you run this demo. Make sure no other software like putty or teraterm is using the com port). Close Atmel Studio and the putty terminal. The firmware upgrade is successful if you see a PASS sign on the terminal after running the code.

Connecting the Hardware, the Right Way

atmel1-1024x576

  • Connect WINC1500 XPRO board to SAMD21 XPRO connector EXT1
  • Connect I/O1 XPRO board to SAMD21 XPRO connector EXT2
  • Connect OLED1 XPRO board to SAMD21 XPRO connector EXT3
  • Connect SAMD21 XPRO to a free USB port on your PC (make sure no other USB port on your PC is in use)
  • Connect the power to the port that says “DEBUG USB”

The Software

Open the PubNub example: pubnubAtmel/PubNub_EXAMPLE.atsln (included in the code download) in Atmel Studio and you will see the following page. Make sure you choose the debugger/programmer and interface as shown below.

opening-1024x576

Include the following lines in pubnubAtmel/src/main.h:

123
#define TEST_MODE_SSID “Enter-your-SSID” (choose THE Wi-Fi access point you want the chip to connect to)
#define TEST_MODE_PASSWORD “Enter-the password-for-the-SSID” (enter the password for the same Wi-Fi connection)
#define TEST_MODE_WITHOUT_PROVISION

In pubnubAtmel/src/main.c, add the channel name and pub, sub keys.

channel-1

Build (F7 / Build -> build solution), run(continue/ green arrow/ F5/ debug -> continue).

build

Open PubNub Developer Console, use the same channel name and pub,sub keys as in the code and SUBSCRIBE.If all is well, you should see a constant stream of messages in the following format: {“columns”:[[“temperature”,”55.00″]]}

fullsetup

From there, the PubNub crew was able to collect and stream temperature data in realtime. But what’s next, you ask? Well, they needed to do something with that data, right? Visualize it!

Visualizing the Data Stream

xplained_pro_demo_gif

Bhavana and the PubNub bunch didn’t just want to display raw data off the sensor as a live-updating number; instead, their partner-in-crime Tomomi built the beautiful temperature visualization, which mocks nursery or greenhouse monitor (a typical realworld use case for realtime temperature sensors).

The interface runs in the browser, and the technology behind is quite simple, using PubNub JavaScript APIs to subscribe the data sent from the Atmel chip. It’s simple, lightweight, built entirely in JavaScript, and accessible from anywhere in the world with any kind of device – mobile phones, tablets, and any smart device, as long as you have a web browser. The main purpose behind this is to present information in most efficient manner without losing its accuracy.

In this scenario, the UI shows the current temperature, also a simple line graph, updating in realtime so that you can tell the relative changes of the temperature, raising and dropping. This particular data is simple, but when you have multiple, more complicated data, data visualization plays more crucial role.

Go Conquer IoT

This demo is read-only and reads the ambient temperature, but in reality, you want to develop products that lets your users monitor and control, i.e, bidirectional communication between devices. For instance, if you have a smart A/C, not only monitoring the current room temperature, but you need to make it controllable from a remote devices.

“With the power of PubNub APIs, you can achieve this with no hassle. I hope I am leaving you guys with enough excitement to try this demo out, and also build cooler ones,” Bhavana concludes.

In the meantime, be sure to follow our friends at PubNub and Bhavana Srinivas on Twitter!

Turning on a lamp via the Internet the Big Bang Theory way


A team of Atmel Norway engineers decided to make their own rendition of the Big Bang Theory Internet-controlled lamp scene. (Yes, even Sheldon Cooper would approve of this one.) 


How many of you are fans of the CBS hit sitcom series, Big Bang Theory? Well, you’re in luck. If you recall an episode from the show’s first season, entitled “The Cooper-Hofstadter Polarization,” the team of Sheldon Cooper, Leonard Hofstadter, Howard Wolowitz and Raj Koothrappali successfully turned on a lamp via the Internet using an X-10 system.

To do so, the gang sent signals across the web and around the world from their apartment to connect not only their lights, but other electronics like their stereo and remote control cars as well.

“Gentlemen, I am now about to send a signal from this laptop through our local ISP racing down fiber optic cable at the of light to San Francisco bouncing off a satellite in geosynchronous orbit to Lisbon, Portugal, where the data packets will be handed off to submerged transatlantic cables terminating in Halifax, Nova Scotia and transferred across the continent via microwave relays back to our ISP and the external receiver attached to this…lamp,”  Wolowitz excitedly prefaced.

800px-X10_1

What’s funny is, the technology that the group of sitcom scientists was simulating could have just as well been done using a Wi-Fi network controller, like the WINC1500 module. However, at the time of airing back in March of 2008, open access for Internet users looking to control “things” around the house was seemingly something only engineers and super geeks thought possible.

In an effort to generate awareness around the upcoming IoT Secure Hello World training series, a team of Atmel Norway engineers decided to make their own rendition of the Big Bang Theory lamp scene using the ATWINC1500 IEEE 802.11b/g/n network controller and an Atmel | SMART SAM D21 Xplained Pro board, all secured by Atmel CryptoAuthentication devices.

After watching the Trondheim-based crew’s Cooper-Hofstadter IoT experiment above, be sure to check out a detailed description of the technology behind the project and learn more about the IoT Secure Hello World Tech on Tour seminar below.

The Internet of Things and energy conservation

Humans are creative, and adaptive. We’ve done it all our lives, and all our existence. We needed more food, and so we created agriculture. We needed to live together, and so we created architecture. We needed to communicate, and so we created hundreds of ways to do just that; Internet, mobile telephone networks, computers. We are so fond of computers that we have them everywhere, often without noticing them. Yes, you might have a bulky desktop computer at home, or maybe even a flashy new laptop, but those are not the only computers. Your mobile telephone is a computer, but technically, so is your microwave, your car, your television set, and even your washing machine.

Our lives have changed greatly. We’ve all seen pictures and even films of medieval castles, and we know how we used to live. Today, our lives are made more comfortable by scores of machines; when was the last time you washed your clothes by hand? The clothes go in the washing machine, then in the dryer, and then in the cupboard. This all comes at a cost; financially, of course, but also in terms of energy.

Energy. The art of creating electrical power and delivering it to our homes and cities. For most people, this is as simple as having overhead power lines here and there, and paying a bill at the end of the month. Unfortunately, it is much more complicated than that. Power stations require scores of people to operate, and something surprising, data. In France, we have “too many” power stations, and most run at low capacity. When it gets hot, those who have air conditioning like to put it on, consuming electricity. Multiply that by a few thousand, and you get an idea of how much energy the power station needs to produce. When it gets cold, people like to heat their homes and businesses, and since everyone has radiators, electrical consumption soars. Imagine the amount of radiators an entire city can contain, and imagine even 50% of them turned on at the same time. Imagine.

Data is needed from other sources, not just from the weather. Imagine the amount of power required to let all the football fans watch the world cup. Our problem is that we can generate electricity, but we cannot store it (at least, not on this kind of scale). When everything gets turned on, the power station must be able to respond. If it can’t, bad things happen; the lights dim, or sometimes everything goes dark. We now know we cannot live without electricity.

SMART Energy Flow

We all know that we need to reduce our energy dependence, even if some of us don’t want to. To make more people aware, some cities turn off all the lights for an hour. It’s called Earth Hour. For one hour, people are encouraged to use as little electricity as possible; turning off the lights, for example. This does have an impact, but it is a double-edged sword. For one hour, the electricity usage drops considerably, while everyone thinks about the planet, and what we will leave behind for our children. At the end of the hour, everything goes back on, and this is where things get tricky. When electrical devices are first turned on, some can generate what is called an energy spike; a large consumption at first, before something more stable. It is visible just after Earth Hour, but it actually happens every day.

Building Appliances and Home Systems using Energy at Optimum Times

Peak hours. In my house, my electric water heater is connected to a peak-hour detection system. At 11:30 PM, my electricity provider starts “off-peak” hours, a time where electricity costs less. It costs less, an incentive to make me use power-hungry devices at a time when other devices are not needed. At this time of night, most businesses are closed, and so there is less demand. It is all about normalizing energy requirements, and to stop peaks during the day. At 7:30 AM, peak hours start, the water heater turns off, businesses start up, and my kettle turns on, the day is about to begin.

Ikea-kitchen_IoT-SMART-HOME-Connected

Energy is available, that isn’t the problem. Our problem is our use of energy. If only we had a way of using energy when it was available. Imagine, a certain amount of energy available. When I need light, I want my light to be usable immediately. I need a start time; now. However, when I put my clothes in the washing machine generally, I need them to be ready for the next day. I need and “end” time; I need the device to get the work done before a certain time. When will the washing machine start? Well, I don’t actually mind when it starts, and this is where I need help. This is where the IoT can help us, because we really need help.

The IoT will give us millions of connected sensors. This will also supply us with data, lots and lots of it. Why wouldn’t a small device in my house have direct control over my washing machine, or even better, actually be inside my washing machine? It could be programmed to start at a specific time, talking to other devices on the energy grid? Or even in my home; it could tell the water heater to wait until it has finished, and then the water heater gets its chance. The possibilities are endless.

Washing Machine is Connected - SMART HOME

IoT will give us an incredible amount of data, and data that can be used to help up control, and maybe even overcome our need to energy. But wait a minute, doesn’t the IoT itself need energy? It does, but the amount of energy that it will save outweighs the amount of energy it uses, and by a large factor. Take, for example, Atmel’s SAM D21 microcontroller. It uses less than 70µA per MHz, and that is when it is running at full speed. Of course, these devices have advanced power management, and with careful coding, they can last for months on cell batteries. Low power does not mean no power; it has enough flex to get the job done, and more. With built-in USB, ADCs, DACs and enough RAM and ROM for the most complex programs, it gets the job done. It also has the Atmel Event system, a powerful system that lets the microcontroller react to external events without the need to constantly look at inputs.

(Source CES 2014 - Samsung's Vision of the Now and Future of Connected Appliances)

We need a little help in our lives to make simple decisions; when should I turn the heating on? When is the best time to turn on the air conditioner? We think we know, but we don’t. IoT will allow us to know exactly when the cold weather is coming. IoT will know when to turn the lights off. In short, IoT will generate enough data that it will know better than us what to do, and when. What we have seen so far is only the beginning.

Atmel expands SAM D Cortex M0+ MCU portfolio

Atmel has expanded its low-power ARM Cortex M0+-based MCU portfolio with three new families: the SAM D21, D10 and D11. These entry-level, low-power MCUs are packed with high-end features including Atmel’s Event System, SERCOM module, peripheral touch controller and a full-speed USB interface.

“As more devices are becoming smarter and connected in this era of the Internet of Things (IoT), designers are looking for MCUs with additional connectivity and communication options to scale their applications in the consumer, industrial and medical markets,” explained Patrick Sullivan, Vice President of Marketing, Microcontroller Business Unit, Atmel Corporation.

“Atmel’s new SAM D21, D10 and  D11 families of Cortex M0+-based MCUs deliver low-power consumption, connectivity and small footprint, providing designers just the right price-to-performance ratio. These new families expand the company’s growing line of Atmel Smart microcontrollers with new pin and memory combinations, along with new features such as DMA and crystal-less USB.”

samd2tools
As we’ve previously discussed on Bits & Pieces, Atmel’s SAM D portfolio is architected beyond the core, leveraging over two decades of MCU experience to create unique, connected peripherals that are easy-to-use, while providing scalability and performance. Indeed, to help simplify the design process and eliminate the need for additional components, Atmel’s new SAM D lineup integrates additional functionality, including full-speed crystal-less USB, DMA, I2S, timers/counters for control applications, along with several other new features. Atmel’s SAM D devices are also code- and pin-compatible making it easy for designers to migrate up and down the family.

“Atmel’s expanded portfolio of low-power SAM D family ARM Cortex-M0+-based devices enables more designers to deliver smart devices in this increasingly connected world,” said Noel Hurley, Deputy General Manager, CPU Group, ARM.

“The ARM Cortex-M0+ processor is a highly area- and energy-efficient core which enables partners, such as Atmel, to provide the right peripheral set, intelligence, communication and memory for their customers’ needs.”

Key  SAM D21 features include:

  • 48MHz operation
2.14 Coremark/MHz
  • Single-cycle IO access
  • 
6- to 12-channel Event System
  • 
6- to 12-channel DMA
  • Up to six SERCOM modules configurable as UART/USART, SPI, I2C
  • 12Mbps USB 2.0 device with an embedded host and device
  • 
Two-channel I2S with 96MHz fractional PLL for audio streaming
  • Up to five 16-bit timers, up to three 16-bit times optimized for control applications
  • Peripheral touch controller supports up to 256 touch channels for capacitive touch buttons, sliders, wheels and proximity sensing
  • 
Down to 70uA/MHz in active mode
  • 4uA RAM retention
  • Real-time clock and calendar
  • 
Option to choose between internal and external oscillators, on-the-fly clock switching
  • 
Sleepwalking

To help accelerate the design process, the $39 SAM D21 Xplained Pro is equipped with an embedded debugger/programmer and offers support for a wide range of compatible extensions boards. Standalone programmer debugger solutions supporting the SAM D family are also available from both Atmel and third parties, with the Atmel SAM D MCUs fully supported by Atmel Studio and Atmel Software Framework.

The SAM D21 is the first family in this expanded portfolio, and samples and tools are available today with volume production in May 2014. The SAM D21 is offered in 32KB to 256KB of Flash and in 32-, 48- and 64-pin packages. Meanwhile, the SAM D10 and D11 families will be available in 14- and 20-pin SOIC and 24-pin QFN packages with up to 16KB of Flash. Both memory options feature 4KB of SRAM. All package options minimize the number of power pins to maximize the amount of IO available for the application. Engineering samples and tools are slated to go live in Q2 2014.