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
Arduino
  • Products
  • More
Arduino
Arduino Forum Arduino ds18b20 display 20x4 I2C
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 1 reply
  • Subscribers 391 subscribers
  • Views 515 views
  • Users 0 members are here
Related

Arduino ds18b20 display 20x4 I2C

Former Member
Former Member over 9 years ago

I have a project that i implemented in my work for me and my colleges, witsh consistes on an Arduino Nano with 4 DS18B20 connected to the pc to read several temperatures in serial monitor.

The project now needs to evolve to an equipment that does not need the computer by adding a 20x4 I2C Display.

That's where the problem starts, i found a sketch on the internet, but the display only turns on and off the backlight, and doesn't print anything on the display.

Can anyone help me to try and understand what is wrong.

Thank you.

 

 

 

/* YourDuino.com Example: Multiple DS18B20 Temperature Sensors

   Displayed on 4x20 character LCD display

  

   DS18B20 Pinout (Left to Right, pins down, flat side toward you)

  - Left   = Ground

  - Center = Signal (Pin 10):  (with 3.3K to 4.7K resistor to +5 or 3.3 )

  - Right  = +5 or +3.3 V

  

   terry@yourduino.com */

 

/*-----( Import needed libraries )-----*/

// Get 1-wire Library here: http://www.pjrc.com/teensy/td_libs_OneWire.html

#include <OneWire.h>

 

//Get DallasTemperature Library here:  http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library

#include <DallasTemperature.h>

// Wire (I2C) Library

#include <Wire.h>

// LCD Library

#include <LCD.h>

#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library

//Download: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

// Move original LiquidCrystal library elsewhere, copy this in it's place

 

 

/*-----( Declare Constants and Pin Numbers )-----*/

// Data wire is plugged into port 10 on the Arduino (can be changed)

#define ONE_WIRE_BUS 10    // NOTE: No ";" on #define 

 

#define I2C_ADDR    0x27  // Define I2C Address for the PCF8574A on the LCD Backpack board

//---(Following are the PCF8574 pin assignments to LCD connections )----

// This are different than earlier/different I2C LCD displays

#define BACKLIGHT_PIN  7

#define En_pin  4

#define Rw_pin  5

#define Rs_pin  6

#define D4_pin  0

#define D5_pin  1

#define D6_pin  2

#define D7_pin  3

 

#define  LED_OFF  0

#define  LED_ON  1

 

/*-----( Declare objects )-----*/

// Setup a oneWire instance to communicate with any OneWire devices

// (not just Maxim/Dallas temperature ICs)

OneWire oneWire(ONE_WIRE_BUS);

 

// Pass address of our oneWire instance to Dallas Temperature.

DallasTemperature sensors(&oneWire);

 

// Start the LCD display library

LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

 

/*-----( Declare Variables )-----*/

// Assign the addresses of your 1-Wire temp sensors.

// See the tutorial on how to obtain these addresses:

// http://arduino-info.wikispaces.com/Brick-Temperature-DS18B20#Read%20individual

 

 

// WP 1

DeviceAddress Probe01 = { 0x28, 0x9A, 0x80, 0x40, 0x04, 0x00, 0x00, 0xD5 }; // "4"

DeviceAddress Probe02 = { 0x28, 0xE1, 0xC7, 0x40, 0x04, 0x00, 0x00, 0x0D }; // "5"

DeviceAddress Probe03 = { 0x28, 0x9A, 0x80, 0x40, 0x04, 0x00, 0x00, 0xD5 }; // "4" Again for test

DeviceAddress Probe04 = { 0x28, 0x10, 0xA4, 0x57, 0x04, 0x00, 0x00, 0xA9 };

 

 

void setup()   /****** SETUP: RUNS ONCE ******/

{

//------- Initialize the Temperature measurement library--------------

  sensors.begin();

  // set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)

  sensors.setResolution(Probe01, 10);

  sensors.setResolution(Probe02, 10);

  sensors.setResolution(Probe03, 10);

  sensors.setResolution(Probe04, 10);

 

//---------------- Initialize the lcd ------------------ 

  lcd.begin (20,4);  // 20 characters, 4 lines

// Switch on the backlight

  lcd.setBacklightPin(BACKLIGHT_PIN,NEGATIVE);

  lcd.setBacklight(LED_ON); 

 

}//--(end setup )---

 

 

void loop()   /****** LOOP: RUNS CONSTANTLY ******/

{

  sensors.requestTemperatures(); // Send the command to get temperatures

 

  lcd.clear();  // Reset the display 

  lcd.home();

  lcd.backlight();  //Backlight ON if under program control 

 

// Print our characters on the LCD

// NOTE: Line number and character number start at 0 not 1

 

  lcd.setCursor(0,0); //Start at character 0 on line 0

  lcd.print("1: ");

  displayTemperature(Probe01); 

 

  lcd.setCursor(0,1); //Start at character 0 on line 1

  lcd.print("2: ");

  displayTemperature(Probe02); 

 

  lcd.setCursor(0,2); //Start at character 0 on line 2

  lcd.print("3: ");

  displayTemperature(Probe03); 

 

  lcd.setCursor(0,3); //Start at character 0 on line 3

  lcd.print("4: ");

  displayTemperature(Probe04); 

 

  delay(2000);

 

}//--(end main loop )---

 

/*-----( Declare User-written Functions )-----*/

void displayTemperature(DeviceAddress deviceAddress)

{

 

float tempC = sensors.getTempC(deviceAddress);

 

   if (tempC == -127.00) // Measurement failed or no device found

   {

    lcd.print("Temperature Error");

   }

   else

   {

   lcd.print("C=");

   lcd.print(tempC);

   lcd.print(" F=");

   lcd.print(DallasTemperature::toFahrenheit(tempC)); // Convert to F

   }

}// End printTemperature

 

//*********( THE END )***********

  • Sign in to reply
  • Cancel
Parents
  • gihu
    0 gihu over 9 years ago

    Hi Nuno,

     

    Can you share which Display you are using, and the connetions you have done?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • gihu
    0 gihu over 9 years ago

    Hi Nuno,

     

    Can you share which Display you are using, and the connetions you have done?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
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