element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog UpCycle IT - R2I - BackONTrack
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jkutzsch
  • Date Created: 4 Jun 2017 7:09 AM Date Created
  • Views 556 views
  • Likes 3 likes
  • Comments 1 comment
  • upcycle it design challenge
  • upcycle it
Related
Recommended

UpCycle IT - R2I - BackONTrack

jkutzsch
jkutzsch
4 Jun 2017

UpCycle IT - R2I - Hot2Not

UpCycle IT – R2I INDEX:

 

Blog #1_”Introduction”

Blog #2_”Designing”

Blog #3 "The Kit"

Blog #4_"Mother Natures Version"
Blog #5_"Research"
Blog #6_"Competition01"

Blog #7_"Edison Setup"

Blog #8_"Edison 2 Ardunio"
Blog #9_"Grove-ON"
Blog #10_"Hot2Not"
Blog #11_"BackONTrack"

 

Blog #11 - BackONTrack

 

Ah good times!  Sometimes you can be stuck on a single problem for days and days, other times you can be so lucky as to come across  a simple fix that has you back working in just a few hours!

 

Today was one of the good days.

 

In my last blog I was feeling a little down because while I had success with the Temperature sensor, the LCD RGB Backlight didn't work and I was concerned it would take some modifying to get it doing what it should.

 

image

 

Instead some more research showed me that I had not been as aware of the features of the Base Shield as I should have been.

 

In the yellow circle you will see a little switch for going from 3.3 V to 5V.  By default it was set for 3.3V.  This allowed my Temperature Sensor to function (although due to the math being based on 5v it was not correct) but my LCD would not.  Switching this over to 5V quickly changed the situation to R2I being Back On Track!

 

image

 

Okay, let's try that Hello World example again!

 

image

 

austin-powers-yeah-baby-yeah.jpg

 

I have to agree with Mr. Powers on this one!!!

 

Okay, so we have our LCD working!  But Hello World really isn't going to do much for the R2I project, so time to modify a little of that example code and come up with something better for this purpose!

 

/* Hello World and Grove Temperature Sensor sketches modified for use

   in displaying temperature to lcd.

*/

 

#include <Wire.h>

#include "rgb_lcd.h"

 

rgb_lcd lcd;

 

const int colorR = 0;

const int colorG = 0;

const int colorB = 255;              //BLUE

 

const int pinTemp = A0;            //Temp

const int B = 3975;                    //Temp

 

 

void setup()

{

     Serial.begin(9600);              //Temp

 

    // set up the LCD's number of columns and rows:

    lcd.begin(16, 2);

   

    lcd.setRGB(colorR, colorG, colorB);

   

    // Print a message to the LCD.

    lcd.print("E14-R2I Project");

 

    delay(1000);

}

 

 

void loop()

{

     int val = analogRead(pinTemp);

     float resistance = (float)(1023-val)*10000/val;

     float temperature = 1/(log(resistance/10000)/B+1/298.15)-273.15;

     float ftemp = temperature * (9.0/5.0) + 32.0;

     

    // set the cursor to column 0, line 1

    // (note: line 1 is the second row, since counting begins with 0):

    lcd.setCursor(0, 1);

    // print the number of seconds since reset:

    lcd.print(ftemp);                 //TEMP

 

    delay(100);

}

 

 

/*********************************************************************************************************

  END FILE

*********************************************************************************************************/

 

Combining elements from the Temperature sketch and the Hello World sketch and changing Hello World to blue E14-R2I Project brings the LCD to a much nicer look for what I want.

 

image

 

I used Green to highlight the key spots, there are a few more changes not displayed due to size of picture, but it is the main part.

 

So let's see what this Sketch will give us now!

 

image

 

Yes I definitely like this better!  I had turned on my space heater as well so the combination of the heater right below my work area as well as using the correct voltage brings a tad more understandable temperatures into view.

 

Deciding to play with a little more code and the Grove LED option, I added a section that would check and see if the temperature was between a certain range and turn on the LED if it is. 

 

The idea with this was a quick way to display how the temperature sensor will pickup changes and the LED will display a range of interest.

 

This can later be applied with the Relay and the heat element to keep the incubator at a programmed temperature and not too cold or too hot.

 

Here is my Temp2LCD2LED Sketch:

 

/* Hello World and Grove Temperature Sensor sketches modified for use

   in displaying temperature to lcd.  LED activated if TEMP is in a

   range to simulate heat element for R2I project

*/

 

#include <Wire.h>

#include "rgb_lcd.h"

 

rgb_lcd lcd;

 

const int colorR = 0;

const int colorG = 0;

const int colorB = 255;                                                                                              //BLUE

 

const int pinTemp = A0;                                                                                            //Temp

const int B = 3975;                                                                                                    //Temp

 

const int pinLed    = 3;                                                                                               //LED

 

void setup()

{

     Serial.begin(9600);                                                                                             //Temp

 

     pinMode(pinLed, OUTPUT);                                                                              //LED

 

    // set up the LCD's number of columns and rows:

    lcd.begin(16, 2);

   

    lcd.setRGB(colorR, colorG, colorB);

   

    // Print a message to the LCD.

    lcd.print("E14-R2I Project");

 

    delay(1000);

}

 

void loop()

{

     int val = analogRead(pinTemp);                                                                           //Temp

     float resistance = (float)(1023-val)*10000/val;                                                     //Temp

     float temperature = 1/(log(resistance/10000)/B+1/298.15)-273.15;                    //Temp

     float ftemp = temperature * (9.0/5.0) + 32.0;                                                       //Temp

 

    if ((ftemp > 79) and (ftemp < 90)) digitalWrite(pinLed, HIGH);                              //LED

    if ((ftemp < 80) or (ftemp > 89)) digitalWrite(pinLed, LOW);                                 //LED  

     

    // set the cursor to column 0, line 1

    // (note: line 1 is the second row, since counting begins with 0):

    lcd.setCursor(0, 1);

    // print the number of seconds since reset:

    lcd.print(ftemp);

 

    delay(100);

}

 

/*********************************************************************************************************

  END FILE

*********************************************************************************************************/

 

So key parts now are we are watching for Temp to be less than 80 and the LED is unlit.  More than 89 and the LED is unlit.  But if the temp is between 80 & 89 the LED will illuminate.  Easily allowing us to imagine where instead I would require the heat to come on if the temperature is too low and shut off at a certain point.  That is a simpler piece of logic but I wanted to show the Sensor off with the LED.  :-)

 

image

 

Here we can see the temperature is below 80 so the LED is unlit.  Yes I know, in the incubator now I would actually want to be applying heat, but this is for demonstration purposes.

 

 

image

 

Now the temperature is greater than 80 and the LED is illuminating.

 

image

 

And here we have exceeded the 89 degree limit and the LED has went to an unlit state.

 

What I will end up doing later is implementing the LED as an external display of when the heat is on or off.

 

So far so good!  More to come!

  • Sign in to reply

Top Comments

  • DAB
    DAB over 8 years ago +2
    Good update John. Yes, anytime things do not make sense, always reset and review what you have hooked up and why. Just went through this with my wife on our latest book. It suddenly would not make a PDF…
  • DAB
    DAB over 8 years ago

    Good update John.

     

    Yes, anytime things do not make sense, always reset and review what you have hooked up and why.

     

    Just went through this with my wife on our latest book.  It suddenly would not make a PDF, so I had her take out sections one by one and sure enough, the last section she added had something that drove MS Word nuts.  We further refined the problem to an embedded picture which tried to reference a nonexistent link.

     

    So kudos on the debug.

     

    DAB

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube