Page 1 of 1

TeensyView not playing well with DS18B20

Posted: Fri May 04, 2018 9:20 am
by erdc
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);
}

Re: TeensyView not playing well with DS18B20

Posted: Sat May 05, 2018 5:41 am
by paulvha
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).

Re: TeensyView not playing well with DS18B20

Posted: Tue May 08, 2018 11:00 am
by erdc
Thanks paulvha for your reply. I have tried both pins 8 then 7, but now get a readings of 85C and 185F.

Re: TeensyView not playing well with DS18B20

Posted: Tue May 08, 2018 11:15 pm
by paulvha
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."

Re: TeensyView not playing well with DS18B20

Posted: Wed May 09, 2018 3:02 pm
by erdc
No, there is no change in readings by commenting out those lines of code. It still gives a reading of 85C and 185F.

Re: TeensyView not playing well with DS18B20

Posted: Thu May 10, 2018 1:55 am
by paulvha
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).

Re: TeensyView not playing well with DS18B20

Posted: Thu May 10, 2018 12:10 pm
by erdc
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.

Re: TeensyView not playing well with DS18B20

Posted: Thu May 10, 2018 12:30 pm
by paulvha
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.