-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set up with wifi manager ? #3
Comments
https://www.youtube.com/watch?v=VnfX9YJbaU8&t=1120s This link worked for me and I adjust the sketch code to use the WiFiManager from this video and clear out the current sketch WiFi routine... /* /* It seems that the max RPM these motors can do is ~ 13 RPM, = ~ 1100 #include <Stepper.h> //#include "secrets.h" // Replace the ssid and password in secrets.h // Hostname // Preferences library namespace and keys. The library const int stepsPerRev = 2048; /* steps / rev for stepper motor / #define IN1 19 int stepDelay; /* minimum delay / step in uSec */ // initialize web server library // initialize the stepper library Preferences preferences; // initialize UDP library // Define the NTP server and timezone offset long timeZoneOffsetHours = 0; time_t getNtpMinute(); void setupWiFi() { // The above ordering shouldn't really be required; in an ideal // Note that calling getHostname() isn't a reliable way to verify // For a little more info, please see: //WiFi.setHostname(hostname); //while (WiFi.status() != WL_CONNECTED) {
//} void setupTz() { // Default to UTC preferences.end(); void setup() { // Setup Wi-Fi connection // Setup time zone variables // Initialize the NTP client and sync with the NTP server Serial.println("waiting for sync"); // Set up Arduino OTA ArduinoOTA
ArduinoOTA.begin(); // Set up the web server server.begin(); // Start the server pinMode(led, OUTPUT); myStepper.setSpeed(maxSpeed); time_t currentTime = now(); cMinute = pMinute = localTime.tm_min; // Start up cycle void loop() { // Handle incoming client requests // Check Wi-Fi connection and reconnect if necessary // Get the current time in seconds since January 1, 1970 (Unix time) // Convert the Unix time to local time long cStep = 0; /* current motor step count */ /* We go 1 rev = 2048 steps / hour / if (cMinute != pMinute && cMinute >= (pMinute + updateIntervalMinutes) % 60) { /* time for update? - every updateIntervalMinutes minutes /
} // Handle hour offsets
} void handleRoot() { ";
html += " Set Time";html += " Set the time you see on the clock now. Click submit to adjust the dial to current time automatically";html += ""; html += "Hour (1-12): "; html += "Minute (0-59): "; html += "Set Time"; html += "+5m"; html += "-5m"; html += "Recycle"; html += "Demo"; html += " Preferences";html += ""; html += "TZ hour offset: "; html += "TZ minute offset: "; html += "Daylight Savings Time currently in effect?<input type='checkbox' id='dst' name='dst'" + String( isDst ? "checked" : "") + "> "; html += "Save preferences"; html += " Debug Info";html += " cHour: cMinute = " + String(cHour) + ":" + (cMinute < 10 ? "0" : "") + String(cMinute) + " ";html += " pHour: pMinute = " + String(pHour) + ":" + (pMinute < 10 ? "0" : "") + String(pMinute) + " ";html += " timeZoneOffsetHours : timeZoneOffsetMins = " + String(timeZoneOffsetHours) + ":" + (timeZoneOffsetMins < 10 ? "0" : "") + String(timeZoneOffsetMins) + " ";html += " isDst = " + String(isDst ? "true" : "false") + " ";html += " hostname = " + String(hostname) + " ";
server.send(200, "text/html", html); void handleFormForward5() { Serial.println("full rotation clockwise"); Serial.println("Jump 5m"); server.send(200, "text/plain", "Moved 5 minutes Forward"); void handleFormBackward5() { Serial.println("full rotation clockwise"); Serial.println("Jump 5m"); server.send(200, "text/plain", "Moved 5 minutes Backward"); void handleFormRecycle() { Serial.println("full rotation clockwise"); server.send(200, "text/plain", "Cycle complete"); void handleFormDemo() { server.send(200, "text/plain", "Demo 12h Cycle complete"); void handleDialAdjustments(int iHour, int iMinute) { time_t currentTime = now(); cMinute = pMinute = localTime.tm_min; // Print the local time to the serial monitor // Parse the input time in hours and minutes // Calculate the time difference in minutes int minuteDifference = hourMinDiff + minuteDiff; // Print the time difference in seconds // Handle adjustments } void handleFormSetPreferences() {
} else { void handleFormSubmit() {
} else { /-------- NTP code ----------/ const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message time_t getNtpMinute() while (udp.parsePacket() > 0) ; // discard any previously received packets
} // send an NTP request to the time server at the given address |
Comment this out becaause WiFi will reset after power is turn off... //wm.resetSettings(); |
damm thats a really big sketch !! could you attach a note pad file instead please ? the github forums are adding unecessary stuff in to the code. |
How do i change your code to use it with wifi manager in this video : ?
this is to avoid compiling sketch for a new password and ssid.
https://www.youtube.com/watch?v=VnfX9YJbaU8&ab_channel=DroneBotWorkshop
The text was updated successfully, but these errors were encountered: