Assignment 16                                          17.5.2017

Topic: Interface and Application Programming

Write an application that interfaces with an input and/or output device that you made, comparing as many tool options as possible.

Learning outcomes:

Have you:

Processing

My interface software was Processing. It is totally new for me. I installed it from page: https://processing.org/. Further, I found two example codes there. The one processed basic drawings (https://processing.org/reference/loop_.html) and the second keyboard communication (https://processing.org/reference/keyCode.html). Then, a lot of coding, trials and errors, and I coded following test program, which changes brown color height in yellow color background if I pressed up and down buttons in keyboard.


fab hui






Command size() set the display window size.

Here command noLoop() runs once the setup() function when the program begins.



Command Rect() draws a rectangular which width is same as window and height as window height - y.  It's color was set by command fill().



Value y changes depending of keyboard commands: UP key increases the y and DOWN decreases it by amount of 20.


Command loop() here activates looping draw() function again when keyboard key is pressed. 



Next task was connection and communication of my Node with this program. The Node is explained more deeply is assignment 15. I used Wemos D1 Mini Pro as a serial interface to my computer similarly as FTDI cable would serve. It is 32-bit 80 MHz ESP8266 microcontroller board and include Wifi functioning. Wemos used operating voltage and I/O levels as 3.3 V. It generates 3.3 V and 5 V from USB source. I used it's 3.3 V pin as voltage source for my Node (Attiny45). Therefore, it operated also as  3.3 V I/O level and communicated via TX and RX pins with Wemos. Empty code programmed to Wemos served as serial interface to my Node board. Node sent AD results as one  8-bit value, between 0 - 255. Thus, this value might set the brown rectangle height and describe the temperature variation. I imported serial library for serial communication by command: import processing.serial.*;.  Command my_port = new Serial(this, "COM3, 9600); sets serial port for use. Command while( my_port.available() >0 ) checks the usage of the serial port. And, my_port.read() reads the data from the serial port. I used voltage divider as temperature measurement, where NTC resistor locates between ADC pin and ground.


hui 03

Empty code for Wemos looks like this:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}














I added also temperature calculation to my Processing code. I picked equation from Neil's hello.temp.45.py code, but I confirmed it also from several sources.

hui 5

I can read my board data also to Matlab and draw figures, for example. My serial interface, Wemos board, seems as serial port (COM12) to Matlab. I set it's properties, open it, and read data to buffer by fread(s) command. Then, I plot a graph, close serial port and delete all communication ports, that I can use it again.

matlabmatlab

I'm interested to do HTML code, also. Here is a simple web interface to my temperature measurement board, my Node. I use ESP8266 wifi features in my Wemos board.

I programmed it in Arduino environment and used my mobile wifi to connect Wemos and my laptop to the same network. My Node and Wemos produce web server and I can read it using web browser on my laptop.

esp

Original codes for Processing are here: FAB_temp02 and FAB_temp03 .


Post-registered note

I added video explaining the operation of my interface.