rtc.setDOW(WEDNESDAY) // Set Day-of-Week to SUNDAY The below lines are commented in the code but if you are using the DS3231 module for the first time and you want to set the day, date and time, then uncomment these lines and set it. Then we gave the command to DS3231 and OLED to start communicating with the Arduino. In the setup function, we declared the LM35 sensor pin as input because the Arduino will take the input from the sensor. DS3231 rtc(SDA, SCL) #define OLED_MOSI 11 #define OLED_CLK 13 #define OLED_DC 9 #define OLED_CS 10 #define OLED_RESET 8 Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS) const int sensor_pin = A0 float temp float output After that, we initialized the LM35 sensor pin and other variables. Therefore we initialized the pins 8, 9, 10, 11, 13 which are for the SPI communications. The OLED works with the Arduino through SPI communication. The DS3231 module works with the Arduino through the I2C communication so we have used the SDA and SCL pins of the Arduino. Next, we defined the pins where we have connected the DS3231 module and the OLED. The Adafruit library for the OLED has more functions compared to the other libraries used for OLEDs. Connect the left pin of LM35 to 5V on the Arduino, the middle pin to A0 on the Arduino and the left pin to ground on the Arduino.įirst of all, we added the libraries for the DS3231 module and the OLED. In the end, connect the LM35 sensor with the Arduino. Connect SCL on the OLED to the A5 pin on the Arduino.Connect SDA of the OLED to A4 on the Arduino.Connect VCC of the DS3231 to 5V pin of the Arduino.Connect GND of the DS3231 to the GND pin of the Arduino.Connect the DS3231 module to the Arduino as follows: The pins for I2C communication on the Arduino are SDA and SCL. The DS3231 module works with the Arduino through I2C communication. Connect GND of the OLED to GND pin of the Arduino.Īfter that, connect the DS3231 module with the Arduino.Connect VCC of the OLED to 5V pin of the Arduino.Connect D0 of the OLED to pin 13 of the Arduino.Connect D1 of the OLED to pin 11 of the Arduino.Connect RES of the OLED to pin 8 of the Arduino.Connect DC of the OLED to pin 9 of the Arduino.Connect CS of the OLED to pin 10 of the Arduino.The connections of the OLED with the Arduino are as follows: The SPI pins on the Arduino are pin 8, 9, 10, 11, and 13. The OLED works with the Arduino through the SPI as well as I2C communication but we have connected it using SPI communication. First of all, connect the OLED with the Arduino.
0 Comments
Leave a Reply. |