I am working on a project that uses the Arduino MKR1000 with ThingSpeak. While working on my code, I uploaded a bad sketch to the MKR1000. Every time that the board powers up, it starts running my bad code over and over and appears to be stuck in an infinite loop. I tried pressing the reset button, unplugging the USB cable, reboot my computer, reinstalling drivers, and unplugging the USB cable (for good measure). Nothing made the board responsive again. I found a forum post talking about the bootloader. The user mentioned that quickly pressing the reset button twice put the device into a good state by loading the bootloader. Success!
I shared my latest project over on my Nursery Hacks website. It combines some of my favorite things… IoT, CheerLights, ThingSpeak, Particle, and building things for my soon-to-be-here son’s nursery. I didn’t want a bright light in the nursery, but I did want to build a little CheerLights display for something in the background.
I found a Robot Nightlight on Amazon and purchased it. This little robot is a great night-light and you can change the color using the included infrared remote control. To connect this light to CheerLights, I built an IR controller that is internet-connected using the Particle Photon. The Photon subscribes to the latest CheerLights color on ThingSpeak and transmits the IR code as if the button was pressed on the remote control.
To build your own CheerLights Robot, visit Nursery Hacks for the parts and code.
Oh, my. I am sure you have been hearing about the Internet of Things… The IoT! You might be wondering how to get started with i(o)t. There are many places to start. You might be interested in the data that devices collect and analyzing it or you might be interested in how to deploy thousands of sensors around a factory floor to better understand how efficient things are. You might just want to tinker. Be the cool person at the party talking about Arduino, Raspberry Pi, and Maroon 5. If you want to try out a “thing” – a small, connected device – that can measure data, I will help you get started with a quick tutorial using the ESP8266 “thing”.
First, you need to go by a thing on Amazon. I recommend for this project an ESP8266 compatible device like the NodeMCU. Don’t be scared. Add it to your Amazon shopping list or ask Alexa to buy you one. It’s $8.
Other parts that you will need:
- Micro USB cable
While you are waiting for your Amazon stuff to arrive, you can learn about ThingSpeak.
ThingSpeak is where we are going to store the data collected by our thing and where we can see the data that we collected. Visit ThingSpeak.com and Sign Up for an account. This will just take a minute and user accounts are free. Once you have a user account, you need to create a channel. ThingSpeak channels are where data gets stored. Create a new channel by selecting Channels, My Channels, and then New Channel. Name the channel, “ESP8266 Signal Strength” and name Field 1, “RSSI”. Click “Save Channel” at the bottom to finish the process.
Once the ESP8266 comes in the mail in a couple of days you need to gather a few more things to be able to program this thing. You will need a laptop and a micro USB cable (like the one that you charge a phone with). On the laptop, we need to install some software to be able to program the ESP8266. Visit Arduino.cc and install the Arduino IDE.
Once the Arduino IDE is installed, open the program so we can do a couple of setup steps to get it ready to program ESP8266 devices. Under File, Preferences, and Additional Boards Manager URLs, add this link: http://arduino.esp8266.com/stable/package_esp8266com_index.json – this will allow the Arduino IDE to manage ESP8266 compatiable boards.
The thing that you bought from Amazon uses the CP2102 USB driver. You might have to install a USB driver from Silicon Labs for this to work with your computer. Connect the ESP8266 to your laptop with the micro USB cable.
Whew. We got through the setup. Now we can program this device or any ESP8266 compatible device and shouldn’t have to do that again.
The code that the Arduino IDE uses is called a “sketch” – this is just a short program that the device runs over and over. In our project, we are going to have the code measure the signal strength of the Wi-Fi connection and upload the data to ThingSpeak, wait, and repeat. Over time we can see the signal strength of our Wi-Fi connection. Copy the example code to your Arduino IDE and change some of the defaults to match your Wi-Fi network and ThingSpeak settings.
Once everything is set, click Sketch and then Upload. This will take the code and program the ESP8266 with it. It takes a minute so be patient. If anything goes wrong, make sure that you have the right board settings and that your “Port” matches what your laptop thinks the port is.
Back on ThingSpeak, you should see data start to come in. You are looking for the Private View of your channel and a chart that is updating. As new dsata comes in, the chart shows the latest value. If you carry the ESP8266 around the house, you might notice the signal strength changing.
To take the project further, you can use MATLAB on ThingSpeak to do some data analysis. I will post about IoT data analytics on another day. The ESP8266 source code for sending data to ThingSpeak is available on GitHub.
Welcome to the Internet of Things. Let me know if you try this out and let me know if you take this project further and build something cool.
ThingSpeak just announced that they added MQTT as a way to send data to a ThingSpeak channel. This is great news since a lot of devices support MQTT. If you don’t have a device, but want to try out the MQTT protocol with ThingSpeak, you can use a desktop application called MQTT.fx. In this example, I am going to explain how to use MQTT.fx to send data to a ThingSpeak channel.
- Sign up for ThingSpeak (or log in if you have an account)
- Create a new channel
- Note the Channel ID and Write API Key
- Download and install MQTT.fx.
- Configure the connection profile for the desktop MQTT client.
- Broker Address: mqtt.thingspeak.com
- Broker Port: 1883
- Click Connect to connect to the ThingSpeak MQTT broker.
- Enter the topic channels/<channelID>/publish/<apikey> to publish data to a channel feed. Replace <channelID> with the channel ID and <apikey> with the write API key of the channel. Enter the message to publish to the channel feed. This PUBLISH message publishes a value of 45 to field 1 and 60 to field 2 of the specified channel, along with a status message MQTTPUBLISH.
- Alternatively, you can enter the topic channels/<channelID>/publish/fields/field<fieldnumber>/<apikey> to publish to a channel field. Replace <channelID> with the channel ID, <fieldnumber> with field number that want to update, and <apikey> with the write API key of the channel. Enter the message to publish to the channel field. This PUBLISH message publishes a value of 45 to field 1 of the specified channel.
- MQTT Basics – Learn about the publish/subscribe architecture for connecting bandwidth and power-constrained devices over wireless networks
- MQTT Client Configuration – Learn how to set up an MQTT client to communicate with the ThingSpeak MQTT broker
- Choose Between REST and MQTT – Learn when to use REST and MQTT to update a channel
Bruce Sinclair of IoT-Inc. recently asked me to be a guest on his Internet of Things podcast, the IoT Business Show. I have been a faithful listener to the podcast since it started so I was honored to be a part of his show. Bruce asks very interesting questions and has his audience at heart. His questions help answer questions that the audience might be wrestling with when making a decision about getting into IoT (or not).
In his latest episode, Bruce asks, “Are Open Source IoT Platforms Ready for Primetime?” My open source IoT project is ThingSpeak. I created ThingSpeak back in 2010 as an ioBridge project and it has really taken off. The source code for the ThingSpeak API is available on GitHub and is being worked on by over 100,000 developers from around the world.
I have been working with the Twilio API for a few of my projects. I have used Twilio to call me when disk space is running low on a server or to call my house and request its status. Twilio is a cloud-based communications platform for sending and receiving text messages or placing phone calls. Twilio is wrapped up nicely with a RESTful API so ThingSpeak or MATLAB can use it without a lot of setup.
Tonight, I was following a beginner tutorial that I wrote for using Twilio and ThingSpeak, and I noticed that their voice example plays a friendly greeting and then by surprise Twilio starts playing Rick Astley’s “Never Gonna Give You Up”, for the world’s geekiest rickroll.
Twilio’s example points to this Url: https://demo.twilio.com/docs/voice.xml.
If you look closer you will see the following code:
<?xml version="1.0" encoding="UTF-8"?> <Response> <Say voice="alice">Thanks for trying our documentation. Enjoy!</Say> <Play>http://demo.twilio.com/docs/classic.mp3</Play> </Response>
Go ahead and click: http://demo.twilio.com/docs/classic.mp3
Often when building IoT projects, you end up wondering what data is being sent to a cloud service like ThingSpeak. The IoT Debugger tool allows you to see the data inside a ThingSpeak channel in a table view. The ThingSpeak Logger shows you data as the channel gets updated. This is an easy way to see if you are sending bad data or null data. The project is open source and available on GitHub.
Features of IoT Debugger
- ThingSpeak Data Logger
- Particle.io Webhooks Manager
- Settings are saved in LocalStorage
- Built using HTML5, Bootstrap, and jQuery
- Open Source!