Attiny1614 Oled DS18B20 - SOLVED

Hello, I'm trying to build a temperature sensor using the Attiny1614 using a 0.96 oled and a DS18B20 temperature sensor. I mange to get the oled working by using the Tiny4Koled. here. Also I found the DS18B20 temperature here. For some unknown reason beyond my programming skills I can not get the Temperarure sensor working. The attiny1614 does have spi and i2c on it. But not serial. well it does have serial but i would need to hook up a FTDI to it for it to work. The Attiny1614 programs by UPDI. I really need help to figure out what is wrong. Can someone help me please? My sketch is below.

Edit: I get no errors in compiling. I just get no temperature.

/*
 * Tiny4kOLED - Drivers for SSD1306 controlled dot matrix OLED/PLED 128x32 displays
 *
 * Based on ssd1306xled, re-written and extended by Stephen Denne
 * from 2017-04-25 at https://github.com/datacute/Tiny4kOLED
 *
 * This example shows how the scrolling features work.
 * When scrolling, the double buffering of screens cannot be used.
 *
 */

// Choose your I2C implementation before including Tiny4kOLED.h
// The default is selected is Wire.h

// To use the Wire library:
//#include <Wire.h>

// To use the Adafruit's TinyWireM library:
//#include <TinyWireM.h>

// To use the TinyI2C library from https://github.com/technoblogy/tiny-i2c
//#include <TinyI2CMaster.h>


#include <Tiny4kOLED.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 8

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

/*
 * The setup function. We only start the sensors here
 */

void setup() {
    // Start up the library
  sensors.begin();
  oled.begin();

  oled.clear();
  oled.on();
  oled.setFont(FONT6X8);
    oled.setCursor(0, 0);
    oled.invertOutput(false);
    oled.println("Temperature");
    delay(500);
}

void loop() {
  // call sensors.requestTemperatures() to issue a global temperature 
  // request to all devices on the bus
  //Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
 // Serial.println("DONE");
  // After we got the temperatures, we can print them here.
  // We use the function ByIndex, and as an example get the temperature from the first sensor only.
  float tempC = sensors.getTempCByIndex(0);

  // Check if reading was successful
  if(tempC != DEVICE_DISCONNECTED_C) 
  {
   // Serial.print("Temperature for the device 1 (index 0) is: ");
   // Serial.println(tempC);
 
  
oled.setFont(FONT6X8);
    oled.setCursor(0, 10);
    oled.invertOutput(false);
    oled.println(tempC);
    delay(500);


 } 
  else
  {
       oled.setCursor(0, 10);
   oled.setFont(FONT8X16);
    oled.print("Not Found");
    oled.clearToEOL();
    delay(500);
   // Serial.println("Not Found");
  }

}

Joseph

I see you are using the onewire library. It seems to be important to use the forked version of it.

Spend the $3 on buying a USB to serial adapter, or better buy 2 of them, as from the cheap CH340G version you can make very good UPDI programmers

Hello thank you I will try that this afternoon.

Edit: a guy I talk a guy from YouTube called bitluni. He is the one who took a arduino nano and turned it into a programmer. Now the thing is the nano I have is using a ch340 chip.

Joseph

This is the programmer I am using. 5 of them for $4

I cut off the TX pin and then on the bottom soldered a diode between TX and RX.

The second (and third) programmer then can be used to connect to the UART(s), and you will have a few spare :slight_smile:

I have ch340 programmers I'm looking into building my own UPDI using the CH340. I found another guy on in google that made a board that does this. and looks good.

Joseph

Hello, That one wire works. thank you now the temperture sensor is showing up.

Joseph

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.