Introducing Smart IoT light using Adafruit IO and IFTTT

by Nov 21, 2020Raspberry Pi projects

Introduction :

This is an IoT-enabled Led light with Multiple color-changing features. which can be controlled by google assistant. RGB Led is used as an IoT light of this project. Which is controlled by a Raspberry Pi on the edge. Adafruit.io is working as a cloud between IFTTT application which is further connected to Google Assistant for controlling.

Hardware Description :

RGB Led: It is a light-emitting diode having three basic colors like Red, Green, Blue. These three colors in different combinations can be used to create any color.

Raspberry Pi: Raspberry Pi is a microprocessor with a running Raspbian operating system. It has 40 pins out of which 26 are General purpose pins. Python can be used to program the circuits. It can connect to Adafruit.io easily using MQTT or HTTP protocols.

Adafruit.IO:

It is an IoT cloud platform that is very easy to integrate with hardware and with online applications. It has so many features to control the edged device from a remote location and very effective for small and large-scale IoT devices.

IFTTT :

If This Then That is a web-based service that allows users to create chains of conditional statements triggered by changes that occur within other web services such as Gmail, Facebook, Telegram, Instagram, or google assistant. IFTTT is simple to use. You download the mobile app to create a free account and you’re up and running with automation in minutes.

Creating different colors using RGB Led:

color mixing

A total of 7 colors can be creating using different combinations of Red, Green and Blue.

  1. Red : Give logic ‘1’ to Red pin of RGB and logic ‘0’ to others.
  2. Green : Give logic ‘1’ to Green pin of RGB and logic ‘0’ to others.
  3. Blue : Give logic ‘1’ to Blue pin of RGB and logic ‘0’ to others.
  4. Yellow : Give logic ‘1’ to Red and Green pin of RGB and logic ‘0’ to others.
  5. Purple : Give logic ‘1’ to Red and Blue pin of RGB and logic ‘0’ to others.
  6. Cyan : Give logic ‘1’ to Green and Blue pin of RGB and logic ‘0’ to others.
  7. White : Give logic ‘1; to all the pins of RGB.

Working of IoT light :

Preparing Adafruit.IO

  1. Open Adafruit.IO and sign in to your Account or register a new account.
  2. Create a new Dashboard and name it whatever you want.
  3. Create a new Block from the ‘+’ icon on the top right and add a new text block onto the dashboard.
  4. Attach this block to a feed or group (create one if not already created) on to which you want to send data from IFTTT and subscribe to that feed from Raspberry Pi.

Connecting Google assistant to Adafruit Io using IFTTT :

  1. Install the IFTTT application from Playstore and sign in.
  2. Go to create one.
  3. Open the ‘if’ block and search for google assistant.
    1. Type the phrase you using which, you want to trigger Adafruit from Google assistant.
    2. Type additional phrases to trigger and response you want from google assistant.
  4. Open ‘then’ block and search for Adafruit.IO
    1. Select send data to Adafruit.
    2. Choose the feed you want to send data to.
    3. write the data you want to send.
  5. Create a different block for every color.

Blog on Connecting IFTTT with Raspberry Pi

Python Code :

import sys, time
from Adafruit_IO import *
import RPi.GPIO as GPIO
redPin   = 2
greenPin = 3
bluePin  = 4

def blink(pin):
  GPIO.setmode(GPIO.BCM)
  GPIO.setup(pin, GPIO.OUT)
  GPIO.output(pin, GPIO.HIGH)
def turnOff(pin):
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(pin, GPIO.OUT)
        GPIO.output(pin, GPIO.LOW)
def default():
  redPin   = 2
  greenPin = 3
  bluePin  = 4
  GPIO.setmode(GPIO.BCM)
  GPIO.setup(redPin,GPIO.OUT)
  GPIO.setup(greenPin,GPIO.OUT)
  GPIO.setup(bluePin,GPIO.OUT)
  GPIO.output(redPin, GPIO.LOW)
  GPIO.output(greenPin, GPIO.LOW)
  GPIO.output(bluePin, GPIO.LOW)

def redOn():
        default()
        blink(redPin)
def greenOn():
        default()
        blink(greenPin)
def blueOn():
        default()
        blink(bluePin)

def yellowOn():
        default()
        blink(redPin)
        blink(greenPin)

def cyanOn():
        default()
        blink(greenPin)
        blink(bluePin)

def magentaOn():
        default()
        blink(redPin)
        blink(bluePin)

def whiteOn():
        default()
        blink(redPin)
        blink(greenPin)
        blink(bluePin)
def redOff():
        turnOff(redPin)

def greenOff():
        turnOff(greenPin)

def blueOff():
        turnOff(bluePin)

def yellowOff():
        turnOff(redPin)
        turnOff(greenPin)

def cyanOff():
        turnOff(greenPin)
        turnOff(bluePin)

def magentaOff():
        turnOff(redPin)
        turnOff(bluePin)

def whiteOff():
        turnOff(redPin)
        turnOff(greenPin)
        turnOff(bluePin)
while True:
        aio = Client("Brownboy333","aio_aHCq59YIUcI10mefiqlEcbZtMrJk")
        cmd = aio.receive("txt").value
        print(cmd)
        if (cmd == "red on"):
                redOn()
                print("red On")
        elif cmd == "red off":
                redOff()

        elif cmd == "green on":
                greenOn()
                print("green ON")

        elif cmd == "green off":
                greenOff()

        elif cmd == "blue on":
                blueOn()

        elif cmd == "blue off":
                blueOff()

        elif cmd == "yellow on":
                yellowOn()

        elif cmd == "yellow off":
                yellowOff()

        elif cmd == "cyan on":
                cyanOn()

        elif cmd == "cyan off":
                cyanOff()

        elif cmd == "magenta on":
                magentaOn()

        elif cmd == "magenta off":
                magentaOff()

        elif cmd == "white on":
                whiteOn()

        elif cmd == "white off":
                whiteOff()

        else:
                print("Not a valid command.")

Creating a multiplication Skill in Alexa using python

Written By Monisha Macharla

Hi, I'm Monisha. I am a tech blogger and a hobbyist. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. Thank you for reading my blog! Happy learning!

RELATED POSTS

Magic Wand using Raspberry Pi and OpenCV

Magic Wand using Raspberry Pi and OpenCV

What if I could do things with a swing of a wand? Practically impossible but with technology maybe not. In this tutorial, we will use a raspberry pi and OpenCV to try and recreate something similar to a wand. It will perform specific functions when it recognizes...

IBM Watson IoT Platform with Raspberry Pi

IBM Watson IoT Platform with Raspberry Pi

IBM Watson is one of the leading cloud computing platforms there is. It has almost all the features one could expect from a modern-day cloud platform, from machine learning support to IoT, even till edge computing. In this tutorial, we will use raspberry pi and an...

Home Automation With Telegram and Raspberry Pi

Home Automation With Telegram and Raspberry Pi

In this Article we will see how we can use Telegram for Home Automation. Telegram is an extremely popular multi-platform messaging service. Just like any other messaging platform, it is used to send messages and exchange photos, videos, stickers, audio, and files of...

Home Automation System with Raspberry Pi and Flask

Home Automation systems are becoming increasingly popular for the level of convenience they offer. Imagine sitting on your couch and turning on/off lights or fans in the room without having to get up. You could also control blinds or even door locks. This project is a...

Smart Alarm Clock with Raspberry Pi

Smart Alarm Clock with Raspberry Pi

Smart Alarms are very common today yet the good ones expensive. What if you wanted to make a smart alarm clock on your own using as little hardware and cost as possible? You may ask isn't the RPI costly, yes it is but, the only purpose of using an RPI is easy to net...

Spy Bot with Raspberry Pi

Spy Bot with Raspberry Pi

Spy bot is a raspberry pi bot that uses its camera to take secret pictures, encrypt them using RSA encryption and upload it safely to a database/server. Today, security and surveillance have become very important. To take inspiration from world scenario we start off...

VIDEOS – FOLLOW US ON YOUTUBE

EXPLORE OUR IOT PROJECTS

IoT Smart Gardening System – ESP8266, MQTT, Adafruit IO

Gardening is always a very calming pastime. However, our gardens' plants may not always receive the care they require due to our active lifestyles. What if we could remotely keep an eye on their health and provide them with the attention they require? In this article,...

How to Simulate IoT projects using Cisco Packet Tracer

In this tutorial, let's learn how to simulate the IoT project using the Cisco packet tracer. As an example, we shall build a simple Home Automation project to control and monitor devices. Introduction Firstly, let's quickly look at the overview of the software. Packet...

All you need to know about integrating NodeMCU with Ubidots over MQTT

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

All you need to know about integrating NodeMCU with Ubidots over Https

In this tutorial, let's discuss Integrating NodeMCU and Ubidots IoT platform. As an illustration, we shall interface the DHT11 sensor to monitor temperature and Humidity. Additionally, an led bulb is controlled using the dashboard. Besides, the implementation will be...

How to design a Wireless Blind Stick using nRF24L01 Module?

Introduction Let's learn to design a low-cost wireless blind stick using the nRF24L01 transceiver module. So the complete project is divided into the transmitter part and receiver part. Thus, the Transmitter part consists of an Arduino Nano microcontroller, ultrasonic...

Sending Temperature data to ThingSpeak Cloud and Visualize

In this article, we are going to learn “How to send temperature data to ThingSpeak Cloud?”. We can then visualize the temperature data uploaded to ThingSpeak Cloud anywhere in the world. But "What is ThingSpeak?” ThingSpeak is an open-source IoT platform that allows...

Amaze your friend with latest tricks of Raspberry Pi and Firebase

Introduction to our Raspberry Pi and Firebase trick Let me introduce you to the latest trick of Raspberry Pi and Firebase we'll be using to fool them. It begins with a small circuit to connect a temperature sensor and an Infrared sensor with Raspberry Pi. The circuit...

How to implement Machine Learning on IoT based Data?

Introduction The industrial scope for the convergence of the Internet of Things(IoT) and Machine learning(ML) is wide and informative. IoT renders an enormous amount of data from various sensors. On the other hand, ML opens up insight hidden in the acquired data....

Smart Display Board based on IoT and Google Firebase

Introduction In this tutorial, we are going to build a Smart Display Board based on IoT and Google Firebase by using NodeMCU8266 (or you can even use NodeMCU32) and LCD. Generally, in shops, hotels, offices, railway stations, notice/ display boards are used. They are...

Smart Gardening System – GO GREEN Project

Automation of farm activities can transform agricultural domain from being manual into a dynamic field to yield higher production with less human intervention. The project Green is developed to manage farms using modern information and communication technologies....