Skip to content

rassawyer/Bell_Control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Bell Control

Background

About a month ago, I was asked by a client to install an alarm bell that could notify an employee who is working in their warehouse/shop area, whenever the door to their showroom was opened. This is a commercial setting and the ambient noise level is fairly high, so I designed and installed a circuit using an 85dB, 120VAC alarm bell from Amazon. The bell is controlled by a relay, driven by a 12VDC power supply, and triggered by a Reed switch on the door. All in all, it is a fairly straight-forward circuit. Unfortunately, no sooner was it placed into service than the client requested a modification. As it happens, the door to the showroom spends quite a bit of time open, and the alarm bell rings the whole time that it is open. The other occupants of the building were displeased. The client requested that I configure it so that the bell would ring twice, for 3 seconds each time. Thus I began writing a project to use an ESP8266 to take an input from a 12VDC source, and trigger a relay. However, the thought in the back of my mind the whole time was "Does this client realize how long 3 seconds of 85dB bell ringing is?". I fear the answer is that he does not, and so I embarked on a much more challenging adventure: How to write a web server, that could serve multiple pages, take input from the user, and update variables, so that the client could easily configure On Time/Off Time/Cycle counts for himself.

Other Projects Referenced

In the process of trying to get the web server and the bell controls working, I studied countless StackOverflow questions, numerous other code samples, and several other micro conntroller projects. Then most notable can be found at the following links: https://randomnerdtutorials.com/esp8266-web-server/ https://www.esp8266.com/viewtopic.php?p=80548#p80548

Result

In the end, I came up with a fairly basic circuit, consisting of an ESP8266 micro controller, 2 buck converters, and a relay, plus, of course, the items mentioned at the begining of this README. The switch at the door still operates on 12VDC, such that when the door is opened, it closes the switch, completing the circuit. That then feeds a buck converter, which steps the voltage down to 5VDC, to be appropriate to use as an input signal for the micro controller (I do not fully trust thisand I have not done the research to verify. My concern is that 5V may be too high for the inputs to the microcontroller). The micro controller itself is powered via the other buck converter, which takes the 12VDC supply from the power supply, and steps it down to 3.3VDC, as any thing above 3.3VDC is known to fry the ESP8266. When the micro controller receives a 5VDC signal on GPIO15, it triggers an interupt, which activates the bell for the first ring cycle, and sets the cycle count variable to the appropriate number. From there, control returns to the main loop, and on-off cycles are controlled by global variables, using the hardware clock of the micro controller as the timing mechanism. By far the most difficult part was getting the C++ code to properly serve the HTML and JavaScript code to make the front end perform as I desired. The root URL displays a summary of the current settings, and a button to click/touch to edit the settings. That button takes the user to a page where they can set the number of seconds for which they wish the bell to remain on, as well as another buttton to continue with changing the settings. When the user activates that button, the javascript gets the contents of the text box, and appends it to the URL as a query param. This process then repeats for the user to set the number of seconds for the bell to be off between times that it is on, and finally to set the number of times for the bell to ring upon each activation. The final screen summarizes the new settings, and includes a button to return home. I realize that using buttons to handle links is somewhat of an anti-pattern, however I felt that it was appropriate since the link is primarly ancillary to it's primary duty of running the JS.

More recent

I successfully implemented variable persistance across reboots/power outages by utilizing LittleFS, and writing the variables to a file, then reading from the file on startup. If the file does not exist, then it uses 3 seconds on/3seconds off/2 cycles as the defaults.

Future

So, as it turned out, this project got put on the back burner, as my our first child came much earlier than expected. By the time I had capacity to get back to this, the client had sold his business and no longer needed it. I intend to leave this repo here, and have some other projects in mind that might reuse some of the code from this, but this is not a finished solution. Perhaps some day I will have the time and inspiration to come back and push this through to feature completion, but for now, other priorites demand my attention.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages