22 **************************************************
33 *
44 * @file Inkplate_6_Motion_WiFi_Simple.ino
5- * @brief Simply connect to your home Wi-Fi network and get some data
5+ * @brief Simply connect to your home Wi-Fi network and GET some data
66 *
77 *
88 * For info on how to quickly get started with Inkplate 6MOTION visit docs.inkplate.com
1616
1717Inkplate inkplate; // Create Inkplate object
1818
19- // Change WiFi SSID and password here.
20- #define WIFI_SSID " Soldered "
21- #define WIFI_PASS " dasduino "
19+ // Change WiFi SSID and password here
20+ #define WIFI_SSID " "
21+ #define WIFI_PASS " "
2222
2323// Link to download text data from
24- char httpUrl[] = {" https://example.com/" };
24+ char httpUrl[] = {" https://raw.githubusercontent.com/SolderedElectronics/Inkplate_Motion_Arduino_Library/refs/heads/"
25+ " dev/examples/Advanced/Web_WiFi/Inkplate_6_Motion_WiFi_Simple/exampleFile.txt" };
2526
2627void setup ()
2728{
@@ -40,14 +41,17 @@ void setup()
4041 WiFi.setMode (INKPLATE_WIFI_MODE_STA);
4142
4243 // Connect to WiFi:
43- if (!WiFi.begin (WIFI_SSID, WIFI_PASS))
44+ WiFi.begin (WIFI_SSID, WIFI_PASS);
45+ // Wait until we're connected, this is strongly reccomended to do!
46+ // At least do delay(3000) to give the modem some time to connect
47+ inkplate.print (" Connecting to Wi-Fi..." );
48+ while (!WiFi.connected ())
4449 {
45- inkplate.println (" Can't connect to Wi-Fi!" );
46- // Go to infinite loop
47- while (true )
48- delay (100 );
50+ inkplate.print (' .' );
51+ inkplate.partialUpdate (true );
52+ delay (1000 );
4953 }
50- inkplate.println (" Successfully connected to Wi-Fi!" );
54+ inkplate.println (" \n Successfully connected to Wi-Fi!" );
5155 inkplate.display ();
5256
5357 // Let's now download a file
@@ -60,13 +64,18 @@ void setup()
6064 // Try to open the page
6165 if (client.begin (httpUrl))
6266 {
67+ // Make GET request on that httpUrl
6368 if (client.GET ())
6469 {
70+ // GET was successful! Let's print some info
6571 inkplate.print (" Connected, file size: " );
6672 inkplate.print (client.size (), DEC);
6773 inkplate.println (" bytes" );
6874 inkplate.partialUpdate (true );
75+ inkplate.println (" " );
76+ inkplate.println (" File contents:" );
6977
78+ // Read file contents:
7079 while (client.available ())
7180 {
7281 // Use blocking method to get all chunks of the HTTP
@@ -86,23 +95,19 @@ void setup()
8695 }
8796 }
8897 }
89- inkplate.partialUpdate (true );
9098 }
9199 else
92100 {
93- inkplate.println (" Failed to get the file" );
94- inkplate.partialUpdate (true );
101+ inkplate.println (" Failed to get the file!" );
95102 }
103+ // Show updates on the display
104+ inkplate.partialUpdate (true );
105+
96106 // End client HTTP request
97107 // This is required! Otherwise any other AT command to the modem will fail
98108 client.end ();
99109
100- // Print out the received bytes
101- inkplate.print (" \n\n\n\n Total received bytes: " );
102- inkplate.println (totalSize, DEC);
103-
104- // End message
105- inkplate.println (" Done!" );
110+ // All done!
106111}
107112
108113void loop ()
0 commit comments