Welcome to Berytech Fab Lab
So the objective of this week is to get introduced to using Code to Create Applications that Interface with input and output devices.
According to Wikipidia, "In computer programming, an application programming interface (API) is a set of subroutine definitions, protocols, and tools for building application software. In general terms, it is a set of clearly defined methods of communication between various software components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer. An API may be for a web-based system, operating system, database system, computer hardware or software library. An API specification can take many forms, but often includes specifications for routines, data structures, object classes, variables or remote calls. POSIX, Windows API and ASPI are examples of different forms of APIs. Documentation for the API is usually provided to facilitate usage and reimplementation." There are many laguages that could be used to build applications that interface with Input and Output devices. Out of which are C++, JAVA, Python, Arduino, and Processing.
In this section, we will learn on how to collect data from sensors through a microcontroller, and how to use coding to Simulate and Visualize the measurements in Graphical representations.
Group Assinment
The group assginment was to Compare as many tool options as possible.
An application program interface (API) is a set of routines, protocols, and tools for building software applications. Basically, an API specifies how software components should interact. Additionally, APIs are used when programming graphical user interface (GUI) components.
The assignment this week was to Compare as many tool options as possible.
So our idea was to compare the various options we can use to interface with out inputs and otputs.
We tested the Processing language with an input such as a potentiometer. The code plots the variation of the potentiometer. We also tried the same application with Python. Many examples of similar codes are available online, such as in the arduino Library: Arduino tutorial
Arduino code
Processing code
Board
Processing plot
Given that the stepper motor is my main output device, I tried to write an application to interface a stepper motor to my computer through my board. I used Python to write a small application That send the pulse rate to the microcontroller which will make the motor turn accordingly. A counter is incremented at each iteration and printed on the screen. The microcontroller code is written in Arduino language.
The python codes require installing the serial and wxPython libraries with commandes: pip install PySerial
The board is connected to the PC with an FTDI cable. The port number can be read in the Device Manager in the Control Pannel
Arduino code
Python code
Running first code
After getting started with a simple Python code I tried to write a more complex code with a graphic interface using the wxPython library. The code take as input a pulse number and sends it to the microcontroller via serial which turns the stepper motor one step according to the value of the pulse. The Arduino code is the same.
The python codes require installing the wxPython library with commandes: pip install -U wxPython
Python code with graphic interface
Interface
Running second code
Blynk is a simple and easy to implement user interface, it facilitates the access to our project via mobile phone.
Since my App will receive data from the PCB, like the Humidity level and the Dehumidifier status (On/Off), I used as a reference the below example "DHT 11" from the official Blynk website.
Reference Blynk.