TODO LIST




Introduction

In this week assignment is to conect a Sensor or any input devices to a microcontroller then Read the values reading by the sensor and then display the values in PC using a UART communication. We have a few sensors in our fablab PIR, Ultrasonic, Phototransisitor etc... some of them. However first i need to select wich microcontroller that iam going to use. Then i need to select wich sensor that i need to conect with the microcontroller. As we do for all electronics based week, First i need to design and millout the PCB.



Sensors

In the broadest definition, a sensor is a device, module, or subsystem whose purpose is to detect events or changes in its environment and send the information to other electronics, frequently a computer processor. A sensor is always used with other electronics, whether as simple as a light or as complex as a computer. Learn more from here. We have different type sensors are available in the market with high quality sensitivity level. But sensors are comes mostly in two type ANALOG sensor and DIGITAL sensor. The Analog sensors can serve a percisional reading because it can give us analog output. So a small fluctuations in the sensitiviy can be read by using analog sensors. But the digital sensor's sensitivity is great, but we could get the digital reading of the sensor (0 & 1) technically HIGH and LOW values. So in some cases digital sensors are better to use. But if you need precisional reading its better to use analog sensors. I will expain more about in the group assignment section.



Fab Temperature and Humidity Tester

SO first my idea is to make a Fab Temperature and Humidity Teseter. Recently in our Fablab, some of the 3D filaments are ruined because of the room tempertaure and humidity. The room temperature and temperature exceeds. This will cause the 3D printer filaments for our Ultimaker2. So to avoid this problem. I decided to make a temperature and humidity tester. I decided to use attiny45 microcontroller and DHT11 as the sensor and i2C 128 x 64 OLED display to display the values.



DHT11: Temperature and Humidity Sensor

Iam going to use the DHT11 temperature and humidity sensor to read the temperature and humidity values. The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed). Its fairly simple to use, but requires careful timing to grab data. The only real downside of this sensor is you can only get new data from it once every 2 seconds, so when using our library, sensor readings can be up to 2 seconds old.Learn more.




passive infrared sensor (PIR sensor)

Iam goint to use a PIR sensor also in this week. PIR sensors allow you to sense motion, almost always used to detect whether a human has moved in or out of the sensors range. They are small, inexpensive, low-power, easy to use and don't wear out. For that reason they are commonly found in appliances and gadgets used in homes or businesses. They are often referred to as PIR, "Passive Infrared", "Pyroelectric", or "IR motion" sensors.Learn more.




PIRs are basically made of a pyroelectric sensor (which you can see below as the round metal can with a rectangular crystal in the center), which can detect levels of infrared radiation. Everything emits some low level radiation, and the hotter something is, the more radiation is emitted. The sensor in a motion detector is actually split in two halves. The reason for that is that we are looking to detect motion (change) not average IR levels. The two halves are wired up so that they cancel each other out. If one half sees more or less IR radiation than the other, the output will swing high or low.



PIR sensors are more complicated than many of the other sensors explained in these tutorials (like photocells, FSRs and tilt switches) because there are multiple variables that affect the sensors input and output. To begin explaining how a basic sensor works, we'll use this rather nice diagram The PIR sensor itself has two slots in it, each slot is made of a special material that is sensitive to IR. The lens used here is not really doing much and so we see that the two slots can 'see' out past some distance (basically the sensitivity of the sensor). When the sensor is idle, both slots detect the same amount of IR, the ambient amount radiated from the room or walls or outdoors. When a warm body like a human or animal passes by, it first intercepts one half of the PIR sensor, which causes a positive differential change between the two halves. When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These change pulses are what is detected. Source






Designing and milling the PCB

Now i need to design the schematics and PCB in eaglePCB. Then i need to millout the PCB. As i said earlier, i need to make a Fab Temperature and Humidity tester for our fablab. Iam using DHT11 as the sensor and a 128x64 OLED display to display the reading from the sensor. The OLED display work in low power beacause it doesnt need a backlight i will explain all the charatristics in the output device week. But now decide to include the OLED display also in the PCB design. So doesnt need to make another PCB in the Output week. I started to design the Schematics and then the PCB. However the DHT11 footprint comes in handy, because i can solder a female header pin and use any of the sensor using jumper wires. So i can try the PIR also on the DHT11 pins. I also added a Micro USB port to external power the board. Included all the files in the resource download area.









Milling PCB using Modela MDX20

Now i need to millout the PCB. SO i usually do, i used the Modela MDX20 PCB milling machine. Then followed the usual process for PCB milling. First i drilled the holes for the through hole components using the 1/32 bit and the milled the traces of the PCB using a 1/64bit after that i cutout the PCB using 1/32 bit. After i take out the PCB from the Bbed. i cleaned the PCB before placing the component. Then tested all traces doesnt have any break but i found a mistake in the PCB. But its not completly my mistake. It is the mistake of the OLED display library. I will explain it later.










Mistakes in PCB

