Hi,
I have received the;
- ESP-01 ESP8266
- ESP-01 ESP8266 Programmer Adapter
I have followed the guides around. Added the URL for additional board manager. Installed the library for ESP8266 and went on to try and test uploading first; blank program, then the blink program to test it out. Sadly, i got an error allready on my first goal, when trying to upload clean sketch.
I get the following Errorcode:
. Variables and constants in RAM (global, static), used 28104 / 80192 bytes (35%)
║ SEGMENT BYTES DESCRIPTION
╠══ DATA 1496 initialized variables
╠══ RODATA 920 constants
╚══ BSS 25688 zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 59667 / 65536 bytes (91%)
║ SEGMENT BYTES DESCRIPTION
╠══ ICACHE 32768 reserved space for flash instruction cache
╚══ IRAM 26899 code in IRAM
. Code in flash (default, ICACHE_FLASH_ATTR), used 232100 / 1048576 bytes (22%)
║ SEGMENT BYTES DESCRIPTION
╚══ IROM 232100 code in flash
esptool.py v3.0
Serial port COM3
Connecting...
Failed uploading: uploading error: exit status 2
To troubleshoot, i have verified the following:
- I have selected the correct board; Generic ESP8266 Module
- Selected to proper COM
- Confirmed CPU frequency at 80MHz
- Flashsize 512kb at 64kb
Im looking for help to troubeshoot why i cant upload sketch to the Wifi module.
I have read some that i might need to solder a reset button on the programmer module it self, but dunno if thats strictly needed?
Bonusquestion; This is the main goal, to upload a sketch to my arduino uno, and retrieving the data for correct date and time.
Can i upload the following code to my Arduino Uno? I struggle to understand if i need to program them separately, and how i know which code to "split".
//Tilføjer bibloteker til brug for at indlæse wifi og dato-modul.
#include <ESP8266WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
// Replace with your network credentials
const char *ssid = "XYZ";
const char *password = "ZYX";
// Define NTP Client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org");
//Week Days
String weekDays[7]={"Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag"};
//Month names
String months[12]={"Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December"};
void setup() {
// put your setup code here, to run once:
//Setupprogram for WIFI-modul og til at få tiden
// Initialize Serial Monitor
Serial.begin(115200);
// Connect to Wi-Fi
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Initialize a NTPClient to get time (sætter den til dansk tid, dvs. GMT +1)
timeClient.begin();
// Set offset time in seconds to adjust for your timezone, for example:
// GMT +1 = 3600
// GMT +8 = 28800
// GMT -1 = -3600
// GMT 0 = 0
timeClient.setTimeOffset(3600);
}
void loop() {
//Indhenter opdateret tid
timeClient.update();
//EpocTime, antal sekunder der er gået siden 1970.
time_t epochTime = timeClient.getEpochTime();
Serial.print("Epoch Time: ");
Serial.println(epochTime);
// Returnere tiden i HH:MM:SS format.
String formattedTime = timeClient.getFormattedTime();
Serial.print("Formatted Time: ");
Serial.println(formattedTime);
// Angiver antal time fra 0-24
int currentHour = timeClient.getHours();
Serial.print("Hour: ");
Serial.println(currentHour);
//Angiver minut fra 0-59
int currentMinute = timeClient.getMinutes();
Serial.print("Minutes: ");
Serial.println(currentMinute);
// Angiver sekund fra 0- 59
int currentSecond = timeClient.getSeconds();
Serial.print("Seconds: ");
Serial.println(currentSecond);
//0 corresponds to Sunday and 6 to Saturday.
String weekDay = weekDays[timeClient.getDay()];
Serial.print("Week Day: ");
Serial.println(weekDay);
//Get a time structure
//tm_sec: seconds after the minute;
//tm_min: minutes after the hour;
//tm_hour: hours since midnight;
//tm_mday: day of the month;
//tm_year: years since 1900;
//tm_wday: days since Sunday;
//tm_yday: days since January 1;
//tm_isdst: Daylight Saving Time flag;
struct tm *ptm = gmtime ((time_t *)&epochTime);
int monthDay = ptm->tm_mday;
Serial.print("Month day: ");
Serial.println(monthDay);
int currentMonth = ptm->tm_mon+1;
Serial.print("Month: ");
Serial.println(currentMonth);
String currentMonthName = months[currentMonth-1];
Serial.print("Month name: ");
Serial.println(currentMonthName);
int currentYear = ptm->tm_year+1900;
Serial.print("Year: ");
Serial.println(currentYear);
//Print complete date:
String currentDate = String(currentYear) + "-" + String(currentMonth) + "-" + String(monthDay);
Serial.print("Current date: ");
Serial.println(currentDate);
Serial.println("");
delay(500);
}