Apr 26: input devices
The task for this week was to measure something: add a sensor to a microcontroller board that you have designed and read it. You can programm the board afterwards with either the Arduino IDE or CCode in Terminal, xcode or pycharm.
Designing the temperature sensor board
I decided to make the temperature sensor. First I started with adapting Neils files in Eagle and build the Schematics up. I also decided to integrate an LED to see if my board works and also can code my temperature sensor so the LED lights up when it is under or over the programmed temperature. I put the connection for the LED in the "MOSI" pin because I only need the "MISO" and "MOSI" pins to programm afterwards.
Milling again in the Roland SRM-20
Next step was to put my exported png files to the
fabmodules and set it up for the Roland SRM-20 one again. I made a small video so you can see the progress of milling the traces and the lines. I have to say I am getting better at it. This time it only took thirty minutes milling time ;)
Soldering the temperatureboard
I am getting quite good in soldering now after all the boards we already did so I searched all the components and voila a couple of minutes later the board were ready to programm.
The components I am used are:
4 Resistor 10K
1 Resistor 499
1 3x2 Pinheads connector
1 6 Pin SMD Type Male Headers
1 Capacitor 1uF
1 Force sensor (for the temperature)
Starting to programm the board in Arduino IDE
Then I setup my PCB board and tried to programm it, which of course didn't worked out at the beginning. I tried to debug it but doesn't found the failure. After somebody pointed us that we connected the smd header wrong ;) Oh well you fail and learn. Then I started to make a small code in Arduino to measure the temperature and have an input. I needed to include the "SoftwareSerial" library to get my first input in the "SerialMonitor". Then I need to change the parameters for the Softwareserial which was when the link to SoftwareSerialPrint from Arduino came in hand. And of course you need to define the right pins for the attiny45 if you want to use the Arduino IDE. At the end I tried another code that my input will read the voltage, celsius and fahrenheit. Somehow it didn't turned out really well, because I never found a datasheet for the force sensor.
Programming in ccode and terminal
First of all I downloaded the Cfile, Makefile, and the Pythonfile. Next I fired up terminal go to the right directory and create the hex file with the command "make -f hello.temp.45". Then I set up to program my Attiny45 with my fabisp with the command "make -f hello.temp.45.make program-usbtiny". Last step was to run the Python file. For that you need to know which USB Port you need. Simple trick just type "/dev/tt.usb*" in terminal and it shows you the name of the port ;) Then I run the python file like this "python3 hello.temp.45.py /dev/cu.usbserial-FTH88ZAY". You see that I need to also type "python3" in the command so it recognizes my python software I used at the moment.
Programming in PyCharm with pythoncode
Next coding language I wanted to try was the python code in
PyCharm. For that I started to doing a little bit more tutorials in Codecademy. I needed to adjust a lot of stuff in the script because I was running on two different versions from Python. I fond a lot of useful links to adjust for example the numpy log or to code "#!/usr/local/bin/python3
# -*- coding: utf-8 -*-" so my computer knows that I am running on python3. At the end it worked out quite well. Now I only need to get my LED lighting up when the temperature gets below or above the programmed degrees. For that I need to dive deeper into the world of ccoding.
Click here to download all the files.