Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:iot-open:practical:hardware:rtu:esp32:scenarios:ds18b20 [2025/07/30 15:46] – created kivilands6en:iot-open:practical:hardware:rtu:esp32:scenarios:ds18b20 [2025/07/30 15:47] (current) – [Prequisits] kivilands6
Line 1: Line 1:
 +====== ESP32 DS18B20 =====
 +This is an example of the ds18b20 running and showcasing temperature using the 16x2 lcd.
  
 +===== Prequisits ====
 +Platform.ini
 +<code>
 +lib_deps = adafruit/Adafruit LiquidCrystal@^2.0.2
 +  milesburton/DallasTemperature@^3.11.0
 +</code>
 +===== Example ====
 +<code>
 +#include <Arduino.h>
 +#include <Adafruit_LiquidCrystal.h>
 +#include <DallasTemperature.h>
 +
 +/* DS18B20 */
 +#define ONE_WIRE_BUS 14
 +OneWire oneWire(ONE_WIRE_BUS);
 +DallasTemperature sensors(&oneWire);
 +
 +#define LCD_RS 48
 +#define LCD_ENABLE 47
 +#define LCD_D4 34
 +#define LCD_D5 33
 +#define LCD_D6 26
 +#define LCD_D7 21
 +
 +static Adafruit_LiquidCrystal lcd(LCD_RS, LCD_ENABLE, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
 +
 +void setup() {
 +  if (!lcd.begin(16, 2)) {
 +    Serial.println("Could not init LCD");
 +    while(1);
 +  }
 +  Serial.println("LCD ready.");
 +
 +  // Print a message to the LCD.
 +  lcd.print("IOT-OPEN");
 +
 +  /* ds18b20 setup */
 +  sensors.begin();
 +}
 +void loop() {
 +  sensors.requestTemperatures();
 +  lcd.setCursor(0, 1);
 +  // print the number of seconds since reset:
 +  lcd.print(sensors.getTempCByIndex(0));
 +  delay(1000);
 +}
 +</code>
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0