Week 11: Input

This week we have to measure something: add a sensor to a microcontroller board that I have designed and read the value.


temp ready!

Designing : Temperature board

I took the exemple that was on Neil's page and redesigned it on Eagle: how I copied

Using the fab library made it easy to find each component, and using the auto-router option in Eagle made me win some time:

temp board 1 (try to avoid 90° angles!)

Then I exported le first layer in monochrome to send it to the Fabmodules: png for fabmodules 1

And the outline also:

png for fabmodules 2

Here are the.rml files to send to the machine:

  • traces
  • contour

  • After a bit of soldering and testing with a multimeter here is my temperature board:

    temp ready! Settings:
  • Tool: 10° conic
  • Traces: 0,4mm
  • Depth:0,06mm

  • The component you see on the side is the actual NTC resistor, it as just a resistor which value depends on the temperature.



    Programming

    Settings:
  • OS:Ubuntu 14.4
  • IDE:Arduino 1.05

  • I am going to program the Temp Board like for the other boards, I need the archive hello.temp.45.c to generate the hex, and the makefile to build the file hello.temp.45.hex.

    I already used both Arduino and the terminal to flash my boards, but since I wanted to run the Python script I did it on a terminal.

    I installed Arduino (on Ubuntu there is only the 1.05 version),from the terminal:

  • "sudo apt-get update && sudo apt-get install arduino arduino-core"
  • I installed AVRDUDE and GCC from the terminal:"

  • sudo apt-get install gcc-avr avr-libc".
  • I dowloaded the files from the Fabacademy page :

  • hello.temp.45.c
  • hello.temp.45.make
  • hello.temp.45.py

  • These contain all the different codes that you need to program your board and also create a graphical interface with Python.

    I then plugged my board to the FabISP (the FabISP to my computer with the USB cable) but also the FTDI cable:

    png for fabmodules 2

    Opened a terminal where I had my files: :

  • sudo make -f hello.temp.45.make program-usbtiny
  • And obtained:

    hex file

    Then I flashed the board :

  • "sudo avrdude -p t45 -c usbtiny -U flash:w:hello.temp.45.c.hex
  • So everything went find (for the first time!), next I wanted to have some kind of GUI to display the temperature.

    To do so, I used the python script that is on a Neil's Page:

  • hello.temp.45.py

    Before need to install the Python TK in UBUNTU enviroment, and use the correct serial port. For that we must open the terminal , as administrator and typing:

  • "ls /dev"
  • We find "ttyUSB0" (port 0) , next we can then use the python code:

  • "python hello.temp.45.py /dev/ttyUSB0"
  • I had a problem: COULD NOT FIND NUMPY-> so I installed anaconda which is supposed to have all the librairies for python. But numby wasn't installed so tried "install numpy" but apparently I needed to install "pip".

    Installed pip and then numpy : "sudo apt-get install python-pip"

    Maked sure I had the latest version "pip install --upgrade pip"

    So first install pip and then numpy.

    So i retried : "sudo python hello.temp.45.py /dev/ttyUSB0".

    But I had an error about "serial" that wasn't found, so : "pip install pyserial".

    I still had problems with python that could not find numpy, closed everything, tryed to uninstall numpy : "pip uninstall numpy" and reinstalled it : "pip install numpy".

    This solved my "numpy" problems! I then typed : "sudo python hello.temp.45.py /dev/ttyUSB0"

    Here is the victory screenshot:

    png for fabmodules 2

    And a little video where I test the sensor with my finger:

    ANd here you can see the GUI a little better as I blow air on the NTC resistor (goes from 20 to 30°C):


    I would like to to a last test to try to read the values with the Arduino IDE and display them in the serial graphic (problems with Arduino 1.6 and some lib for the moment..)



    Learn Make Share