top of page
  • Writer's pictureAlan Seder

EDTEC 568 - Arduino Challenge - The Fifth Week

Updated: Dec 5, 2020

Welcome to the fifth week of EDTEC 568 - Makerspaces Build Challenge. This week's challenge I chose to build a simple Weather Station that reads humidity and temperature using an DHT11 sensor and light level using a photoresistor circuit. After some processing of the inputs the results are printed to a serial monitor and an LCD. While the circles are fairly simple (with the possible exception of the LCD which has many connections), the idea this week was to do a project that required inclusions of libraries and use of their functions, and to build some skills at printing output to a serial monitor and an LCD. To begin, we will take a look at the Weather Station project code I generated in Sketch on the Arduino IDE shown below. Note I include at the beginning of the Sketch #include "DHT.h" to access the DHT11 function library and #include <LiquidCrystal.h> to access the LCD function library. Then I defined and assigned the DHT pin and type to access the applicable functions from the DHT library. Similarly, I assigned the relevant digital pins for the LCD to access the applicable functions in LiquidCrystal. In the void setup() I initialized the serial printing and printed the Weather Station header to the LCD. In the void loop() I call user function getHDT() to retrieve the digital inputs, calculate results, print formatted results to a serial monitor, and print formatted results to the LCD, and I call user function getPhotoresistor() to retrieve the analog voltage input, calculate the result, print the formatted result to a serial monitor, and print the formatted result to the LCD,


The user function getDHT() user DHT.h library functions to pull multiple values through a single digital input including percent relative humidity, temperature in celcius and farenheit, and heat index in celcius and farenheit. The print formatting and results are sent to both a serial monitor using embedded functionality and the LCD using LiquidCrystal library functions. Note a for loop is used to clear the second line of the LCD before updating a result.


The user function getPhotoresistor() reads the photoresistor voltage using an analog input and converts the results to lux using a formula developed offline as this week's extension discussed later. The print formatting and results are sent to both a serial monitor using embedded functionality and the LCD using LiquidCrystal library functions. Again, note a for loop is used to clear the second line of the LCD before updating a result.

Weather Station Code

Next, below is an image of my Arduino Uno and the breadboard with the Weather Station circuit I built. As noted above, the circuits are not difficult to construct, other than perhaps the many connections required for the LCD.


The circuit diagram for the Weather Station is below. Admittedly, this is my second circuit diagram as one has to be fairly thoughtful about the layout to avoid a massive tangle of crossover points. Let's just say I was more thoughtful the second tie through/


The following video shows the Weather Station project in action and describes the workings of the circuit and features of the Sketch code uploaded from the Arduino IDE.


When I first thought about this week's challenge, I considered many different directions - complicated circuits, complicated coding, and high level multitasking. In the end, I chose to pursue a better understanding of using library functions, serial monitors, and LCD displays. While I did not think this would be an easy course, this choice did not disappoint in creating many opportunities to learn and explore.


Upon reflection, I feel this week's challenge gave me excellent insights into calling functions from libraries, developing and calling user functions, printing to a serial monitor, and printing to an LCD. There are many nuances to how and where to efficiently code with respect to these topics. Probably the best learning opportunity was the extension to calibrate a photoresistor voltage to be able to output a light level in lux. There are many ways to skin this cat, so being thoughtful about the circuit design and where to read voltage was key. Also, there were several ways to go to obtain lux readings. Finally, working out how hard to push on the regression for the calibration was a nontrivial consideration. More about this below. All in all, I would say it is so hard not to get drawn into doing more than the time available allows; this makes me wonder how to properly set boundaries for students so they do not wreck their grades in other classes.


Now, a bit of discussion of my extension this week. I wanted my Weather Station to have a meaningful measure of light level and not simply a photoresistor voltage level or a percent of range.; so, I research how to calibrate a photoresistor as a light level detector. It turns out this is not a trivial undertaking. My approach was to set up the photoresistor as a voltage divider in series with a 5K resistor. I then read the voltage across the photoristor in different light levels while also measuring the lux level using an app on my phone. I did a simple regression in Excel to find an equation for converting photoresistor voltage readings into lux. This is the equation I used in the Sketch code to translate my photoresistor input into a light reading.


16 views0 comments

Comments


Post: Blog2_Post
bottom of page