Home

Wk11 - INPUT DEVICES

Group Assignment:
- Measure the analog levels and digital signals in an input device.

Individual Assignment:
- Measure something: add a sensor to a microcontroller board that you have designed and read it.


Individual Assignment

For the individual assignment I will design a board to connect different environmental sensors, process the data inside the ATMEGA 328P controller and send it via wifi network (ESP8266 wifi module) in a future, tanking the reference of the NodeMCU board.

I chose this board as it may fulfill all my future needs along the project in terms of pin connections, data processing in real time, provisional data storing and easy to get in most of the cases.

So far, I will make some testings on a board taking as a reference the Fabkit (version 0.4). This model is the most similar open source board regarding the Arduino UNO, so it can be easily updated and modified with extra shieldboards to add new functions and components in a sandwich structure.

sch
Fabkit v0.4 example


ATMega328P

The microcontroller used for the Fabkit v0.4, as the one used for the Arduino UNO, is the ATMega 328p.

This processor is much more powerful and versatile than the ATTiny44 microcontroller I used for the Embedded Programming assignment. On the following table we can see the main differences between both of them:

schsch
ATMega328P vs. ATTiny44 specifications

As a conclusion we could say the ATMega328P board can process way more data and do it faster than the ATTiny44 (PMS and SRAM: 8 times bigger; EEPROM: 4 times), and more connections at once (18 pins more).

(The ATMega328P pinout scheme can be found at the Board Programming section.)


DHT22 sensor

The first sensor I am using to test the board is the DHT22 temperature and humidity sensor. This component is widely used in many projects and fields, it is easy to plug and solder anywhere, it gets more accurate readings than other models like the previous one (DHT11) and here you can find more different aspects between both models.

sch
DHT22 humidity and temperature sensor

- Low cost
- 3 to 5V power and I/O
- 2.5mA max current use during conversion (while requesting data)
- Good for 0-100% humidity readings with 2-5% accuracy
- Good for -40 to 80°C temperature readings ±0.5°C accuracy
- No more than 0.5 Hz sampling rate (once every 2 seconds)
- Body size 15.1mm x 25mm x 7.7mm
- 4 pins with 0.1" spacing



Components

The components I am using for this assignment are listed below:

- Microcontroller: ATMEGA 382P
- Temperature + humidity sensor: DHT22
- Resistor: 10 kohms
- Resistor: 499 ohms
- Capacitor (unpolarized): 10 uF
- Capacitor (unpolarized): 1 uF
- Capacitor (unpolarized): 0.1 uF (x2)
- Resonator: 8 MHz
- LED: 1206SMD
- Switch: 6 mm
- Header: 6 pin
- Pin header: 8 pin

I chose to work with a ATMEGA 328P controller to have enough data space and power to process many sensors and sources of info at once. And also the DHT22 over the DHT11 as its much more precise in terms of obtaining the data on a range of decimals of ºC and humidity %.


Board design

Then I will design my board on Eagle. First I will check if all the components I need are indeed included in the downloaded libraries. Then in Eagle's schematics, I set all the components, connections, tags and values to create the Fabkit board.

sch

Then switching to Eagle's Board module, I finish setting the connections, and placement of the different elements. This is how it should look

sch

As all the elements are placed very close to each other, it is highly recommended to adapt the grid size so that the distribution is not so restricted and paths can be set easily.

sch

To prevent fails on the board production or connectivity, it is better to avoid 90 degrees angles in paths, so turning them into chamfers may help in the future.

chamfer

As this board design includes drilled connections to plug external pins, the process of producing the board will be different from the previous works. So, there will be 3 different .png files to prodjce the board:

- The inner milling drawing, activating the paths and pads' layers (without the drilling holes).
- The drilling holes drawing, just activating the pads' layers to know the position and diameter of the holes, filling them in Photoshop and removing the pads from the drawing, so there will just be all the white dots.
- The outer cutting drawing, creating the outer line in Photshop with a 16px thickness line.

fillpads

The first inner milling file will be set for a 1/64 endmill, and holes-drilling and outer cutting files with 1/32 endmill. The files are shown below:

inner
Inner milling file.

drillsouter
Drilling holes file + Outer cutting file.

Board production

After getting the .png files, I can make the .rml files on mods importing them and setting the Roland SRM20 milling machine's parameters for inner circuit, outcut and holes. Then soldering all the elements on the board.
wrong1

After milling the inner part, that went alright, I had problems drilling the holes on my board. The solution is to invert the drawing in mods, so that the mill doesn't go around the outter lines of the holes, but cut the inner part. So I tried it again inverting the holes' drawing.

wrong2

Once I finished milling the first file (inner part) I discovered the microcontroller connections on the board rised up suddenly. This may give me problems in the future, so I milled it again in a lower speed (80% in the Roland machine). And this was the result:

board atmega328p


Board programming

Before starting to program anything, I checked with the multimeter all the connections in the board, and I had to make several changes in some solderings, as all the elements were very close from each other. Then using the FabISP programmer and the Arduino software I will set a program to read the values from the DHT22 sensor.

First, I need to power my new board to start the process with the FTDI connection, keeping the black cable for the GND pin as a reference. I also need to check what is the ATMega328P pinout scheme:

atmega328p-scheme

Then from my FabISP board's SMT 2x3 connector, I send all the correspondent wires to the 8 serial pins connecting from right to left: RESET, VCC, GND, SCK (LED), MISO and MOSI.

board atmega328p

Before starting with the programming, I will test first the Blink example on the board to see if all the settings are fine.

test blink program

And here the visual proof:

test blink light

Next, I had to download the DHT sensor library for Arduino:

library manager

As well as the board config for ATMega328P, setting the next URL on Arduino's Preferences menu on Boards Manager: https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json

board manager

And I tried to start checking the board by programming with simple examples like the blink or the LED+button sketches.

For testing my board with the sensors, I am placing the circuit onto a protoboard first instead of making a single new board for the sensor, as for further exercises of input (anemometer or pluviometer) and output components (lcd display and bluetooth/wifi module) I will need to bring them altogether into the same shield board.

This is the connection I made with my Fabduino + FabISP + DHT sensor and 4.7Kohm Res in protoboard:

dht connection

Trying to compile the program I got this error:

error compiling

Then I noticed I also needed to add an Adafruit Sensor Library from github. So I downloaded and installed it on Arduino.

library manager

I programmed the board with the DHT sensor preset testmode to see the first results.

add library

Input data results

After having programmed and tested the board,

monitor arduino

dht-error

dht-results

dht-results2