Introduction: IoT Robotics - Part 2 - the Hardware

This project uses an accelerometer based controller to control and move a motorised robotic device miles away across the internet.

The idea of this project is really to touch on the possibilities and give you a starting point to building your own IoT based robotics.

This is the second of a 2 part series for this project. This instructable focuses on the hardware for this project (i.e the accelerometer for the controller, and the servo's for the receiver, and the arduino's in both), whilst the original instructable focuses on the IoT platform used to connect the 2 pieces of Hardware (i.e IBM's Watson IoT platform and Node-Red).

You can view the first part (i.e the Watson IoT platform) to this 2 part series here.

What you'll need.

In order to build this project you'll need the following pieces of hardware.

Controller:

  • Arduino - Ethernet or Wifi based. I used a generic Arduino Mega 256 with an Ethernet Sheild attached.
  • 3-Axis Accelerometer - You can get these from many places and they generally cost between $10-$20AUD
  • Chassis - I used a Tamika project board to fix the above hardware to, but you can of course use whatever you want. The Black and White pattern was fixed to the board purely to make movement of the controller more visible in the video.

Receiver:

  • Arduino - Ethernet or Wifi based. I used a Freetronics Etherten because it was what I had on hand.
  • AdaFruit Motor Driver - This regulates and makes controlling the servo's easier. (Approx. $20AUD)
  • 2 x Servo's - These are to pan and tilt the black and white pattern to mimic the movement of the controller. ($7AUD each)
  • 1 x Servo Chassis - This is a small metal casing used to house and connect the servo's in relation to each for easy tilting and panning. (Approx $12)
  • Polymorph plastic and screws - I used polymorph plastic as a quick prototyping tool build some struts that I attached to the overall chassis. These struts slotted in and supported the servo chassis.
  • Chassis - as per the Controller.

You'll of course also need an IBM Bluemix account for the connectivity IoT platform connectivity piece, but I would suggest watching part 1 of this series for that detail.

Having said that, this tutorial will walk through the above pieces in a fashion that you can learn the workings of each (i.e the accelerometer, servo's, and arduino) as separate pieces to be incorporated in to your own projects as you wish.

Step 1: The Controller

The controller is fairly straight forward and simply uses a 3-axis accelerometer to read the pitch and angle that you are holding the device at.

It then feeds the data of the X,Y, and Z axis of the controller up to the cloud to be interpreted and sent out to the receiver (or receivers if there are many of them) and translated in to a position to mimic the controller movement.

I have attached 2 Arduino sketches as examples.

  • The first is the sketch I have used in this project. The complexities in this script come mainly from connecting to the Watson IoT service, but in it's most basic form it's really just reading the 3 items of axis data and sending it up in to the cloud. I would suggest reviewing part 1 of this series to understand this code better.
  • The second sketch is the standalone script for the arduino. Use this to understand the Accelerometer in it's most basic form to incorporate in to your own projects.

I won't walk you through the code here as I have clearly documented each script in the attached files. They are very simple to understand.

The Zero G Pin

The above diagram includes an LED and Zero G pin which I have not used in this project, but I have included it to demonstrate the usage of the Zero G pin. This is used in the 2nd standalone sketch above.

The cool thing about the Zero G pin is that it can detect if you have dropped the device and deploy airbags or do some sort of protective maneuver. You'll notice that in the standalone code I have attached this as an Interrupt. This means that the code is alerted immediately and does not wait for the sketch loop to come around before executing a sub-routine to react.

What else can I use an accelerometer for?

As per the video above, accelerometers measure the G-Force of each axis. Therefore, they can also be used to identify the velocity of the device.

They can even help you to understand if your device is upside down so that you can take action to rectify it's stance.

More?

For more detail about the 3-Axis accelerometer you can get links and other information here.

Step 2: The Receiver

Now, all the wires in my pictures might look confusing, but it's actually pretty simple to hook up a servo motor.

There are literally 3 wires:

  • Power
  • Ground
  • Data

I have used an AdaFruit motor shield to drive these motors as I find the shields regulate the motors and control them better. It makes them more efficient without having to know how to hook up capacitors and other components. There are many motor shields out there you can choose from.

In my photos above, the wiring might look complex, but as per the diagram, each motor only requires the above 3 wires. For efficiency, I have attached the ground and power pins to a breadboard to be shared by the two servo's. Each servo then has their own PIN for positional data.

I have attached 2 arduino sketches as examples.

  • The first is the sketch I have used in this project. The complexities around this code are primarily with receiving the data from the Watson IOT platform. I would suggest reviewing part 1 of this series to understand this code better, but in it's most basic form, this sketch is merely receiving 2 numbers (the X and Y position) and telling the 2 servo's to go to those positions.
  • The second is the standalone script for the Arduino. Use this to understand your servo's in their most basic form and integrate them in to your own projects.

I won't walk you through the code here as I have clearly documented each script in the attached files. They are very simple to understand.

It's important to note:

Servo's can come as continuous or standard servos.

The standard servos have a limited movement range (generally 180 degrees) and the number of 0-180 sent through the data pin indicates the position the motor moves to.

A continuous servo moves continuously in a full circle motion and the number of 0-180 sent through the data pin indicates the speed (forward or backwards) the motor is moving at.

For this project I have used 2 x standard servos to position the pitch and angle of the pattern to mimic the controller.

The Build

The photo's attached give you a good indication of how this all hangs together, but the build itself really isn't that important to make this project work. I imagine you will use the ground knowledge of how this hangs together in various and alternate solutions that are far more inventive than what you see here.

I have included the above video about Shapelock (polymorph plastics) as I find it very useful to quickly prototype unique parts for my projects. You can find out more detail about polymorph plastics here.

There are a number of places that you can purchase the servo chassis from and I would suggest using these as they are fast and easy to implement.

Step 3: You're Ready to Go

So that's pretty much it!

Now whilst this project uses the IBM Watson IoT platform to connect these two devices together, there are of course many ways to push and pull this data.

The benefits of using the Watson platform range from speed of development to platform scalability. You could literally have 100 receivers subscribed to the data from one controller whilst ramping up or down that capability in minutes.

As mentioned earlier, the idea of this project is really to touch on the possibilities and give you a starting point for your own IoT based projects.

The following are some useful links mentioned throughout this instructable.

Watson IOT and Node-Red Controlled Robotics
https://www.instructables.com/id/Watson-IOT-and-No...

Accelerometers - LaikaBot
http://laikabot.com/modules_and_components/Acceler...

Shapelock and Polymorph Plastics - LaikaBot
http://laikabot.com/modules_and_components/ShapeLo...

Freetronics
http://www.freetronics.com.au

AdaFruit
https://www.adafruit.com/