You are on page 1of 16

ARDUINO ELECTRONIC MODULES SERIES

Arduino Electronic Modules

DS3231
AT24C32
ESP8266
I2C 1602
MFRC522

ARDUINO ELECTRONIC MODULES SERIES


DS3231 AT24C32 IIC High Precision Real Time Clock Module

DS3231: I2C real-time clock chip (RTC)


AT24C32: storage chip 32KB EEPROM
integrated with temperature sensor
Integrated with CR2032 to keep the RTC running when power off

ARDUINO ELECTRONIC MODULES SERIES


DS3231-AT24C32 Module Connection With Arduino

ds3231.ino shows you how to use this


module
This demo is based on arduino library
DS3231-AT24C32. Download link:
http://pc.cd/vwvrtalK
Extract the library to Arduino Root/libraries
then restart the arduino

ARDUINO ELECTRONIC MODULES SERIES


ds3231.ino
#include <DS3231.h>
#include <Wire.h>
DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;
byte year, month, date, DoW, hour, minute, second;
void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data )
{
int rdata = data;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8));
Wire.write((int)(eeaddress & 0xFF));
Wire.write(rdata);
Wire.endTransmission();
}
byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress )
{
byte rdata = 0xFF;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8));
Wire.write((int)(eeaddress & 0xFF));
Wire.endTransmission();
Wire.requestFrom(deviceaddress,1);
if (Wire.available())
rdata = Wire.read();
return rdata;
}

ARDUINO ELECTRONIC MODULES SERIES


ds3231.ino
void setup() {

// Start the I2C interface


Wire.begin();
// We only need to set the time once, CR2032 can keep the time
if(i2c_eeprom_read_byte(0x57, 0) != 1)
{
Clock.setSecond(30);
// Set the second
Clock.setMinute(38);
// Set the minute
Clock.setHour(20);
// Set the hour
Clock.setDoW(0);
// Set the day of the week
Clock.setDate(6);
// Set the date of the month
Clock.setMonth(12);
// Set the month of the year
Clock.setYear(15);
// Set the year (Last two digits of the year)
// time setting completed, write the EEPROM to mark it
i2c_eeprom_write_byte(0x57,0,1);
// EEPROM I2C address 0x57
}

// Start the serial interface


Serial.begin(115200);
}

ARDUINO ELECTRONIC MODULES SERIES


ds3231.ino
void ReadDS3231()
{
int second,minute,hour,date,month,year,temperature;
second=Clock.getSecond();
minute=Clock.getMinute();
hour=Clock.getHour(h12, PM);
date=Clock.getDate();
month=Clock.getMonth(Century);
year=Clock.getYear();
temperature=Clock.getTemperature();
Serial.print("20");
Serial.print(year,DEC);
Serial.print('-');
Serial.print(month,DEC);
Serial.print('-');
Serial.print(date,DEC);
Serial.print(' ');
Serial.print(hour,DEC);
Serial.print(':');
Serial.print(minute,DEC);
Serial.print(':');
Serial.print(second,DEC);
Serial.print('\n');
Serial.print("Temperature=");
Serial.print(temperature);
Serial.print('\n');
}
void loop()
{
ReadDS3231();
delay(1000);
}

ARDUINO ELECTRONIC MODULES SERIES


LCD1602 and I2C Interface for LCD1602
LCD1602 consumes many arduino IOs (7 IOs)
I2C interface for LCD1602 saves arduino IOs by using I2C
communication (Only 2 IOs needed)
The blue knob can be used to adjust the brightness of back light
Default address 0x27, A0 A1 A2 can be used for address modification
see table 01

ARDUINO ELECTRONIC MODULES SERIES

Table 01: Address Reference

ARDUINO ELECTRONIC MODULES SERIES


LCD1602 Connection With Arduino
VCC <--> VCC
GND <--> GND
A4 <--> SDA
A5 <--> SCL

Library LiquidCrystal_I2C is for LCD1602.


Download link: http://pc.cd/zpirtalK
Check the examples in this library for more
information
ds3231_lcd1602.ino is an example to show
how to display date and temperature on
LCD1602. It is based on library DS3231AT24C32 and LiquidCrystal_I2C. Extract
libraries to Arduino Root/libraries to use

ARDUINO ELECTRONIC MODULES SERIES


ds3231_lcd1602.ino
#include <DS3231.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27,16,2);
// check your own device, device address in this demo is 0x27
DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;
byte year, month, date, DoW, hour, minute, second;
void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data )
{
int rdata = data;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB
Wire.write(rdata);
Wire.endTransmission();
}
byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress )
{
byte rdata = 0xFF;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB
Wire.endTransmission();
Wire.requestFrom(deviceaddress,1);
if (Wire.available())
rdata = Wire.read();
return rdata;

ARDUINO ELECTRONIC MODULES SERIES


ds3231_lcd1602.ino
void setup() {
Wire.begin();
if(i2c_eeprom_read_byte(0x57, 0) != 1)
{
Clock.setSecond(30);//Set the second
Clock.setMinute(38);//Set the minute
Clock.setHour(20); //Set the hour
Clock.setDoW(0); //Set the day of the week
Clock.setDate(6); //Set the date of the month
Clock.setMonth(12); //Set the month of the year
Clock.setYear(15); //Set the year (Last two digits of the year)
i2c_eeprom_write_byte(0x57,0,1);
}
Serial.begin(115200);
// initialize lcd
lcd.init();
}
void ReadDS3231()
{
int second,minute,hour,date,month,year,temperature;
second=Clock.getSecond();
minute=Clock.getMinute();
hour=Clock.getHour(h12, PM);
date=Clock.getDate();
month=Clock.getMonth(Century);
year=Clock.getYear();
temperature=Clock.getTemperature();

ARDUINO ELECTRONIC MODULES SERIES


ds3231_lcd1602.ino
lcd.clear();
lcd.print("Temperature:");
lcd.print(temperature);
// print
lcd.write(0xDF);
lcd.print("C");
lcd.setCursor(0, 1);
//lcd.print("20");
//lcd.print(year,DEC);
//lcd.print('-');
lcd.print(month,DEC);
lcd.print('-');
lcd.print(date,DEC);
lcd.print(' ');
lcd.print(hour,DEC);
lcd.print(':');
lcd.print(minute,DEC);
lcd.print(':');
lcd.print(second,DEC);
}
void loop()
{
ReadDS3231();
delay(1000);
}

ARDUINO ELECTRONIC MODULES SERIES


MFRC522 RFID Read Module
Power supply DC 3.3V-5V
upports serial communication I2C communications with ISP address
(can be selected via the dip switch on the Board)
Support card types: mifare1, mifare1 S70, Mifare UltraLight, Mifare
Pro, and Mifare Desfire
Accessories RFID module one IC card IC key ring cards

ARDUINO ELECTRONIC MODULES SERIES


MFRC522 RFID Module Connection With Arduino
Library rfid is for LCD1602. Download link:
http://pc.cd/rJirtalK
check https://github.com/miguelbalboa/rfid
for more information
Many examples included in this library

ARDUINO ELECTRONIC MODULES SERIES


ESP8266 WiFi Module

SDIO 2.0, SPI, UART


32-pin QFN package
Integrated RF switch, balun, 24dBm PA, DCXO, and PMU
Integrated RISC processor, on-chip memory and external memory interfaces
Integrated MAC/baseband processors
Quality of Service management
I2S interface for high fidelity audio applications
On-chip low-dropout linear regulators for all internal supplies
Proprietary spurious-free clock generation architecture
Integrated WEP, TKIP, AES, and WAPI engines
Support AT commands, check https://github.com/espressif/esp8266_at/wiki/AT_Description

ARDUINO ELECTRONIC MODULES SERIES


ESP8266 WiFi Module Connection With Arduino

Library ESP8266wifi can be used for this module. Download link:


http://pc.cd/wHirtalK
Check https://github.com/ekstrand/ESP8266wifi for more information
If your arduino SoftwareSerial dont support Baud 115200, try to use
hardware serial instead.
You can connect esp8226 with a USB-UART(TTL) chip (e.g. PL2303,
CH340, FT232 ) and debug it by using AT commands through UART.
USR-TCP232-Test can be used for test. Link: http://pc.cd/7LirtalK

You might also like