Arduino With Alexa and Google Assistant | Arduino Crane Project

by ShreyasJha5706 in Circuits > Arduino

3697 Views, 31 Favorites, 0 Comments

Arduino With Alexa and Google Assistant | Arduino Crane Project

Arduino with Amazon Alexa and Google Assistant | Arduino Crane Project | Shreyas Jha
20200615_222312.jpg
DSC_3149.JPG
DSC_3151.JPG
DSC_3184.JPG
DSC_3239.JPG
DSC_3275.JPG

Hi everyone! Hope you like my project. The story behind the project is --

I live in a duplex apartment, which means if I need something from downstairs in my workshop, I will have to go down the stairs, and back up the stairs [ I work upstairs as the air conditioner is upstairs :) ] This gets very tiring especially in summers. I could just ask somebody from downstairs for the part I was looking for, (someone is always downstairs 75% of the time) but how will I get it back up? Hmm....

This led me to making a crane with Arduino to lift small payloads from downstairs to upstairs! I mean, how cool is that! Check out the video for a detailed view on how I made this project. If you are unclear about any steps, the video will surely help you out.

Supplies

The supplies needed for this project are (50% will likely be around your house)-

Electronics -

  • A DC Motor (Mine is 12V and 60RPM with a torque of about 157.6 N-cm) x 1
  • Bracket for the DC Motor x1
  • A wooden block (30mm*60mm*250mm) x 1

  • Motor Driver (L298N Based Motor Driver Module) x 1
  • Arduino Uno (The brains !) x 1
  • Arduino Ethernet Shield x 1
  • Female power jack connector x 1
  • Male power jack connector x 1
  • 12V Adapter x 1(Make sure you get a decent one with a current rating above 2A)
  • HC-05 Ultrasonic Sensor x 1
  • Jumper Wires
  • Ethernet Cable x 1
  • Access to power point and Ethernet (I used a WiFi Extender that was waiting to be installed)

Mechanical -

  • M4 x 50mm Bolts with Washers and Nuts x 8
  • M3 x 25mm Bolts with Nuts x 4
  • M3 x 20mm Bolt x 1
  • M3 X 20mm Male to Female Brass Hex Threaded Pillar Standoff Spacer x 7

  • A way to mount the device on your wall :)
  • Fishing line (Braided)
  • A plastic basket (The one which has weave pattern is a bonus )
  • An S-hook ( Optional, but helps in in

Tools -

  • A 3D printer (or access to one)
  • Common Tools

Sketching Out the Basic Idea

Screenshot 06-15-2020 22.07.41.png
Screenshot 06-15-2020 22.07.59.png

Before starting building anything, we have to sketch out the basic idea that we want to be built. I started with sketching out the railings of my stairs and the system around it. Remember, this is just a draft, not an actual plan. We will be changing some parameters of the design. :)

Here I have included some of my initial designs. As you can see from the picture in the beginning, I changed quite a few parameters. (The mount on the wall, The pulley system was removed etc.).

Now go ahead and sketch!

3D Printing the Parts

Screenshot 06-16-2020 09.24.20.png
DSC_3178.JPG
DSC_3140.JPG
DSC_3205.JPG

