NTP time to OLED using an Arduino and ESP-01

Hello,

I programmed ESP-01 via USB-TTL adapter. ESP-01 can connect to wifi and reveice NTP data from server. I can read correct NTP data from PC Arduino IDE serial monitor while ESP is connected to the PC USB-TTL adapter.

How can I to see this NTP data on my OLED screen which is connected to the Arduino UNO ? I must use UNO since I will add some keypad and some servo to my project. Main goal is, run servo when specified time comes

Thanks.

Ideally, the Uno would be set up to receive serial data (the time data) from the "ESP".
Any idea how you can send "Hello Uno" from the ESP to the Uno and have that display on the OLED?

OK, the command "Serial.print" can succesfully send data to PC via USB-TTL adapter , thats fine.
But, UNO did not recognize this data. I feel I should try something different. I tried Serial.write into ESP but it didnt work.

What are we talking about?

The usual approach is to attach a Software Serial instance to one of the Uno I/O pins. Then it can receive the serial data from the ESP. You also need 3.3V-5V level shifting between the two.

As suggested in the previous post, you haven't explained anything about your serial connection. You said, "try something different" but different than what?

I'm sorry, but the Uno doesn't require level-shifting on its input; "3V" is an acceptable High.
From what I read, the Uno only needs the NTP from the ESP.

PE -
OP needs to establish a grasp of the fundamentals of Serial data transfer, a simple proof of concept thing.

Can't uno receive data from ESP via Hard serial pins ? Because I used hard serial pins.

Yes, as long as you don't require serial communication with the PC at the same time. You still haven't told us enough about your system... that would be okay if it worked. But you say it doesn't.

@udemir
Consider posting your code (in code tags, etc.)

Also a wiring diagram of your system. Everything, including the power distribution. If you can't manage that, at least post close up photos.

This is my code on ESP

#include <NTPClient.h>

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char *ssid     = "******";
const char *password = "******";

WiFiUDP ntpUDP;

NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000);

void setup(){
Serial.begin(115200);

  WiFi.begin(ssid, password);

  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }

  timeClient.begin();
}

void loop() {
  timeClient.update();
  Serial.println(timeClient.getFormattedTime());

  delay(1000);
}

This is the code on the UNO:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width,  in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels


Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(115200);
  if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
}

  delay(2000);         
  oled.clearDisplay(); 
  oled.setTextSize(1);          
  oled.setTextColor(WHITE);    
  oled.setCursor(0, 10);       
  oled.println("Hello World!"); 
  oled.display();            
}

void loop() {

if (Serial.available()) {
oled.setCursor(0, 10);       
oled.println(Serial.read());
oled.display();             
  
  }
}

How can I see NTP data on the OLED ?

Outside of your NTP paradigm, to learn something, come up with two sketches.

  1. The ESP sketch sends Serial data to the Uno.
  2. The Uno sketch receives that Serial data (perhaps using SoftwareSerial) and prints that data on the OLED.

(Suggest the ESP should send something simple "XXX", delay several seconds, then sends "YYY", delay several seconds, and Repeat. . .)

Reduce complexity! Why do you want to use two microcontrollers? The less components you have, the easier your sketch gets. If you use a board like a Wemos D1 or a NodeMCU you get more pins, you can connect the display directly to the NodeMCU and can get rid of the Arduino! If you really run out of pins, consider to use some I2C portexpanders to get more pins.
Talking about a keypad: For example the SX1509 is a very nice IC to do all the needed things to decode a keypad / buttonmatrix!.

Furthermore: there is no need to do this NTP code in the user sketch. The ESP is perfectly able to do all this in the background, with two, three lines of code.
There is a nice example ESP8266 / NTP-TZ-DST or if you want to read a smaller version on my page https://werner.rothschopf.net/202011_arduino_esp8266_ntp_en.htm

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.