Notifications
Clear all

ESP32 - Wifi hotspots - and RTC modules

77 Posts
5 Users
22 Likes
6,025 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@ajpatrick @will Couple ideas.

1. Post FORMATTED (Tools/Auto Format) code you intend to move forward with.

2. Using a #define of either print or screen wrap all the printer code in #ifdef so somebody without a printer can test your code.

3. Move all the WiFi code to setup

My WiFi is super unreliable but maybe wil can help you add wifimgr

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
AJPatrick reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@will I don't think so, the entire point of wiFiMgr is to eliminate that. There is no passwords in the code with WiFiMgr.

DST is handled in the RTC although if they do cancel it I imagine there will be chaos this fall.

If that happens the reset switch should fix it if you code setup to always set the rtc.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@ajpatrick)
Member
Joined: 2 years ago
Posts: 16
Topic starter  

@will fortunately for me, i live in a state in Australia that refused to adopt day light savings like all those darn progressive southern states. I believe out of fear that the extra hour of sunlight would fade the curtains and confuse the cows. 🙂

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@ajpatrick Here is how to set your code up so it will either print or use the serial output. As it sits, it will use Serial, if you uncomment the first statement so that PRINTER is defined then your code inside the #ifdef PRINTER and the #endif is executed. Now folks trying to help can run your code without a physical printer.

 

//#define PRINTER

void setup() {    // put your setup code here, to run once:

  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

#ifdef PRINTER
  Serial.println(" Pretend there is a printer attached ");
#endif

#ifndef PRINTER
  Serial.println(" No Printer attached ");
#endif
}

void loop() {   // put your main code here, to run repeatedly:

}

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
AJPatrick reacted
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2507
 
Posted by: @zander

@will I don't think so, the entire point of wiFiMgr is to eliminate that. There is no passwords in the code with WiFiMgr.

OK, but I thought that it was personal and that everybody had to set up their own parameters so that they would automatically be accessed. I didn't think that one person could set up access for others.

DST is handled in the RTC although if they do cancel it I imagine there will be chaos this fall.

Indeed !

If that happens the reset switch should fix it if you code setup to always set the rtc.

Yes, as long as there's a convenient time source available. Maybe they need to set up a WIFI net in the teacher's lounge. Then all they'd have to do is reset their devices as needed in the lounge using that common ID and password and all of the teachers could use the pass generators.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2507
 
Posted by: @ajpatrick

@will fortunately for me, i live in a state in Australia that refused to adopt day light savings

You have no idea how lucky you are. It is a vexatious nuisance and seems unlikely to have ever saved anywhere near enough energy to have warranted its introduction.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@will One of us is confused. The point of WiFi Manager I thought, I am falling asleep as I type so can't watch the video again,

To set up a board that connects to Wifi and in this case will once connected call the national time server to get the correct time and store it in the battery backed real time clock. The person holding the device puts their phone in hotspot mode and sets a password. Then by pressing the reset switch on the esp32 the setup code runs and (not sure of this part) uses some sort of usb keyboard to ask if the clock is ok or not. IF it is decided the clock needs to be reset then the person is asked for the creds on their phone. Done! No creds are stored in the esp32. There may even be RTC class variables that tell you the battery was changed.

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@ajpatrick

Posted by: @ajpatrick

@zander Hi Ron,

You are right, and that was the original design. no wifi or bluetooth, just the RTC set when the program was uploaded. But if i am giving it to someone else, who may leave the school or move away etc. and the battery fails they have no way of setting the time without getting the source code, and uploading it again. if it was just for me, i don't actually need to change it, but because i will be giving it to someone i don't want it to be difficult to use if the is an issue, like the time being wrong, because it is the main component of the whole device, without an accurate time the tickets are useless. so i am just being careful really.  I don't want it to check the ntp unless there is wifi connection avaiable is what i was thinking. so the teacher sees the time is wrong, presses a button which connects it to their phone and grabs the time, stores it in the rtc, then the device is good to go for months hopefully. does that make sense? i might not be being very clear sorry.

The following reading may (or may not) help, but it's always a good start 🙂

ESP32 Synchronization, Time Zones, etc...

Cheers


   
AJPatrick reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@will Let me try again. Do you have a cell phone? Does it have a personal hotspot? Do you create a password for your personal hotspot? I am positive the answers to all 3 of those questions is yes. You are not sharing with anyone unless other than by extreme random chance no different than your home router. Once you have your phone set up as a mobile router then via WiFi Manager you connect to the internet and get the time. Am I explaining it any better? This is no different than connecting your Mac to the internbet via your router, replace router with phone hotspot, replace Mac with esp32 board.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@frogandtoad I have read that some ESP32 boards have built in RTC, but do they have a battery? I don't see any battery on mine.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@zander

Posted by: @zander

@frogandtoad I have read that some ESP32 boards have built in RTC, but do they have a battery? I don't see any battery on mine.

I don't know of any ESP32 boards that have a built in battery.  However, I thought the main issue was around timezone and synchronization?


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@frogandtoad The issue is how to connect to an ESP32 without exposing creds in order to set a RTC via a time server. I am not a strong network guy, but I thought it was possible to create an esp32 app that would expose an interface where you log in with anonymous creds and immediately connect to the persons phone. Maybe today I will feel strong enough to set that up or I am 100% wrong.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@inq and fyi @will @ajpatrick Networking and WiFi are NOT my strength but I think there is a solution that @Inq will know because it is his strength.

In a nutshell we have an app (second issue) that needs a real time clock with battery backup and about every two years needs a new battery. When the battery is changed it needs to connect to an internet time server to initialize itself. The op @ajpatrick has an esp32 app that colleagues would also like to use.

Q: How to modify the app so it will connect to the several different colleagues phones in hotspot mode (or any convenient AP) to make the connection to the time server. At the moment he has creds hard coded but that is obviously not scalable. 

In other words is it possible to create code with NO embedded creds that will prompt the user for the creds of his/her phone or other AP to gain internet access. Part two is, how do we get the app to interface with the new users every couple years. I think they will need a computer and usb cable to power it and provide a gui.

Obviously the gui to get my phone creds can be triggered by the reset button, but if a reset is needed for any other reason, power loss for instance can the gui time out and continue on with remembered creds since the RTC has the current time and NO internet access is required. There is only a problem when the RTC clock is at zero due to battery replacement. 

I hope I made that understandable.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
AJPatrick reacted
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2507
 
Posted by: @zander

@will One of us is confused.

It's me, but I'm not confused, just ignorant 🙂 I don't know anything about WIFI.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@will And I know a little bit so I am worse off than if I was totally ignorant. @inq will know what to do, I am fairly confident of my gut feel, but certainly not 100%.

This situation is no different than going to the store and buying a 'smart outlet' It has to get connected to the internet somehow.

If I recall the sequence of events, it broadcasts an AP, I click on it on my phone, then my phone app (just a browser in this case) connects the outlet to my home network with my new made for it credentials.

The difference, is after the browser connects somehow we need to shoot the time to the board. I will bet you a few beers @Inq will chuckle at how easy this is (at least I hope so)

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Page 2 / 6