I finally bought the new Arduino Giga R1 WIFI. I mounted the Wifi antenna to the u.FL connector. The Mega 2560 has a power jack that I connect up a 9V 1A power pack. The Giga R1 WIFI has a audio output instead. The VIN port can take 6V-24V. I am going to see about getting a 24V 1A power pack. The other interesting thing was pins for the RTC (Real Time Clock). You can solder pins and connect a battery to hold up the time.
The Arduino GIGA R1 is one of our most feature-packed Arduino boards to date, supported by the same powerful, ML-capable, dual-core microcontroller found in the Pro family’s Portenta H7. It features support for display connectors, USB-host, an Audio Jack, an Arducam connector, a CAN bus, 4 UART Serial Ports, 2 I2C buses, dedicated DAC Pins, and much, much more.
It came with a plastic mounting case under it.
This is my new Giga R1 Wifi
1.) Setup Wifi and assigned a IP
2.) Formatted a 32GB, opened a directory, wrote a file to the USB
3.) Setup NTP from naval time server. It is in UTP time.
4.) Setup all the MBED Giga libraries.
Here is the sketch storage and memory usage. The Mega 2560 has nothing on the Giga.
Sketch uses 294348 bytes (14%) of program storage space. Maximum is 1966080 bytes.
Global variables use 68320 bytes (13%) of dynamic memory, leaving 455304 bytes for local variables. Maximum is 523624 bytes.
Starting USB Dir List example…
Mounting USB device… done.
Opening the root directory… Done
done.
Root directory:
System Volume Information
numbers
2 files found!
Closing the root directory… OK
mount done Open /usb/numbers/integer.txt
Writing numbers (0/10)
Writing numbers (1/10)
Writing numbers (2/10)
Writing numbers (3/10)
Writing numbers (4/10)
Writing numbers (5/10)
Writing numbers (6/10)
Writing numbers (7/10)
Writing numbers (8/10)
Writing numbers (9/10)
File closing
File closed
Attempting to connect to SSID: OurFamilyWIFIAP
Connected to WiFi
SSID: OurFamilyWIFIAP
IP Address: 192.168.40.16
Gateway: DNS Address: 1.0.0.1, 1.1.1.1
signal strength (RSSI):-54 dBm
UTC System Clock: Sun 2024-03-17 22:47:55
/* Arduino GIGA Real Time Clock - WiFi giga-rtc-wifi.ino Demonstrates Arduino GIGA real time clock operation using Internet time source Prints time to serial monitor Code provided by Arduino */ /* Udp NTP Client Get the time from a Network Time Protocol (NTP) time server Demonstrates use of UDP sendPacket and ReceivePacket For more on NTP time servers and the messages needed to communicate with them, see http://en.wikipedia.org/wiki/Network_Time_Protocol created 4 Sep 2010 by Michael Margolis modified 9 Apr 2012 by Tom Igoe modified 28 Dec 2022 by Giampaolo Mancini This code is in the public domain. */ #include <Wire.h> #include <WiFi.h> #include <WiFiUdp.h> #include <mbed.h> #include <mbed_mktime.h> #include <Time.h> #include <FATFileSystem.h> #include <Arduino_USBHostMbed5.h> USBHostMSD msd; mbed::FATFileSystem usb("usb"); int status = WL_IDLE_STATUS; #include "arduino_secrets.h" ///////please enter your sensitive data in the Secret tab/arduino_secrets.h char ssid[] = SECRET_SSID; // your network SSID (name) char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) int keyIndex = 0; // your network key index number (needed only for WEP) unsigned int localPort = 123; // local port to listen for UDP packets constexpr auto timeServer{ "tock.usno.navy.mil" }; const int NTP_PACKET_SIZE = 48; // NTP timestamp is in the first 48 bytes of the message byte packetBuffer[NTP_PACKET_SIZE]; // buffer to hold incoming and outgoing packets // A UDP instance to let us send and receive packets over UDP WiFiUDP Udp; constexpr unsigned long printInterval{ 1000 }; unsigned long printNow{}; void setup() { // Open serial communications and wait for port to open: Serial.begin(115200); pinMode(PA_15, OUTPUT); //enable the USB-A port digitalWrite(PA_15, HIGH); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.println("Starting USB Dir List example..."); // if you are using a Max Carrier uncomment the following line // start_hub(); while (!msd.connect()) { //while (!port.connected()) { delay(1000); } Serial.print("Mounting USB device... "); int err = usb.mount(&msd); if (err) { Serial.print("Error mounting USB device "); Serial.println(err); while (1) ; } Serial.println("done."); Serial.println(" "); char buf[256]; // Display the root directory Serial.print("Opening the root directory... "); DIR* d = opendir("/usb/"); Serial.println(!d ? "Fail :(" : "Done"); if (!d) { snprintf(buf, sizeof(buf), "error: %s (%d)\r\n", strerror(errno), -errno); Serial.print(buf); } Serial.println("done."); Serial.println("Root directory:"); unsigned int count{ 0 }; while (true) { struct dirent* e = readdir(d); if (!e) { break; } count++; snprintf(buf, sizeof(buf), " %s\r\n", e->d_name); Serial.print(buf); } Serial.print(count); Serial.println(" files found!"); snprintf(buf, sizeof(buf), "Closing the root directory... "); Serial.print(buf); fflush(stdout); err = closedir(d); snprintf(buf, sizeof(buf), "%s\r\n", (err < 0 ? "Fail :(" : "OK")); Serial.print(buf); if (err < 0) { snprintf(buf, sizeof(buf), "error: %s (%d)\r\n", strerror(errno), -errno); Serial.print(buf); } Serial.println(" "); Serial.print("mount done "); mbed::fs_file_t file; struct dirent *ent; int dirIndex = 0; int res = 0; Serial.println("Open /usb/numbers/integer.txt"); FILE *f = fopen("/usb/numbers/integer.txt", "w+"); for (int i = 0; i < 10; i++) { Serial.print("Writing numbers ("); Serial.print(i); Serial.println("/10)"); fflush(stdout); err = fprintf(f, "%d\n", i); if (err < 0) { Serial.println("Fail :("); error("error: %s (%d)\n", strerror(errno), -errno); } } Serial.println("File closing"); fflush(stdout); err = fclose(f); if (err < 0) { Serial.print("fclose error:"); Serial.print(strerror(errno)); Serial.print(" ("); Serial.print(-errno); Serial.print(")"); } else { Serial.println("File closed"); Serial.println(" "); } // if you are using a Max Carrier uncomment the following line //start_hub(); while (!msd.connect()) { delay(1000); } // check for the WiFi module: if (WiFi.status() == WL_NO_SHIELD) { Serial.println("Communication with WiFi module failed!"); // don't continue while (true) ; } // attempt to connect to WiFi network: while (status != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); // Connect to WPA/WPA2 network. Change this line if using open or WEP network: status = WiFi.begin(ssid, pass); // wait 10 seconds for connection: delay(10000); } Serial.println("Connected to WiFi"); printWifiStatus(); setNtpTime(); Serial.print("UTC System Clock: "); Serial.println(getLocaltime()); } void loop() { } void setNtpTime() { Udp.begin(localPort); sendNTPpacket(timeServer); delay(1000); parseNtpPacket(); } // send an NTP request to the time server at the given address unsigned long sendNTPpacket(const char* address) { memset(packetBuffer, 0, NTP_PACKET_SIZE); packetBuffer[0] = 0b11100011; // LI, Version, Mode packetBuffer[1] = 0; // Stratum, or type of clock packetBuffer[2] = 6; // Polling Interval packetBuffer[3] = 0xEC; // Peer Clock Precision // 8 bytes of zero for Root Delay & Root Dispersion packetBuffer[12] = 49; packetBuffer[13] = 0x4E; packetBuffer[14] = 49; packetBuffer[15] = 52; Udp.beginPacket(address, 123); // NTP requests are to port 123 Udp.write(packetBuffer, NTP_PACKET_SIZE); Udp.endPacket(); } unsigned long parseNtpPacket() { if (!Udp.parsePacket()) return 0; Udp.read(packetBuffer, NTP_PACKET_SIZE); const unsigned long highWord = word(packetBuffer[40], packetBuffer[41]); const unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]); const unsigned long secsSince1900 = highWord << 16 | lowWord; constexpr unsigned long seventyYears = 2208988800UL; const unsigned long epoch = secsSince1900 - seventyYears; set_time(epoch); /* #if defined(VERBOSE) Serial.print("Seconds since Jan 1 1900 = "); Serial.println(secsSince1900); // now convert NTP time into everyday time: Serial.print("Unix time = "); // print Unix time: Serial.println(epoch); // print the hour, minute and second: Serial.print("The UTC time is "); // UTC is the time at Greenwich Meridian (GMT) Serial.print((epoch % 86400L) / 3600); // print the hour (86400 equals secs per day) Serial.print(':'); if (((epoch % 3600) / 60) < 10) { // In the first 10 minutes of each hour, we'll want a leading '0' Serial.print('0'); } Serial.print((epoch % 3600) / 60); // print the minute (3600 equals secs per minute) Serial.print(':'); if ((epoch % 60) < 10) { // In the first 10 seconds of each minute, we'll want a leading '0' Serial.print('0'); } Serial.println(epoch % 60); // print the second #endif return epoch; */ } String getLocaltime() { char buffer[32]; tm t; _rtc_localtime(time(NULL), &t, RTC_FULL_LEAP_YEAR_SUPPORT); strftime(buffer, 32, "%a %Y-%m-%d %H:%M:%S", &t); return String(buffer); } void printWifiStatus() { // print the SSID of the network you're attached to: Serial.print("SSID: "); Serial.println(WiFi.SSID()); // print your board's IP address: IPAddress ip = WiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip); IPAddress gateway = WiFi.gatewayIP(); Serial.print("Gateway: "); IPAddress dns_0 = WiFi.dnsIP(0); IPAddress dns_1 = WiFi.dnsIP(1); Serial.print("DNS Address: "); Serial.print(dns_0); Serial.print(", "); Serial.println(dns_1); // print the received signal strength: long rssi = WiFi.RSSI(); Serial.print("signal strength (RSSI):"); Serial.print(rssi); Serial.println(" dBm"); Serial.println(" "); }
I modified the base sketch to include gateway and both DNS servers. The input cable is the same as my Android phone, USB-C.
Connected to wifi
SSID: xxxxxxxxx
IP Address: 192.168.40.16
Gateway: 192.168.40.173
DNS Address: 1.0.0.1, 1.1.1.1