The first step is to 3D print all the parts. I designed a pulley and two brackets in Fusion 360 to be 3D printed for this project. Make sure you print these at 100% infill [Because you don't want it to fall :( ]. The pulley is in 2 parts, so you have to glue the parts together to make it functional. I didn't put holes in the bracket as I didn't know at first where the holes should go but I have included the holes in the .stl file (Just for the part which secures the wood to the bracket) But you would still have to drill the holes to make sure the M4 bolts fit through.


Preparing the Wood

DSC_3240.JPG
DSC_3218.JPG
DSC_3285.JPG
Screenshot 06-16-2020 19.46.25.png

Now it is time to prepare the wood. My wood came from my spare wood inventory. I had to clean it up and sand some parts. To drill the holes, simply place the bracket on the wood mark the holes and drill! Holes for the Arduino and Motor Driver are a little tricky. First trace the holes and drill a 6mm hole half way through the wood. Then drill a 3mm hole completely through the wood. You'll see why you have to do this in just a bit. In case of the motor driver, drill only 2 holes as shown in the pictures.( I drilled 4 holes as I didn't know that the cables wouldn't fit.) Also, drill the holes according to the bracket for your motor.

Mounting the Hardware

DSC_3266.JPG
DSC_3261.JPG
DSC_3262.JPG
DSC_3285.JPG
Screenshot 06-16-2020 19.46.25.png

Now, Put the M3 bolt from the 3mm hole side and drop a nut from the 6mm side. Then start screwing the bolt and you will see the nut moving downwards. Continue screwing till the nut hits the end. Now screw the spacer in place. Repeat these steps and in the case of the motor driver, screw 2 spacers on top of each other. Now, place the hardware on the spacers and secure it in place with M3 Nuts. You should have the result as shown in the images above. At this stage, also screw the motor bracket and the wall brackets in place.( You will need the M5 bolts and nuts)

The Wiring

DSC_3289.JPG
DSC_3275.JPG
DSC_3277.JPG
DSC_3284.JPG
20200614_192859.jpg
DSC_3313.JPG
  1. Connect the Trig pin of the sensor to pin 7 and the Echo pin to pin 6.
  2. Connect In 3 and In 4 of the Motor Driver to Pin 8 and 9 respectively.
  3. Solder wires to the motor and connect the other end to Out 3 and Out 4.
  4. Make a splitter cable as shown in the pictures. (The wires are connected in parallel)
  5. Connect the male power jack connector to the Arduino and the loose wires to the motor driver's Vin and GND.
  6. Connect an Ethernet cable to connect the shield ( Make sure the cable can bend 90 degrees) and a nearby Ethernet access point. (I connected mine to a WiFi extender that was pending to be installed)
  7. Connect the female power jack connector to the power adapter.
  8. Glue the wires of the ultrasonic sensor as shown.

The wiring is complete. Take a break. You earned It!

The Payload

DSC_3297.JPG
DSC_3303.JPG
DSC_3301.JPG
DSC_3311.JPG
DSC_3312.JPG

Take your fishing line and tie it around the screw of the motor pulley as shown. Measure the length of fishing line that is needed for it to go up and down [Take about 20cm extra just in case :) ] and cut the line accordingly. Now, take the plastic basket and tie the fishing line to all four corners as shown. Now make a loop at the end so the S-hook can fit through. Take the end of the motor pulley line and make a similar loop. Now, you can connect both the lines together with the hook. You should have results similar to the images above.

The Coding

Screenshot 06-16-2020 12.32.17.png
Screenshot 06-16-2020 12.32.31.png
Screenshot 06-16-2020 12.32.39.png

I used Blynk for this project as I wanted to connect it with Amazon Alexa and Google Assistant via IFTTT. We live in the 21st Century, and we don't push buttons anymore for doing tasks. Voice Interaction rules ! You can read the code with the explanations and then download the code and change the parameters and upload it!

//  Default Blynk Code Start
#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

#define W5100_CS  10
#define SDCARD_CS 4

char auth[] = "YourAuthToken"; // DON'T FORGET TO FILL THIS OUT
// Default Blynk Code End

// Variable declarations for Ultrasonic Sensor Start
float duration, distance;
const int trigPin = 7;
const int echoPin = 6;
// Variable declarations for Ultrasonic Sensor End

// Function to check distance Start
void checkDistance() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = (duration * .0343) / 2;
  Serial.println(distance);
}
// Function to check distance End

// Function to be called when the value of Virtual Pin 1 is changed Start
BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  checkDistance();
  // State 1 of V1 means go up
  if (pinValue == 1) {
    do { 
      checkDistance();
// You will have to change the distance condition according to your needs. I chose 50 
// as I wanted the motor to stop when the bucket reaches 50cm from the motor.

      if (distance <= 50) { // Check if distance is less than 50 cm
        digitalWrite(8, LOW); // If it is, turn of the motor.
        digitalWrite(9, LOW);
        delay(20);
      }
      if (distance > 50) { // Check if distance is greater than 50cm
        digitalWrite(8, HIGH); // If it is turn on the motor.
        digitalWrite(9, LOW);
        delay(20);
      }
    } while (distance >= 50); // The condition for the loop is greater than equal to 50 as 
// the loop has to run when distance = 50 so the motor can be turned off.			
  }
