Close

​Wemos + bells + switch

A project log for Vintagephone - old rotary phone retrofitting

An open project to bring new functionalities to vintage phones with the nice old rotary, keeping their fascinating vintage style alive.

giulio-ponsGiulio Pons 05/15/2022 at 16:190 Comments

Ok, let's try to make those bells ring! How do they ring? Between the two bells there is a small hammer which rapidly and alternatively  move against the bells. It's moved with a magnetic field created by a coil.
You can try to manually swap the + and - poles of a 9 volts battery to two pins of the coil, and sometimes you can hear a small "ding" when you change the poles! 
So we need a way to feed in alternate current to two pins of the coil. The alternate current inside coils creates the magnetic field.
Since our project runs with direct current we need a way to transform it. I've first added a boost up to raise the voltage from 5 V to 12 V. The raised voltage then goes to the controlled input of the LD293 shield. This shield is commonly used to drive motors with an external power source, but with two pins from Wemos we can turn on and off alternatively the power to the output to pins A+ A-.

For example, we put 0 to A- and 1 to A+, then we can invert the values: A- to 1 and A+ to 0. So, if we use those A+ and A- to feed to the coil we have a signal that goes alternatively from -12 V to +12 V.

Try some different delays to match the proper frequency that sounds nice!

We can also connect a pin of Wemos to the switch to detect the close and open of the circuit.

When you disconnect all the cables you can turn upside-down that old circuit board and see the stain tracks, you can also try with the tester to find the two pins that change the state when you move the lever that drive the switch on and off.

Here is a small script that ring the bells a few times and then makes a pause. It will repeat until someone picks up the handset.
#define PIN_HANGUP_SWITCH D1      // switch hang up
#define PIN_BELL_1 D2
#define PIN_BELL_2 D3

void setup() {
  Serial.begin(115200);
  pinMode(PIN_HANGUP_SWITCH, INPUT_PULLUP);
  pinMode(PIN_BELL_1,OUTPUT);
  pinMode(PIN_BELL_2,OUTPUT);
}

//
// Ring the bells!
// Make a alternate square wave on bells coil with 2 pin and L293D driver
void bells() {
  int maxRings = 5;

  byte cornettaStatus; // 0 = OPEN, PICK UP - 1 = CLOSE, HUNG UP

  while(maxRings>=1) {
    int i = 0;

    cornettaStatus = digitalRead(PIN_HANGUP_SWITCH);  
    if(cornettaStatus==1) Serial.println("Ringing...");

    while(cornettaStatus==1 && i<30) {
      digitalWrite(PIN_BELL_2,LOW);
      digitalWrite(PIN_BELL_1,HIGH);
      delay(20);
      digitalWrite(PIN_BELL_2,HIGH);
      digitalWrite(PIN_BELL_1,LOW);
      delay(20);
      i++;
      cornettaStatus = digitalRead(PIN_HANGUP_SWITCH);  
    }
    
    if(cornettaStatus==0) Serial.println("Picked up!");
    digitalWrite(PIN_BELL_2,LOW);
    unsigned long ti = millis() + 2000;
    while(cornettaStatus == 1 && millis()<ti){
      delay(1);
      cornettaStatus = digitalRead(PIN_HANGUP_SWITCH);  
    }
    if(cornettaStatus==0) Serial.println("Picked up!");
    maxRings--;
  }
}

void loop()
{
  bells();
}

Here is also a video!

Discussions