Adding an alarm (buzzer) to the kit

More
2 years 2 months ago #8692 by fotr3bor
Hi,

I will soon start building my first Nixie Clock using Ian's kit. I'm thinking about the possibility of adding some kind of buzzer/speaker to implement an alarm feature. The software side of things is okay - I can code the stuff required to make it work, but what I'm missing is experience/knowledge on the hardware side.

First, I think that I need a separate controller/board to handle all of this extra stuff. Arduino Nano sounds interesting for this purpose due to its size and flexibility. However, I'd really like to be able to configure the alarm on the already existing web interface hosted on the ESP8266, but due to my limited HW knowledge, I can't think of an immediate solution on how to handle the communication between the extra controller and the ESP8266 or the extra controller and the main Atmega controller on the board.

Can somebody point me to the right direction? There's always the possibility of adding another ESP chip, but that doesn't really sound like a clean solution to me.
Thanks in advance!

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #8693 by Ty_Eeberfest
Which kit do you have? Classic, All-In-One or Modular?

Adding an alarm would be a simple matter of hooking up a piezo beeper to a spare GPIO output, BUT there aren't any spare GPIO pins unless you want to give up something (like LEDs or separators?) to free up a pin. This would be the simplest approach - just hook up the beeper and modify the code in the ATMega and the ESP. But maybe you don't want to give up anything, so...

You can get around the lack of available spares a few ways using the I2C bus. I2C is already used to talk between the ESP and the ATMega, so the "guts" of I2C are already in the code as well as the "application layer" code for passing values between ESP and ATMega. I2C can have more than 2 "nodes" so tacking on some other I2C aware piece of hardware is possible.

You could use an I2C I/O port expander such as the MCP23008 chip, though I don't know off the top of my head whether there's a good library for talking to it. Hook your buzzer to an output pin on the expander and add all your code to the ATMega clock code and the ESP code.

You could also use a Nano (or something like one) connected to the ATMega over I2C, Hook your buzzer to an output pin on the Nano. From there it's a judgement call as to whether you add all your code to the ATMega and ESP, put some minimal code in the Nano, and treat the Nano like it's a dumb I/O expander - or put most of your code in the Nano and add a little bit to the ATMega and ESP. My initial thought is to treat the Nano as a dumb expander, All the states and values you need to see in order to control your alarm are in the ATMega. Smart Nano method you have to pass them all to the Nano all the time. Dumb Nano method the only thing you have to pass is "buzzer turn on" and "buzzer turn off".

Actually when I think about what I just wrote I'm almost positive "Dumb Nano" is much better then "Smart Nano". With dumb nano you can set your alarm setpoints, store them in EEPROM, compare time to alarm setpoints, etc. all by adding to the existing framework that already handles such things in & between the ATMega and the ESP. The smart nano scheme would require you to do all that over I2C which might not be pretty.

That's my 5 minute take on the subject. Perhaps Ian has a better idea...



Here's the repo for the Classic and All-In-One kits:
github.com/isparkes/ArdunixNix6
Clock is ardunixFade9_6_digit and ESP is WifiTimeProviderESP8266

For the Modular the code is here:
bitbucket.org/isparkes/nixiefirmwarev2/src
Clock is ModularRev3 and ESP is WifiTimeProviderESP8266

I'm pretty sure the ESP code is not the same in the 2 repos so to be on the safe side grab the ESP code from the same place you get your clock code.

Look into it later when the dust is clearing off the crater.

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #8694 by fotr3bor
Hi,

thank you for the comprehensive answer! It really helped. I own the all-in-one kit (obviously with the wifi module).

For the sake of simplicity I think that adding a dumb Arduino Nano is the best idea. Am I able to just hook up the extra Arduino on the SCA/SCL lines of the ATmega controller, without any additional electronics?

Thanks again for your valuable help!

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #8695 by Ty_Eeberfest

fotr3bor wrote: For the sake of simplicity I think that adding a dumb Arduino Nano is the best idea. Am I able to just hook up the extra Arduino on the SCA/SCL lines of the ATmega controller, without any additional electronics?


Yep, the "extra parts" you'll install on the clock board to support the WiFi module include the I2C pull-up resistors, so all you have to do is connect SDA to SDA and SCL to SCL.

I thought about the "dumb nano" option a bit more and I still like it best. Keep this in mind though: when the WiFi module is present, the clock's ATMega drops into I2C Slave mode and the WiFi module becomes the I2C Bus Master. Only a Master can initiate a data transfer. So it's not as simple as making the Nano a Slave and throwing commands at it. I2C allows multiple Masters, and arbitration for control of the bus seems to be transparent (check me on this!). So your Nano could be a Master and it could fetch a byte from the ATMega every second (or something - basically a periodic polling scheme) to learn what's expected of it. Just a byte that's true if ATMega wants the beeper to beep and false if it wants it to shut up.

That's the general idea at least. I'm no I2C expert but I'm not totally in the dark either. I suggest you read one of the many short articles out there that summarize the main points of how it works.

Also, if you haven't already guessed it, the Arduino I2C libraries are in wire.h. In the clock and WiFi source files search for method calls like Wire.Start() and the like to see how the I2C comms between the clock, the WiFi module and the optional (and unnecessary) RTC module are done. Pretty straightforward to follow once you know what you're looking for.

Look into it later when the dust is clearing off the crater.

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #8696 by Ty_Eeberfest
I should add... if you read articles about how I2C works, don't get too hung up on the electrical & timing details. The wire.h library encapsulates all the complexities and all you really have to do in code is Start / Send / Receive / Stop. Kinda like dealing with a TCP socket or a named pipe on a PC.

Look into it later when the dust is clearing off the crater.

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #8697 by fotr3bor
All clear! Thank you very much, you helped me immensely. I just ordered the Nano, I'll let you know how it goes and if I can actually talk to it using I2C.

Have a good day!
Roberto

Please Log in or Create an account to join the conversation.

Moderators: AccutronTy_EeberfestIan
Time to create page: 0.093 seconds

Search

Tube Suppliers

Go to top
JSN Boot template designed by JoomlaShine.com