element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Blog Part 2.3 Touche Minions
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: pmohan
  • Date Created: 20 Dec 2014 6:31 PM Date Created
  • Views 2788 views
  • Likes 4 likes
  • Comments 13 comments
  • RoadTest
  • mqtt
  • chuck
  • yun
  • minions
  • wifi_christmas_tree
  • iot_holidaylights
  • osc
  • capacitive
  • arduino
  • mpr121
Related
Recommended

Part 2.3 Touche Minions

pmohan
pmohan
20 Dec 2014

After receiving the hardware from Element 14 for the IOT Holiday lights challenge, i have completed the touch enabled minion ornaments for my christmas tree to go along with the minion sound generation i described in the earlier blog post.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

Components used:

 

1. Arduino Yun

2. Adafruit 12-key capacitive touch sensor breakout - MPR121

3. Eclipse Paho MQTT Library

4. Home made minion ornaments

5. Conductive Thread for wrapping around any christmas ornament

 

Here is a high level diagram of how it all works.

image

Pictures:

 

1. Home made Minion ornaments ready to be tested. I couldn't find the minion ornaments in the local stores. So I just used aluminum foil from the kitchen to wrap around piece of cardboard. And stuck the minion stickers on them.

Notice the last christmas ornament. This is wrapped around with conductive thread. This is what i originally intended to do if i get the actual minion ornaments. This works well too.

image

 

2. Wiring:

Arduino Yun is connected to the Adafruit MPR121 touch sensor break out. Since this is a temporary arrangement i didn't solder the fires to the break out. The break out speaks I2C. On Yun the SDA and SCL are on the digital pins 2 and 3.

image

 

3. Yun connected to tree. (Officially becoming a WiFi Tree)

The small breadboard had a 3m sticker on the back. So i was able to peel it off and attach it to the base of the tree. So this tree is going to be a bread boarded tree forever. In the years to come i hope this bread board gets used for other projects. I just kept the Yun in one of the shipment boxes for now. Later when other parts of the WiFi christmas tree project is done i will plan for an enclosure.

image

4. Minion Ornaments on the Tree

I was really happy once it all worked on as planned and the look on my 5 year old son's face was priceless when he touched one of the minions for the first time and it went "whaaaaaaaaaaaaat" image

image

 

The Code:

I have used the code from Adafruit for Capactive touch and the MQTT example from the MQTT C library linked by kartben in an earlier blog post on MQTT. I have modified both code to suit my purposes.

 

This sketch contains three files. I abstracted away the MQTT functionality in to a MQTTHelper class in the arduino coding style to keep my main arduino sketch cleaner. This mqtt helper class just contains a MQTT Publish functionality only. I will add the subscribe functionality later as i continue to work on other parts of the project.

 

ToucheMinions Arduino Sketch

//Created By: Mohan Palanisamy for Holiday Lights IoT project at Element 14
//http://www.element14.com/community/groups/arduino/blog/2014/12/11/intro-interactive-wifi-christmas-tree
//Thanks to Adafruit, Benjamin Cabe, Eclipse Paho for their sample code and Libraries
//You can find them here:
//Adafruit MPR121 Library: https://github.com/adafruit/Adafruit_MPR121_Library
//Benjamin Cabe: http://www.element14.com/community/groups/arduino/blog/2014/11/25/controlling-holiday-lights-using-mqtt-and-the-arduino-yún
#include <Wire.h>
#include <SPI.h>
#include <YunClient.h>
#include <IPStack.h>
#include <Countdown.h>
#include <MQTTClient.h>
#include "MQTTHelper.h"
#include "Adafruit_MPR121.h"


char* mqttBroker ="192.168.1.217"; //mqtt broker running on windows pc
int port = 1883;
char* topic = "WiFiTree/FromController/MinionSound";


uint16_t lasttouched = 0;
uint16_t currtouched = 0;


MQTTHelper mqttHelper=MQTTHelper();
Adafruit_MPR121 minionSensor = Adafruit_MPR121();


void setup() {


  Serial.begin(9600);
  Bridge.begin();
  minionSensor.begin(0x5A);
  mqttHelper.begin(mqttBroker,port);


}


void loop() {

  currtouched = minionSensor.touched();


  for (uint8_t i=0; i<12; i++) {
      if ((currtouched & (1 << i)) && !(lasttouched & (1 << i)) ) {
            char msgbuf[2];
            sprintf(msgbuf,"%d",i);
            mqttHelper.sendMessage(topic,(char *) msgbuf);
        }
  }


  lasttouched = currtouched;

  delay(100);
}

 

MQTTHelper.cpp

//Created By: Mohan Palanisamy for Holiday Lights IoT project at Element 14
//http://www.element14.com/community/groups/arduino/blog/2014/12/11/intro-interactive-wifi-christmas-tree
//Uses source from Benjamin Cabe of eclipse foundation.


#include "MQTTHelper.h"


YunClient c;
  IPStack ipstack(c);
MQTT::Client<IPStack, Countdown> client=MQTT::Client<IPStack, Countdown>(ipstack);


MQTTHelper::MQTTHelper() {
}


void MQTTHelper::begin(char* hostname, int port) {


//MQTT client setup
  ipstack.connect(hostname, port);
  MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
  data.MQTTVersion = 3;
  data.clientID.cstring = (char*)"wifitree-555";
  client.connect(data);

  Serial.println("MQTT connected");
}


void MQTTHelper::sendMessage(char* topic, char* msgbuf)
{
  MQTT::Message message;


  if (!client.isConnected())
    return;


  Serial.println(msgbuf);
  message.qos = MQTT::QOS0;
  message.retained = false;
  message.dup = false;
  message.payload = (void*)msgbuf;
  message.payloadlen = strlen(msgbuf)+1;
  client.publish(topic, message);
}

 

MQTTHelper.h

//Created By: Mohan Palanisamy for Holiday Lights IoT project at Element 14
//http://www.element14.com/community/groups/arduino/blog/2014/12/11/intro-interactive-wifi-christmas-tree


#include <Wire.h>
#include <SPI.h>
#include <Bridge.h>
#include <YunClient.h>
#include <IPStack.h>
#include <Countdown.h>
#include <MQTTClient.h>


class MQTTHelper {
public:

  MQTTHelper(void);


  void begin(char* hostname, int port); // to abstract connection setup arduino style
  void sendMessage(char* topic, char* msgbuf);
};

 

 

 

Future adjustments:

On Chuck i should be able to create shreds to make tingling sounds with the proper scale. Then it would be easy to make a very musical christmas tree when the ornaments are touched.

 

Hope you enjoyed this and try this out for your self. Merry Christmas and Happy Holidays every one!!!

  • Sign in to reply

Top Comments

  • pmohan
    pmohan over 10 years ago in reply to fvan +2
    I removed the pictures and uploaded them again. Please let me know if you can see them now..
  • DAB
    DAB over 10 years ago +2
    Excellent project. This is one of the most innovative uses for technology that I have seen in a while. Well done. DAB
  • mcb1
    mcb1 over 10 years ago +1
    Thats brilliant ... well done. Mark
  • Former Member
    Former Member over 10 years ago

    Cool!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • gadget.iom
    gadget.iom over 10 years ago

    Nice project. image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 10 years ago

    Excellent project.

     

    This is one of the most innovative uses for technology that I have seen in a while.

     

    Well done.

     

    DAB

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • pmohan
    pmohan over 10 years ago in reply to mcb1

    Thanks.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 10 years ago

    Thats brilliant ... well done.

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube