Notifications
Clear all
Topic starter
2025-02-26 8:25 pm
Ever wondered what the DS-pin on the DS1307 Tiny RTC board is for? And why there is one corner on the board with 3 unused PTHs?
Well, you can add a DS18B20 to the board and read the temperature directly from the DS pin. Just solder it in place like this:
Normally you need to add a 4.7K resistor between VCC and the DQ pin of the DS18B20. I used a SMD of 4.3K and this works fine too.
Here is a small code sample on how to use it.
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is connected to GPIO 12
#define ONE_WIRE_BUS 12 // D6 on Wemos D1 Mini
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
void setup(void) {
Serial.begin(115200);
DS18B20.begin();
Serial.println(); Serial.println("---------------");
// Resolution can be set to 9, 10, 11 or 12 bit (resp. 0.5°C, 0.25°C, 0.125°C and 0.0625°C)
// Default is 12 (0.0625°C), so we lower it to 0.125°C (i.e. 11)
DS18B20.setResolution(11);
Serial.print("Resolution: "); Serial.println(DS18B20.getResolution());
}
void loop(void) {
DallasTemp();
}
void DallasTemp(void) {
DS18B20.requestTemperaturesByIndex(0);
float tempC = DS18B20.getTempCByIndex(0);
// print temperature in degrees Celsius
Serial.print("Temperature: "); Serial.print(tempC); Serial.print("°C - ");
// print temperature in degrees Fahrenheit
Serial.print(DS18B20.toFahrenheit(tempC)); Serial.println("°F");
// delay (tested as low as 100 mSec OK )
delay(1000);
}
Hope this proves helpful.


