TeensyView not playing well with DS18B20

Have questions about a SparkFun product or board? This is the place to be.

Moderators: phalanx, TS-Tim

Post Reply
erdc
Posts: 5
Joined: Mon Jan 18, 2016 3:11 pm

TeensyView not playing well with DS18B20

Post by erdc » Fri May 04, 2018 9:20 am

The below code will give me a valid temperature readings from a DS18B20, as long as I COMMENT OUT the TeensyView code. For when it is included, all I get then is a constant reading of -127.00 for C and a reading of -196.60 for F.

Just by commenting out all TeensyView code EXCEPT FOR "#include <TeensyView.h>" and "oled.begin();" will cause this effect to take place.

#################################################
#include <TeensyView.h>
#include <DallasTemperature.h>
#include <OneWire.h>
///////////////////////////////////
// TeensyView Object Declaration //
///////////////////////////////////
//Standard
#define PIN_RESET 15
#define PIN_DC 5
#define PIN_CS 10
#define PIN_SCK 13
#define PIN_MOSI 11

#define ONE_WIRE_BUS 12
TeensyView oled(PIN_RESET, PIN_DC, PIN_CS, PIN_SCK, PIN_MOSI);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup()
{
oled.begin(); // Initialize the OLED
oled.clear(ALL); // Clear the display's internal memory
delay(1000); // Delay 1000 ms
oled.clear(PAGE); // Clear the buffer.
sensors.begin();
}

void loop()
{
oled.clear(PAGE); // Clear the page
oled.setFontType(1); // Set font to type 1
oled.setCursor(0, 17); // move cursor
oled.print("TEMP = "); // Write a byte out as a charact
oled.println(sensors.getTempCByIndex(0));
oled.display(); // Send the PAGE to the OLED memory
Serial.print("TEMP = ");
Serial.println(sensors.getTempCByIndex(0));
delay(200);
}

paulvha
Posts: 209
Joined: Sat Nov 11, 2017 2:39 am

Re: TeensyView not playing well with DS18B20

Post by paulvha » Sat May 05, 2018 5:41 am

Try to use another pin for ONE_WIRE_BUS than 12. Seems the library is setting standard SPI interface and then pin 12 is set for MISO (on arduino uno).

erdc
Posts: 5
Joined: Mon Jan 18, 2016 3:11 pm

Re: TeensyView not playing well with DS18B20

Post by erdc » Tue May 08, 2018 11:00 am

Thanks paulvha for your reply. I have tried both pins 8 then 7, but now get a readings of 85C and 185F.

paulvha
Posts: 209
Joined: Sat Nov 11, 2017 2:39 am

Re: TeensyView not playing well with DS18B20

Post by paulvha » Tue May 08, 2018 11:15 pm

does the reading work correctly on pin 8 or 7 when "Just by commenting out all TeensyView code EXCEPT FOR "#include <TeensyView.h>" and "oled.begin();" will cause this effect to take place."

erdc
Posts: 5
Joined: Mon Jan 18, 2016 3:11 pm

Re: TeensyView not playing well with DS18B20

Post by erdc » Wed May 09, 2018 3:02 pm

No, there is no change in readings by commenting out those lines of code. It still gives a reading of 85C and 185F.

paulvha
Posts: 209
Joined: Sat Nov 11, 2017 2:39 am

Re: TeensyView not playing well with DS18B20

Post by paulvha » Thu May 10, 2018 1:55 am

This issue now os maybe not related to Teensyview. Try use a standard sketch that is part of DS18B20 library and make that work first with pin 7 or 8 (maybe removing Teensy hardware if needed).

erdc
Posts: 5
Joined: Mon Jan 18, 2016 3:11 pm

Re: TeensyView not playing well with DS18B20

Post by erdc » Thu May 10, 2018 12:10 pm

That is what I did in my original post. I first made sure that I was gettin a valid reading then tried to add the Teensyview code to it.

paulvha
Posts: 209
Joined: Sat Nov 11, 2017 2:39 am

Re: TeensyView not playing well with DS18B20

Post by paulvha » Thu May 10, 2018 12:30 pm

I know, but I understood that at that time the temperature was read correctly as long as you commented out many Teensyview lines. If you now comment out the same lines (using pin 8 or 7 for the DS18B20) ) and still don't get the right temperature, there might be another issue to solve first and then include the Teensyview. The fact that it would not work with pin 12 is was because of SPI/MISO, not sure why it would not work with pin 7 or 8.

Post Reply