// State 0 means no movement
  if (pinValue == 0) {
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    delay(20);
  }
// Explanation same as state 1, but this time state 2 means go down. So the conditions are
// also switched.
  if (pinValue == 2) {
    do {
      checkDistance();
      if (distance >= 290) { // If distance is greater equal than 290cm, stop
        digitalWrite(8, LOW);
        digitalWrite(9, LOW);
        delay(20);
      }
      if (distance < 290) { // If distance is less than 290cm, turn motor on
        digitalWrite(8, LOW);
        digitalWrite(9, HIGH);
        delay(20);
      }
    } while (distance <= 290); // Again the condition for the loop is less 
// than equal to 290cm as the loop has to run when distance = 290 so the motor 
// can be turned off.
  }
}
// Function to be called when the value of Virtual Pin 1 is changed End

void setup()
{
  // Debug console
  Serial.begin(9600);

// Declare pins as Outputs and Inputs Start
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(SDCARD_CS, OUTPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
// Declare pins as Outputs and Inputs End

  Blynk.begin(auth);
}

void loop()
{
  Blynk.run();
}

Blynk App and IFTTT

Screenshot_20200616-192455_Blynk.jpg
Screenshot_20200616-192539_Blynk.jpg
Screenshot_20200616-192552_Blynk.jpg
Screenshot_20200616-192610_Blynk.jpg
Screenshot_20200616-192709_Blynk.jpg
Screenshot_20200616-192714_Blynk.jpg
Screenshot_20200616-192716_Blynk.jpg
Screenshot 06-16-2020 15.32.19.png
Screenshot 06-16-2020 15.33.04.png
Screenshot 06-16-2020 15.34.10.png
Screenshot 06-16-2020 15.35.47.png
Screenshot 06-16-2020 15.36.19.png
Screenshot 06-16-2020 16.23.17.png
Screenshot 06-16-2020 16.23.42.png
Screenshot 06-16-2020 18.57.00.png
Screenshot 06-16-2020 19.00.03.png
Screenshot 06-16-2020 19.07.43.png

Configuring the Blynk App

Now for the Blynk App, You can go ahead and create a new project, Add two buttons (One to change the state from 0 to 1 and another to change the state from 0 to 2 for the V1 pin) And you are set !

Connecting with IFTTT

Now go ahead and open https://ifttt.com/create and repeat steps 1-8 for the following situations-

  • Applet for voice interaction with Alexa to send it up. (Enter value 1 instead of X for up)
  • Applet for voice interaction with Alexa to send it down. (Enter value 2 for down)
  • Applet for voice interaction with Google Assistant to send it up.(It is very similar to make applet for Assistant)
  • Applet for voice interaction with Google Assistant to send it down.

Steps -

  1. Click on the + This button
  2. Type Amazon Alexa in the search services section and click on the Amazon Alexa option
  3. Click Say a specific phrase and type the phrase you want to say. (Remember you will have to say Alexa, trigger + phrase.) Click Create Trigger.
  4. Now, Click + That button.
  5. Type Webhooks in the search services section and click on the Webhooks option.
  6. Click Make a Web Request option and fill out the details as follows -
    • URL : "http://188.166.206.43/YourAuthToken/update/V1?value=X"
    • Method : GET
    • Content Type : text/plain
  7. Click Create action.
  8. Click Finish.

If you are unclear about the steps, check the pictures.

Test Run !

20200615_222312.jpg

Test if everything is working as expected. You may have to debug some things. If it works, Congratulations !! If you have any doubts/I made any mistakes, be sure to leave it in the comment section below! Thanks for reading my post :)

If you liked this post, make sure to vote for it ! :)