Notifications
Clear all

Implementing a safe unlock application

60 Posts
6 Users
6 Likes
2,525 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@papymouzot I have a piece of photography gear that has no off switch. The instructions are to replace the coin battery every 2 years. The battery is a CR2032. What kills the batteries is WiFi. 

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: 6662
 

@papymouzot Here is a link to the API https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/sleep_modes.html

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
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 

@papymouzot - Actually I hope you use a sleep mode concept and post your results here.  I've subscribed to your thread and look forward to your results.

But to clarify my suggestion - Understand, I'm not sure about the hardware wiring, but I've read about this and assume it can be implemented.  To me it sounds like picking yourself up by your bootstraps 😆   but I think the following can be done.  This wiring does not show the ground wires, but I think this should get the concept across.

image
  1. The unit is totally powered off, not using any power.
  2. Pressing the * key and holding it energizes the Arduino.
  3. When it boots up, it simply energizes the relay using the green logic wire.  This should do it.
    1. void setup() 
      {
        pinMode(RELAY_PIN, OUTPUT); 
        digitalWrite(RELAY_PIN, true);    // Power on relay first thing.
      
        Serial.begin(115200);
      }
      
      void loop()
      {
      }
  4. The Arduino is now powered through the relay.
  5. The * button can now be released and the rest of the combination be entered.
  6. When you want to turn off the power in your code, simply set the RELAY_PIN to false and it depowers the whole thing.

You said that you didn't want to have a power button, so I guess this represents using a power button.  I don't know about Arduinos, but I found booting of an ESP8266 took about two seconds, so the * key would have to be held for that amount of time.  

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


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

@papymouzot The randomnerds are always a good starting place. https://randomnerdtutorials.com/esp8266-deep-sleep-with-arduino-ide/

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: 6662
 

@papymouzot You can get a esp-01 down to 0.3ma, see the nerds article above.

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
Papymouzot
(@papymouzot)
Member
Joined: 2 years ago
Posts: 24
Topic starter  

@Ron, Thanks for your input. The Arduino I use is based on an Atmel328p chip, not a esp. The libraries seem to be different, although the concept should be the same. I wish I could find the same doc for the chip I use.

 

@all. I just started reading the 328p data sheet but although it helps understanding which registers are used to activate sleep mode and enable/clear interrupts It isn’t the most user friendly piece of documentation for my programming level. 

I would love to find some documentation about the 328 sleep and power libraries. My searches on the arduino web site didn’t bring back good usable results. I could not find their source code either. I’ll keep looking !!! 

@inq, I am not sure how to implement your proposed solution with using the * key to power the chip. The keypad is a matrix 3 by 4 and the four rows and 3 columns are wired to 7 I/O pins on the cpu. The pins are used by the keypad library to return which key(s) have been pressed. In my case it is pins 3,4 & 5 for the columns and 6,7,8 & 9 for the rows. I have read the source code of the library keypad.cpp in order to understand how it worked and I can’t really dissociate the * key without removing access to keys 1,4, 0 and # at the same time. 

I manage to bring the cpu to sleep and to wake it up using external interrupts int0 or int1 but not consistently using pin change interrupts. 


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

@inq Sounds good, just make sure it's a solid state type relay or MOSFET.

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: 6662
 

@papymouzot Ok, but why not switch to the esp?

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: 6662
 

@papymouzot Does this help https://circuitdigest.com/microcontroller-projects/arduino-sleep-modes-and-how-to-use-them-to-reduce-power-consumption

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.


   
Papymouzot reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 
Posted by: @papymouzot

I am not sure how to implement your proposed solution with using the * key to power the chip. The keypad is a matrix 3 by 4 and the four rows and 3 columns are wired to 7 I/O pins on the cpu. The pins are used by the keypad library to return which key(s) have been pressed. In my case it is pins 3,4 & 5 for the columns and 6,7,8 & 9 for the rows. I have read the source code of the library keypad.cpp in order to understand how it worked and I can’t really dissociate the * key without removing access to keys 1,4, 0 and # at the same time. 

Ah!  That makes sense they'd try to streamline the interface to those keypads.  I've not used one of those.  I was just assuming they were individual momentary switches.  

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


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

@papymouzot This looks like what you need for the arduino family

https://docs.arduino.cc/learn/electronics/low-power

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.


   
Papymouzot reacted
ReplyQuote
Papymouzot
(@papymouzot)
Member
Joined: 2 years ago
Posts: 24
Topic starter  

@zander 

 

Hi Ron, thanks for the docs !! I really appreciate.

I have just purchased a few Arduino UNO and one Nano for some "electric train layouts" projects. I don't really wish to go in various directions. Maybe the documentation you just provided links for will help me succeed with the hardware I have at present.

I only wish to do simple code, I just have the "safe unlock" project which is probably a little more demanding for me 😜 


   
ReplyQuote
Papymouzot
(@papymouzot)
Member
Joined: 2 years ago
Posts: 24
Topic starter  

If anybody knows where I could find some guidelines on how to use the sleep and power built-in libraries for the atmel328P based Arduino boards, I'll really appreciate...


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

@papymouzot However, many of the older boards are now end of life, the SAMD is the future. The SAMD boards will use less power. 

Here are some alternatives. Just creative food, not meant to be your solution.

https://github.com/ms1963/SleepyPico

https://www.pishop.ca/product/piz-uptime-ups-board-for-raspberry-pi-zerow/

 

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: 6662
 

@papymouzot I am pretty sure we all use google, no secret stashes of docs not on the web. I grabbed this part of your post

how to use the sleep and power built-in libraries for the atmega328 based Arduino boards

and the first hit was https://docs.arduino.cc/learn/electronics/low-power

That is official arduino documentation and appears to be fairly in-depth with code and useful explanations.

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 / 4