I already said about some mistake in the PCB. Not a big mistake but it is a mistake. The mistake came from the OLED display foot print parts. The OLED display pinouts and the Footprint of the Pads doesnt matching. So now i need to redesign the PCB with a appropriate OLED disply eagle librray or make one myself. But this mistake will not affect in this week. So decided to do this week with this PCB because others are waiting to mill their PCB. So i decided to redesign the PCB in output devices week. Un fortunately The micro USB that iam soldered on the PCB was ripped of from the PCB while iam troubleshooting the PCB, because of too thin traces.









Soldering the components on the PCB

Now i need to solder all the components on the PCB. i started to solder the attiny45 and then all the smd passive components. After that i solder the MIcro USB into the PCB. Atlast soldered the Header pins to the PCB.












Software Serial in ATtiny45 : Arduino IDE

I need to display the readings of the sensor in my PC. So i need to use UART communication in attiny45 and use a USB to TTL converter to conect with the PC. But the Attiny45 does not support Hardware Serial. So the only way is to use the Software Serial in ATtiny45. But it should laed me into a big problem. The Attiny45 have 4KB flash memory. The memory is not enough to use both software serial and DHT11 library in arduino. But i should try. I used a PLC2303 based USB to TTL converter to do the Serial communication with my PC. i assigned the PB3 as RX and PB4 as TX pin. i conected VCC, GND, RX and TX pins to the USB to TTL conveter uisng some Female Female jumper wire. Now the Serial communication wiring is complete.









Programming the Board using Arduino IDE

I conected my board to the pc using the FabISP.Then open the ARduino IDE. I wrote a basic code to use software serial in attiny45. I selected the board as I uploaded the code using the FabISP. I explained the process to upload code using arduino in visit my week 7. But select the Attiny45 insted of attiny44. AFter uploading the code to the Attiny45. i conected the USB o TTL converter that i pluged with the ATtiny45 board to the PC. Now a RED led glow for power indication. If the ATtiny45 sending anything through the software serial, then a Blue led starts to blink or glow.







If you doesnt install the drivers for the PLC2303, download it from here. I downloaded the driver then installed in my computer like as we install all other drivers. After successfully install the driver. go to the Device manager in windows PCs. Select ports. Then you can see the PLC2303 there with its Port Number. Copy down the Port number for later use.




Now, We need to open the Serial Monitor window in arduino. Just got the the ARduino -> tools -> ports -> Select the Port of the PLC2303 -> Then Click on Serial monitor(ctrl+Shift+m). Now in the Serial monitor select the Appropriate Bauderate that you given in the code. In my case it is 9600 Baudrate.




You can see the screenshot of my Serial monitor window below




Software Serial: Arduino Code

#include <SoftwareSerial.h>



#define RX    3   // RX pin
#define TX    4   // *TX pin

 SoftwareSerial ss(RX, TX);
 
void setup() {            

 
  ss.begin(9600);
  
}

void loop()
{

  ss.println("Iam working dude!");

}




Read DHT11 Sensor along With Software Serial

So. now i conected the DHT11 to the PCB. Inorder to us ethe DHT11, i need to use a DHT11 library.Iam using Adafruit's DHT11 library. You can find the arduino library from Here. Just download and add it into you arduino.




After then i wrote the code to read the humidity and temperature and send them in to software serial lines. But things goesn in a wrong way. The sketch is exceeded the Flash memory. The arduino is showing an error message that the code is too big. Almost took 118% of the flash memory. This is happened by two libraries that iam using. So i have only one choice now, i need to change the microcontroller to any other microcontroller that have a bigger flash memory. So, i decided to completly redesign the board in output week with Atmega328p microcontroller.






DHT11: Arduino Code


#include "DHT.h"
#include <SoftwareSerial.h>


#define DHTPIN 1     // what digital pin we're connected to
#define DHTTYPE DHT11   // DHT 11
#define RX    3   // RX pin
#define TX    4   // *TX pin

 SoftwareSerial ss(RX, TX);





DHT dht(DHTPIN, DHTTYPE);

void setup() {
  ss.begin(9600);

  dht.begin();
}

void loop() {
 

 //read humidity
  float h = dht.readHumidity();
  // Read temperature as Celsius 
  float t = dht.readTemperature();

  ss.println("Humidity: ");
  ss.println(h);

  ss.println("Temperature: ");
    ss.print(t);
  
}



Read PIR Sensor along With Software Serial

After a failure attempt with DHT11 sensor with attiny45 microcontroller. I decided to try the PIR sensor along with the software serial. I conected the PIR sensor to the board using female to make header pins. I used the same pins that i used to conect DHT11. Then i wrote a simple code read the PIR sensor and the values through Serial lines.











DHT11: Arduino Code

#include <SoftwareSerial.h>



#define RX    3   // RX pin
#define TX    4   // *TX pin

 SoftwareSerial ss(RX, TX);
 
void setup() {            

 
  ss.begin(9600);
  
}

void loop()
{
int val = digitalRead(1);
  ss.println(val);

}




Group Assignment

We tried to do our grooup assignment. Unfortunately we have only one Osciloscope Unisource DS-100. It should not have the feature to display the analog and digital value messurements in ASCII format. The group Assignmnet we need to measure the analog levels and digital signals from an input device and display then is Osciloscope.It doesn't have an ASCII text / binary decode function. Datasheet

Download Resource Files