Things used in this project

Hardware components:
Iotopia box rs
AllThingsTalk IOTOPIA Rapid Development kit
SeeedStudio Grove RGB lcd display
brick list above
Software apps and online services:
AllThingsTalk Maker


How to connect
House schematic
Connecting the LED
To fit the LED nicely in the roof, we have to extend the legs a bit. Just solder some wires to them and attach them on the backside of the Grove connector.
Ch led


Sketch for one house. You need a second and link them together through the SmartLiving cloud platform.

Arduino UART Demo Sketch. This Sketch is made for an Genuino 101 IoT board with a Grove
UART WiFi module based on the popular ESP8266 IoT SoC to communicate to the AllThingsTalk
IoT developer cloud.
The Grove UART WiFi module has firmware installed which includes the ATT_IOT library. It
communicates through Serial1 of the Genuino 101 board.

### Instructions
1. Setup the Arduino hardware
  - Use an Arduino Genuino 101 IoT board
  - Connect the Arduino Grove shield, make sure the switch is set to nullV
  - Connect USB cable to your computer
  - Connect a Grove LCD RGB display to pin I2C of the Arduino shield
  - Connect a Grove Button to pin D2 of the Arduino shield
  - Connect a Grove LED socket to pin 3D of the Arduino shield
  - Grove UART wifi to pin UART (D0,D1)
2. Add 'ATT_IOT_UART' library to your Arduino Environment
3. Fill in the missing strings (deviceId, clientId and clientKey) in the keys.h file
4. Upload the sketch


#include "ATT_IOT_UART.h"      // AllThingsTalk Arduino UART IoT library
#include <SPI.h>               // Required to have support for signed/unsigned long type
#include "keys.h"              // Keep all your personal account information in a seperate file
#include <Wire.h>
#include "rgb_lcd.h"

ATTDevice Device(&Serial1);
char httpServer[] = "";          // HTTP API Server host
char mqttServer[] = "";       // MQTT Server Address

rgb_lcd lcd;

// Define default values
#define red 30
#define green 30
#define blue 30

#define messageId 1
#define displayId 0   // I2C
#define buttonId 2
#define ledId 3

bool sensorVal = false;
bool buttonVal = false;
boolean hasMessage = false;

#define scrollSpeed 240    // Milliseconds delay for scrolling on lcd display
int xOffset = 16;
long ms;
String msg;
int msgLength;

void setup()
  Serial.begin(57600);                                 // Init serial link for debugging
  while(!Serial && millis() < 1000);                   // Make sure you see all output on the monitor. After 1 sec, it will skip this step, so that the board can also work without being connected to a pc  Serial.println("Starting sketch");
  Serial1.begin(115200);                               // Init serial link for WiFi module

  while(!Device.Init(DEVICEID, CLIENTID, CLIENTKEY))   // If we can't succeed to initialize and set the device credentials, there is no point to continue
  while(!Device.Connect(httpServer))                   // Connect the device with the AllThingsTalk IOT developer cloud. No point to continue if we can't succeed at this

  Device.AddAsset(buttonId, "LED", "button", true, "boolean");
  Device.AddAsset(displayId, "Display", "display", true, "string");
  Device.AddAsset(messageId, "Send message", "send", "true", "string");

  delay(1000);                                         // Give the WiFi some time to finish everything
  while(!Device.Subscribe(mqttServer, callback))       // Make sure that we can receive message from the AllThingsTalk IOT developer cloud (MQTT). This stops the http connection

  lcd.begin(16, 2);

  digitalWrite(ledId, LOW);
  Device.Send("false", buttonId);
  turnOnDisplay(red, green, blue, "House now ready for use!");

  Serial.println("House now ready for use!");

void loop() 
  bool sensorRead = digitalRead(buttonId);             // Read status Digital Sensor
  if (sensorVal != sensorRead)                         // Verify if value has changed
    sensorVal = sensorRead;
    if(sensorVal) {            // Only send the value when pressed down.
      buttonVal = !buttonVal;
        digitalWrite(ledId, HIGH);
        Device.Send("true", buttonId);
        digitalWrite(ledId, LOW);
        Device.Send("false", buttonId);

  if(hasMessage)    // Nicely scroll the message

void scrollMessage()
  if(millis() - ms > scrollSpeed)
    ms = millis();
    printLine(0, 0, "                ");
    if(xOffset >= 0) printLine(0, xOffset, msg.substring(0, 16 - xOffset));
    else if(msgLength + xOffset >= 0) printLine(0, 0, msg.substring(-xOffset, min(-xOffset + 16, msgLength)));
    else {
      xOffset = 16;   // Reset text scroll loop


void turnOnDisplay(int r, int g, int b, String message)
  hasMessage = true;
  msg = message;
  msgLength = message.length();
  lcd.setRGB(r, g, b);

  xOffset = 16;
  ms = millis();

void turnOffDisplay()
  hasMessage = false;
  lcd.setRGB(0, 0, 0);

void printLine(int r, int c, String line)
  lcd.setCursor(c, r);

void toggleDisplay(bool val)
  if(val)      // turn on status LED
    buttonVal = true;
    digitalWrite(ledId, HIGH);
    Device.Send("true", buttonId);
  else        // turn off status LED
    buttonVal = false;
    digitalWrite(ledId, LOW);
    Device.Send("false", buttonId);


void callback(int pin, String& value) 
  // Toggle display of connected house
  if(pin == buttonId)
    Serial.print("Received button: ");

  // Turn on display of connected house with custom message
  if(pin == messageId)
    Device.Send(value, messageId);

  // Set message on our display
  if(pin == displayId)
    Device.Send(value, displayId);
      turnOnDisplay(red, green, blue, value);
Device credentials from SmartLiving. Fill in the device credentials of the house device you are uploading to.
#ifndef SETTINGS
#define SETTINGS

#define DEVICEID ""        // Your device id comes here
#define CLIENTID ""        // Your client id comes here
#define CLIENTKEY ""       // Your client key comes here

AllThingsTalk Arduino UART client
Client library which supports the Genuino 101 with UART WiFi module. First time you run it, you'll need to enter your WiFi credentials. Check the serial monitor!


Sander Hendrickx
1 project • 6 followers
I love mathematics, programming, MacGuyver, electronics, robotics, artificial intelligence, hiking, Rubik's cubes, Star Wars, astrophysics and finding Waldo


Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback


Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog