arduino electronic modules ds3231_ at24c32_ i2c1602_ mfrc522_ esp8266 - jie deng

Upload: anonymous-lqny0i5e1

Post on 07-Aug-2018

236 views

Category:

Documents


4 download

TRANSCRIPT

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    1/16

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    2/16

    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

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    3/16

    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

    http://pc.cd/vwvrtalKhttp://pc.cd/vwvrtalKhttp://pc.cd/vwvrtalKhttp://pc.cd/vwvrtalKhttp://pc.cd/vwvrtalKhttp://pc.cd/vwvrtalKhttp://pc.cd/vwvrtalK

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    4/16

    ARDUINO ELECTRONIC MODULES SERIES

    #include

    #include

    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;

    }

    ds3231.ino

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    5/16

    ARDUINO ELECTRONIC MODULES SERIES

    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 weekClock.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);

    }

    ds3231.ino

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    6/16

    ARDUINO ELECTRONIC MODULES SERIES

    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);

    }

    ds3231.ino

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    7/16

    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 modificationsee table 01 

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    8/16

    ARDUINO ELECTRONIC MODULES SERIES

    Table 01: Address Reference

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    9/16

    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 DS3231-

    AT24C32 and LiquidCrystal_I2C. Extract

    libraries to “Arduino Root”/libraries to use

    http://pc.cd/zpirtalKhttp://pc.cd/zpirtalKhttp://pc.cd/vwvrtalKhttp://pc.cd/vwvrtalKhttp://pc.cd/zpirtalKhttp://pc.cd/zpirtalKhttp://pc.cd/vwvrtalKhttp://pc.cd/vwvrtalKhttp://pc.cd/vwvrtalKhttp://pc.cd/zpirtalKhttp://pc.cd/zpirtalK

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    10/16

    ARDUINO ELECTRONIC MODULES SERIES

    #include

    #include #include

    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;

    }

    ds3231_lcd1602.ino

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    11/16

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    12/16

    ARDUINO ELECTRONIC MODULES SERIES

    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);

    }

    ds3231_lcd1602.ino

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    13/16

    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

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    14/16

    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

    https://my.pcloud.com/publink/show?code=XZuWVRZtyUzka9VlfbbRfUEw1SV2S9I2KQ7http://pc.cd/rJirtalKhttps://github.com/miguelbalboa/rfidhttps://github.com/miguelbalboa/rfidhttps://github.com/miguelbalboa/rfidhttp://pc.cd/rJirtalKhttp://pc.cd/rJirtalKhttps://my.pcloud.com/publink/show?code=XZuWVRZtyUzka9VlfbbRfUEw1SV2S9I2KQ7

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    15/16

    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  

    https://github.com/espressif/esp8266_at/wiki/AT_Descriptionhttps://github.com/espressif/esp8266_at/wiki/AT_Description

  • 8/20/2019 Arduino Electronic Modules DS3231_ AT24C32_ I2C1602_ MFRC522_ ESP8266 - Jie Deng

    16/16

    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 don’t 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 

    https://github.com/ekstrand/ESP8266wifi/archive/master.ziphttp://pc.cd/wHirtalKhttps://github.com/ekstrand/ESP8266wifihttp://pc.cd/7LirtalKhttp://pc.cd/7LirtalKhttp://pc.cd/7LirtalKhttp://pc.cd/7LirtalKhttp://pc.cd/7LirtalKhttp://pc.cd/7LirtalKhttp://pc.cd/7LirtalKhttp://pc.cd/7LirtalKhttps://github.com/ekstrand/ESP8266wifihttps://github.com/ekstrand/ESP8266wifihttp://pc.cd/wHirtalKhttp://pc.cd/wHirtalKhttps://github.com/ekstrand/ESP8266wifi/archive/master.zip