AllThingsTalk is building an Internet of Things cloud platform, used by makers and businesses who are getting into IoT all around the world.
Your goal is to use AllThingsTalk Maker web application to control the LED strips connected to a WiFi device.
Hardware for the workshop includes:
- NodeMCU (ESP8266) board
- 1 meter of LED strip (60 WS2812B LEDs)
- A regulated power supply
- Micro USB cable
For this workshop we’ll be using NodeMCU running on Arduino platform, as it can be easily programmed using the on-board USB port. It has an ESP8266 — an inexpensive WiFi micro-controller which you can use to quickly connect to wireless networks, send and receive data over various protocols, and read and write data from its IO pins.
We’ll be using a strip of 60 WS2812B LEDs. These LEDs are individually-addressable, meaning you can set each to any color you want, and they support Full RGB color spectrum.
Since these are basically the same as Adafruit NeoPixel, we’ll be using NeoPixel library to control the LEDs so we don’t have to worry about protocol details.
-
You’ll notice that the NodeMCU is mounted to a breadboard, which enables easier I/O connecting
-
Following the diagram, connect the input pins of the prepared LED strip to the corresponding holes in the breadboard:
-
Connect the power supply to the AC
- Download and install Arduino IDE to your computer
- Download and install USB to UART bridge drivers
Board configuration needs to be added into Arduino IDE so we can choose the correct one from Tools
menu:
- Connect the board with your computer using a micro USB cable
- Open Arduino IDE, go to
Preferences
and typehttp://arduino.esp8266.com/stable/package_esp8266com_index.json
into the field forAdditional Boards Manager URL
.
-
Select
Tools
>Board
>Boards Manage``r…
-
Select
Tools
>Boards
>NodeMCU 1.0 (ESP-12E Module)
-
In
Tools
>Port
select the port to which the board is connected, you can find this inDevice Manager
>Ports
-
Download Arduino SDK and follow the instructions for installation in the readme**.md** file.
-
Download and install Adafruit NeoPixel library, for controlling LED strips:
-
Download and install ArduinoJson by Benoit Blanchon, following the previous steps
Create a device in Maker to represent your NodeMCU board:
-
Open Maker in your browser
-
Sign up to create an account
-
Go to
Playground
-
Create new device via
Device
tab >+C``ONNECT A DEVICE
>WIFI/Lan devices
>Your own
-
Name your device however you like, and click
Connect
-
Go to
Settings
>Authentication
to find yourDevice ID
andDevice Token
; you’ll need to include these in your sketch later, so the cloud can route the traffic to / from your board -
Create a c****olor asset, which you’ll use to control the color of LED strips
-
+NEW ASSET
-
Select
Actuator
-
Name the asset
color
(watch out, name is case sensitive) -
For setting the Profile, select
Advanced
tab -
Paste the Profile type code: { "type": "object", "properties": { "r": { "type": "integer", "minimum": 0, "maximum": 255 }, "g": { "type": "integer", "minimum": 0, "maximum": 255 }, "b": { "type": "integer", "minimum": 0, "maximum": 255 } } }
-
-
To control the LED strip using a graphical interface, you can pin the color control to the pinboard
-
Choose
+Create pinboard
icon from the top right of the Device page -
Now you can see the
color
asset in your pinboard -
Click on the context menu of the
color
control (three dots) -
Select
Edit control
-
Select
Color picker
control and hit OK -
Select
Save
icon in the top right part of the Pinboard to save the changes
-
Now that you’re all set, you should try out the example sketch and see those LEDs actually glowing!
- Download the example sketch from GitHub
- Edit the credentials.h file with your
Device ID
andDevice Token
which you previously got from the Device Settings in Maker application, and WiFi SSID and Password
-
SSID = “startit”
-
PASW = “StartitCentar”
-
From the Pinboard page in Maker use the
color
control to test your sketch
That’s up to you and your imagination! You can check out NeoPixel Examples for some inspiration, though.