KEMBAR78
EDC Lab 7 PDF | PDF | Printed Circuit Board | Electrical Connector
0% found this document useful (0 votes)
12 views10 pages

EDC Lab 7 PDF

Uploaded by

amare3088
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views10 pages

EDC Lab 7 PDF

Uploaded by

amare3088
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Lab 7 - Jupyter Notebook 1/17/20, 9:26 AM

Lab 7: Revisiting Humidity Sensor with


PCB
In this lab we will revisit using the humidity sensor, except we will now use the PCBs we
created in the previous lab to higlight how it works and how much cleaner our circuit will
look. Furtheremore, we will learn how to store the data from the sensor into Excel for data
analysis.

Background
In order to use our sensors on this PCB we will have to solder the sensors to the three pin
wires as shown below.Below is a diagram of the humidity sensor and its pin and the wires
we will connect it to

http://localhost:8888/notebooks/Desktop/EDC%20Labs/Lab7/Lab%207.ipynb Page 1 of 10
Lab 7 - Jupyter Notebook 1/17/20, 9:26 AM

http://localhost:8888/notebooks/Desktop/EDC%20Labs/Lab7/Lab%207.ipynb Page 2 of 10
Lab 7 - Jupyter Notebook 1/17/20, 9:26 AM

This is what the sensor should look like once soldered

Now this sensor will be able to be plugged into any of the three pin connectors on our board.
However for programing purposes it is important to remeber that the three pin connector
closest to the ESP8266 is connected to Digital Pin D0 (pin 16 in the code) and the furthest
three pin from the ESP8266 is connected to Digital Pin D1 (pin 5 in the code).

http://localhost:8888/notebooks/Desktop/EDC%20Labs/Lab7/Lab%207.ipynb Page 3 of 10
Lab 7 - Jupyter Notebook 1/17/20, 9:26 AM

http://localhost:8888/notebooks/Desktop/EDC%20Labs/Lab7/Lab%207.ipynb Page 4 of 10
Lab 7 - Jupyter Notebook 1/17/20, 9:26 AM

Code
Before programing make sure to download Tera Term for the lab folder. This program will
take any sensor data to an excel sheet.

Sensor Code:

http://localhost:8888/notebooks/Desktop/EDC%20Labs/Lab7/Lab%207.ipynb Page 5 of 10
Lab 7 - Jupyter Notebook 1/17/20, 9:26 AM

In [ ]: #include “DHT.h”
#define DHTPIN 2 // what digital pin we’re connected to

// #Uncomment whatever type you’re using!

#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
Serial.println("Date & Time, Humidity %, Temperature *C, Temperature *F"
dht.begin();
}

void loop() {
// Wait a few seconds between measurements.
delay(1000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print(",");
Serial.print(h);
Serial.print(",");
Serial.print(t);
Serial.print(",");
Serial.println(f);
}

Explanation

Depend upon your sketch you can decide how many numbers of columns you require.

In [ ]: Serial.println("Date & Time, Humidity %, Temperature *C, Temperature *F"

http://localhost:8888/notebooks/Desktop/EDC%20Labs/Lab7/Lab%207.ipynb Page 6 of 10
Lab 7 - Jupyter Notebook 1/17/20, 9:26 AM

We want 4 columns first column is for date & time. But make sure each column is separated
with comma (,). Then second column is for humidity then temperature in Celsius &
temperature in Fahrenheit. And also make sure it is printed in new line.

In [ ]: Serial.print(",");
Serial.print(h);
Serial.print(",");
Serial.print(t);
Serial.print(",");

Data Analysis

After loading the code onto the ESP8266 we will do the following

Now open the tera term software and select serial and port:

Go to file and click on log:

http://localhost:8888/notebooks/Desktop/EDC%20Labs/Lab7/Lab%207.ipynb Page 7 of 10
Lab 7 - Jupyter Notebook 1/17/20, 9:26 AM

Check the box timestamp because we want date and time also. It will ask where we want to
save this log file. I am saving it on desktop. Make sure you save it with .csv file. So it will
create excel sheet. After saving log file press reset button on Arduino.

http://localhost:8888/notebooks/Desktop/EDC%20Labs/Lab7/Lab%207.ipynb Page 8 of 10
Lab 7 - Jupyter Notebook 1/17/20, 9:26 AM

http://localhost:8888/notebooks/Desktop/EDC%20Labs/Lab7/Lab%207.ipynb Page 9 of 10
Lab 7 - Jupyter Notebook 1/17/20, 9:26 AM

Now open the excel file that you created highlight the data and click insert and select line
graph. If done correctly, the following graph will be created:

http://localhost:8888/notebooks/Desktop/EDC%20Labs/Lab7/Lab%207.ipynb Page 10 of 10

You might also like