Getting Started

Signup with if you haven’t yet. The free account will have sufficient credits to run this project. Once you are logged into the IoTIFY main application, go to the virtual lab and click on the Hello Motor project.

Provide a unique name for your project. Then simply click launch.

The project takes 3-5 minutes to launch. The project state will automatically change to running once it is ready. You could then simply click the Open button and it will launch a new window with the Workspace of the project.

The web view has a stepper motor, 4 knobs, few switches, and LEDs.All of these internally connected to an emulated raspberry pi 2, so that you can interact with the corresponding peripheral from the terminal by the programming.

The project contains a stepper motor connected to raspberry pi GPIO via driver IC ( DRV8834 By texas Instruments) The driver IC is connected via GPIOs.

The 4 knobs, Whose output is an analog voltage, are connected to an analog-to-digital converter (ADS1115 Texas Instruments), Which is connected to the emulated pi via I2C (Inter-Integrated Circuit) as we are not having any analog GPIO in our Raspberry Pi. You can read the voltage rating by reading from the ADC via I2C.

The web view contains the LEDs and Switches that are connected directly to the Raspberry pi GPIO.

Physical connection of stepper motor with Raspberry Pi

Now, below fig. Shows the Physical connection of stepper motor with raspberry pi (Here we have used DRV8834 Texas Instruments IC as a stepper motor driver).

Reading the analog voltage

Open a console terminal to get ssh access. The source code for the project is already downloaded in hello-motor directory. Here we have two python scripts – one for the motor and one for the ADC converter.

Reading analog voltage values from Pi

The script in hello-motor directory continually polls each of the 4 analog inputs of ADC. We type the following commands in our console and you can see the analog voltage values.

cd hello-motor
sudo python

Now, if we go to the web view and try to move any of the 4 knobs, we see in the console output the corresponding voltage values are changing.

The voltage knobs are simulating 4 analog channels and software is reading values of those channels via A2D converter. Those 4 channels could represent any 4 analog values such as tilt values at drone wings or tyre pressure of 4 tyres. The software continuously monitors the analog values and based upon that it takes certain actions.

The code is as follows:
import time
# using the ADS1x15 module from Adafruit.
import Adafruit_ADS1x15
adc = Adafruit_ADS1x15.ADS1015(busnum=1)
GAIN = 1
print('Reading ADS1x15 Input voltage values in millivolt, press Ctrl-C to quit...')
# Print nice channel column headers.
print('| {0:>6} | {1:>6} | {2:>6} | {3:>6} |'.format(*range(4)))
print('-' * 37)
#main loop
while True:
# Read all the ADC channel values in a list.
values = [0]*4
for i in range(4):
# Read the specified ADC channel using the previously set gain value
# at PGA setting 1, 2047 steps correspond to 4096 millivolt
values[i] = adc.read_adc(i, gain=GAIN) * 2
# Print the ADC values.
print('| {0:>6} | {1:>6} | {2:>6} | {3:>6} | (millivolt)'.format(*values))

One can go over the documentation of ads1x15 library by Adafruit by clicking on the link given above.