Ok so my house is over 200 years old, which means everything from plumbing to phone wiring wasn't pre-installed. This leads to issues such as flaky phone wiring interfering with my DSL modem. Every once in a while the modem will lose it's internet connection. This requires me to go down to my parent's house and manually turn off the modem, wait a few minutes, then turn it back on, then run back up to our apartment. My house was long ago split into 3 separate living spaces (from one HUGE colonial). The main portion my parents live in and the 2 separated spaces are apartments, the upstairs of which my wife and I rent.
It's not a huge deal for me to do it once a week when it usually drops out, but on occasion it's every day or sometimes even several times a day. I know it's not the modem as Verizon has sent different models as replacements, all of which suffer the same issue. They've also sent a tech out to inspect out lines from the pole to the house, again to no avail.
So I figured there's got to be an easier way for me to reset this thing. So I came up with this
Here is the modem we use:
And here is what I came up with to do my bidding:
I'll make a framework out of black acrylic that will hold the PCB and servo. The PCB in the illustration is an ATMega8A dev kit from Protostack that I was going to use, but it's a tad overkill for this purpose. I ended up using the ATMega8A that came with the dev kit, as the code was small enough to fit on it and save one of my 328's for a bigger project. I used this guide to load the Arduino bootloader onto the ATMega8A (I used the Arduino-to-breadboard illustration at the bottom as I only have one Arduino), then uploaded the code and tested it and it works perfectly!
Yet another HUUUUUGE thanks to crenn for helping me with the coding for this!
Here it is (servo positions still TBD):
What this will do is monitor the "Internet" light (internet connection status indicator) and control the servo to manually turn the power switch on and off. However, to prevent it from cycling when the light blinks (normal activity) there's a timer built in. When the light goes out it starts the timer. If after 30 seconds the light doesn't come back on, it moves the servo will switch off the modem, wait 2 minutes, switch it back on, then wait 3 minutes (for the modem to power itself on and re-establish the connection) then start reading again.Code:#include*<Servo.h> #define dropouttime 30000 #define offtime 120000 #define connecttime 180000 enum { waitingDrop='A', dropDetected='B', waitingConnection='C' }; enum{ turnOff=20, turnOn=160 }; int photocellPin = 0; int photocellReading; char state = waitingDrop; char laststate; unsigned char servoval = turnOff; long looptimer, servotimer; Servo servo; void setup() { Serial.begin(1200); servo.attach(9); servo.write(servoval); delay(2000); servoval = turnOn; servo.write(servoval); servotimer=millis(); looptimer=servotimer; } void loop() { if (((millis()-servotimer) > 50) || (state != laststate)) { servo.write(servoval); servotimer = millis(); } laststate = state; if (state == waitingDrop) { photocellReading = analogRead(photocellPin); Serial.print("Analog reading = "); Serial.println(photocellReading); servoval = turnOn; if ((photocellReading <= 400) && ((millis()-looptimer) > dropouttime)) { state = dropDetected; Serial.println("Dropout detected"); looptimer = millis(); } else if ((photocellReading > 400) && (state == waitingDrop)) { looptimer = millis(); } } else if (state == dropDetected) { servoval = turnOff; if ((millis()-looptimer) > offtime) { Serial.println("Turning Modem On and waiting for connection"); state = waitingConnection; looptimer = millis(); } } else if (state == waitingConnection) { servoval = turnOn; if ((millis()-looptimer) > connecttime) { state = waitingDrop; Serial.println("Waiting for Dropout"); looptimer = millis(); } } else { Serial.print("States: "); Serial.print(waitingDrop); Serial.print(dropDetected); Serial.println(waitingConnection); Serial.print("Invalid state: "); Serial.println(state); if ((millis()-looptimer) > dropouttime){ state = waitingDrop; looptimer = millis(); } } }
I made up the following in Fritzing.
The PCB layout.
The .pdf for etching the board.
I decided I'd have a go at etching my own board. It turned out a lot easier than I was expecting.
I printed the etch .pdf onto plain paper to check the pin spacing and alignment. Once everything checked out ok I printed it on a sheet of photo basic gloss for INKJET printers with my dad's laser printer. The reason for this is the toner will not adhere to the inkjet photo paper.
I then cut a small piece of the Radio Shack copper clad that would fit the circuit with room for mounting. In this pic I've notched where I'm going to cut it.
Now the next step is to heat the toner paper on the copper board with an iron on it's hottest setting. You need to press firmly and be sure to move the iron every 5-10 seconds to evenly heat it. This melts the toner and transfers it to the copper.
After you've got it good and crispy (yes the paper will brown, this is normal and shows you're heating it thoroughly), you let it cool, then soak it in hot water for 5-10 minutes to soften the paper. Then you simply peel it off, and gently rub off any remaining paper with your fingers. If it all goes well, you get this:
Then you put the PCB into a plastic container with your etchant. I used the Radio Shack etchant, but there's lots of recipes on the web about making your own using muriatic acid an other household chemicals. You need to constantly agitate the mixture to keep fresh fluid over the surface to speed up the etching. Mine took about 20 minutes, but time will vary depending on how old your solution is and how much copper needs to be etched away. After it's all good and etched, take it out and rinse it under tap water. If there's still copper left, soak it longer. Once it's etched, you are left with this:
Then you simply wipe off the toner with acetone (I used carb cleaner because I had it readily available), and you're left with a ready-to-drill board! The whole process took about an hour and was really easy.
That's all for now, I still need to drill the board and mount the components, and fab up the framework.