Skip to content
Home » Home » Projects » New sensor as limit switch alternative

New sensor as limit switch alternative

I had the opportunity to test the following sensor: capacitive difference sensor W01. The sensor has two opposite measuring electrodes (A and B) which are responsible for detecting a capacitive change. There is a corresponding output for each measuring electrode. Due to this special design, the sensor is theoretically less sensitive to temperature changes and other external influences. Since both measuring electrodes are equally influenced by these influences, the difference between the two capacitances does not change.


The capacitive differential sensor (analog – non-linear) detects objects within its detection range without contact. As soon as the object enters here, the capacitance to the corresponding measuring electrode and thus the output voltage of the corresponding output changes. This can be used, for example, to determine the distance of the object to the measuring electrode. With the same capacitance between the two measuring electrodes (A, B) and ground, the output voltage at the respective outputs is 2.5 V. The difference between the two voltages is thus 0 V (sleep mode). If the capacitance of one of the measuring electrodes (A or B) changes, the output voltage of the corresponding output increases, while the output of the other measuring electrode decreases to the same extent (difference example). The output voltages can thus each assume a value between 0 V and 5 V. [Datasheet]

Use as limit switch for a diode laser

Since the sensor can detect objects in the detection range on both sides, I came up with the idea of using it as a limit switch for my diode lasers. Normally, two mechanical switches are required at both ends. With this sensor, it is possible to use only one. Namely, with the following structure in the feasibility study:

The sensor is mounted on the movable carriage of the laser head. Corresponding plates are mounted on the left and right to trigger the sensor. [Prototypischer Aufbau]

Wiring of the sensor

In order for the sensor to function like a typical limit switch, we do not need an analog output voltage, but a trigger signal that indicates in binary form whether an obstacle has been detected. To implement this, I used a prototype Arduino Nano, but an Attiny85 would be sufficient here. The circuit is simple, the laser motherboard has a slot with three pins. VCC and GND supply the circuit, and line S is pulled to ground when the switch is active. This allows the laser to detect a pressed limit switch. The sensor W01 is connected to the Nano, both the power supply and the two capacitive outputs, which are connected to analog inputs of the Nano. The 5V of the laser board is sufficient to supply the sensor, it can also be operated with 5V according to the manufacturer, instead of the 6V mentioned in the data sheet.


The code for this study is kept very simple. Basically, it would be interesting to make the threshold value digital or adjustable via a potentiometer so that you can adjust the distance during operation. In addition, logic should be implemented to avoid noise and bouncing of the output. All this has been neglected here.

const int analogInPinOne = 4;  
const int analogInPinTwo = 5; 
const int outputPin = 5;

int sensorValueOne = 0; 
int sensorValueTwo = 0; 
double outputValueOne = 0; 
double outputValueTwo = 0;
const double voltage = (double)5 / (double)1023;
double voltageDiff = 0;
const double threshold = 0.10;

void setup() {
  pinMode(outputPin, OUTPUT);

void loop() {
  // read sensor 1
  sensorValueOne = analogRead(analogInPinOne);
  // read sensor 2
  sensorValueTwo = analogRead(analogInPinTwo);
  // calculate voltages and difference
  outputValueOne = voltage * sensorValueOne;
  outputValueTwo = voltage * sensorValueTwo;
  voltageDiff = outputValueOne - outputValueTwo;

  //check if difference inside threshold (nothing there)
  if (voltageDiff<threshold&&voltageDiff>-threshold){
    //turn off LED and disable laser limit switch
    digitalWrite(LED_BUILTIN, LOW);
    digitalWrite(outputPin, HIGH);
    // if values outside threshold (obstacle detected): turn on led, activate laser limit switch
    digitalWrite(LED_BUILTIN, HIGH);
    digitalWrite(outputPin, LOW);


In the following videos, you can see the switch in operation. It works well right away, but there were also situations with a bouncing effect that interfered with the laser controller. Homing worked as well as triggering the hard limits on the other end, as a limitation of the workspace.

Another picture of the test setup with Arduino flying wired on the side.


The sensor is generally well suited for similar applications. In this case, it may have been misappropriated somewhat, but it still worked smoothly. Overall, of course, the structure still needs to be improved and the processing of sensor data greatly improved, e.g., to be more robust against interference. However, such a sensor would even be suitable, among other things, to trigger disturbances, for example, when a person reaches into the work area. In this case, triggering would even be favorable. Another use case would be a z-distance sensor to detect a workpiece and additionally even detect if the workpiece is aligned perpendicular to the laser head.

I thank you again for the opportunity to test the sensor and will perhaps try one or the other gimmick with it in the future. More videos about the sensor can be found here: YouTube channel and here: Instructables project.