IoT Stepper Motor

IoT Stepper Motor © LGPL

IoT showing how to control a Stepper Motor "knob".

  • 4,483 views
  • 0 comments
  • 13 respects

Components and supplies

Apps and online services

About this project

The Internet of Things (IOT).

is a new emerging technology these days, a self configurable and adaptive system consisting of networks of sensors and other object including intelligent objects whose purpose is to interconnect with all things, including everyday and industrial objects, in such a way that they become intelligent, programmable and more capable of interacting with humans.

All the applications that involve IOT, whether industrial, home, etc. Are controlled and monitored by certain parameters which are implemented and executed by the user or "other". Therefore, their implementation and execution differs with the sets of parameters, for the execution that is specified or desired by the user.

Arduino board is one of the important objects in this ecosystem, since it facilitates us to connect and control different devices like sensors, LEDs, step motors, servos and mobile phones.

This tutorial describes how to create an Internet of Things with Android and Arduino:

Android Application to control a Stepper Motor "knob" according to user button slider input. All objects are in the same network for simplicity.

The above images shown a above diagram of the system. It consist of 1 Stepper Motor of 200 steps 1.8° which is capable of rotate 200 steps per rotation this means that for each step it rotates approximately 1.8° (360/200).

This is then interfaced to the microcontroller and the stepper motor driver from adafruit v1.1, "you can use any other" the Arduino Micro.

Then we have IOT implementation taking place with the help of CC3000 which is then allowing us to upload the parameters which are displayed using mobile App which in this case is above is a hosting platform.

The mobile device sends information to the IOT "CC3000" which is interfaced with the Arduino Micro, the Motor Shield and the stepper motor, this information is obtained from the knob switch in the app, and is sent to the Arduino Micro by means of a UDP server that runs on the mobile app and with the help of the CC3000, this way the motor shield can drive the stepper motor.

Code

ATmega32u4_WiFiStepperKnob.cppArduino
/*
*	Author		: Zavala Ortiz Vicente Arturo.
*	language	: .cpp
*	Created		: 3/11/2015 11:56:57 AM
*	Name		: ATmega32u4_WiFiStepperKnob.cpp
*	Update		: 1/9/2017 02:29:15 PM
*	Description : wifi Socket Client
*/

#include <util/delay.h>
#include <stdlib.h>

#include "CC3000.h"
#include "CC3000_Client.h"
#include "AFMotor.h"
#include "common.h"

/*****		wifi Global Variables		*****/
// Connection info data lengths
#define MAX_MSG_LEN							100
#define DHT11_PIN							0
// Constants

char ap_ssid[]				= "SSID of network";	    // SSID of network
char ap_password[]		= "Password of network";	// Password of network

unsigned int ap_security	= WLAN_SEC_WPA2;	  // Security of network
unsigned long timeout		  = 3000;            	// Milliseconds

// Global Variables
CC3000 wifi						= CC3000();
CC3000_Client client  = CC3000_Client(wifi);

char in_message[MAX_MSG_LEN]	= {0};

/*****		Other Global Variables		*****/
static char page[20], data[20];
signed int option, value, out, stepper2_actual_value = 0;

void setup()
{
	/* add setup code here */
 	ConnectionInfo connection_info;
 
 	// Initialize CC3000 (configure SPI communications) 	
 	Serial.begin(115200);
 	 
 	// Initialize CC3000 (configure SPI communications)
 	if(!wifi.init(9)) {
 			Serial.println("Initialize CC3000 FAIL!");
 		return;
 	}

	else {
		Serial.println"Initialize CC3000 OK");
	}

	if(!wifi.connect(ap_ssid, ap_security, ap_password, timeout)) {	
		Serial.println("Error: Could not connect to AP!");
	}

	else
		return;
	
	
	_delay_ms(5000);
	
	// Gather connection details and print IP address
	if(!wifi.getConnectionInfo(connection_info) )
	{
		Serial.println("Error: Could not obtain connection details");
		return;
	}
	
	else 
	{	
		Serial.println("IP Address: ");
		printIPAddr(connection_info.ip_address);
	}

	_delay_ms(5000);
}

uint8_t i;

void loop()
{		
	/* add main program code here */
 	Serial.println("WAITING FOR MESSAGE!");

	fulsh_buffer(in_message);

	if(client.readfrom(4444, in_message, MAX_MSG_LEN) == -1) {
		Serial.println("NO MESSAGE RECEIVED");
	}
	
	Serial.println(in_message);
			

  if(client.readfrom(4444, in_message, MAX_MSG_LEN) == -1) {
	  Serial.println("NO MESSAGE RECEIVED");
  }

	else
	{
	  stepper2.setSpeed(200);

		if(http_gets(data, "stepper_motor2", in_message)) {
		  value = atoi(data);
							
			if(value > 0) {
				  stepper2.step(value, FORWARD, SINGLE);
			}

			else if (value < 0) {
				  stepper2.step(value, BACKWARD, SINGLE);				
			}
	}
	
	fulsh_buffer(in_message);
}

Custom parts and enclosures

IoTStepperMSchm
iotsteppermotorknob_6KrN5IEJ0J.sch

Schematics

IoTStepperMSchm
Iotsteppermschm krqk28bjef

Comments

Similar projects you might like

IoT Arduino Ball Tracking

by vicente zavala

  • 2,737 views
  • 4 comments
  • 8 respects

IoT Dimmer

Project showcase by vicente zavala

  • 2,425 views
  • 0 comments
  • 6 respects

IoT Face Tracking and Recognition

by vicente zavala

  • 7,248 views
  • 1 comment
  • 21 respects

IoT Speech Recognition

by vicente zavala

  • 5,686 views
  • 0 comments
  • 14 respects

IoT Blink - Getting started with IoT

Project showcase by AppShed Support

  • 2,239 views
  • 1 comment
  • 13 respects
Add projectSign up / Login