adachsoft.com
Published © GPL3+

ESP8266 With DS1307 RTC, NV SRAM and Square-Wave Output

The DS1307 is a real time clock (RTC) with plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C bus.

BeginnerFull instructions provided1.618 hours9,183
ESP8266 With DS1307 RTC, NV SRAM and Square-Wave Output

Things used in this project

Hardware components

ESP8266 ESP-01
Espressif ESP8266 ESP-01
×1
DS1307
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Code

Code snippet #1

Plain text
#include "ESP8266WiFi.h"	#include "Wire.h"	
	#include "RTC_DS1307.h"
	
	RTC_DS1307 rtc;
	
	void setup() {
	  Serial.begin(115200);
	  Serial.println("");
	  Serial.println("START");
	  
	  Wire.begin();
	
	  rtc.SQW( f32768hz );
	}
	
	void loop() {
	}

Code snippet #3

Plain text
void loop() {  //Read time from DS1307 and display (You must be connected to the serial port to see results) 
  rtc.DisplayTime();
  //Convert time to unix timestamp
  long uts = rtc.UnixTimestamp();
  Serial.println( uts );
  delay(1000);
}

Code snippet #4

Plain text
void setup() {  Serial.begin(115200);
  Serial.println("");
  Serial.println("START");
  
  Wire.begin();

Code snippet #5

Plain text
  //Write in NV SRAM	
  rtc.WriteRAMStr(0, "http://geek.adachsoft.com/");
  delay(500);
  
  //Read from NV SRAM
  String str = rtc.ReadRAMStr(0);
  Serial.println("RAM: " +  str);
}

Credits

adachsoft.com

adachsoft.com

9 projects • 16 followers

Comments