Avatar for Oscar

Oscar

Member since Jan 2020 • Last active Feb 2020
  • 1 conversations
  • 8 comments

Most recent activity

    • 18 comments
    • 1,405 views
  • in Puck.js, Pixl.js and MDBT42
    Avatar for Oscar

    I use macOS.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Oscar

    @Robin, the calls to setWatch() and setInterval() were uploaded from the right-hand editor side. For testing, I used individual calls to digitalRead() and analogRead() from the console (left-hand side).

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Oscar

    As far as I remember, the 5V pin is directly connected to the 5V pin of the USB header. That is: you will get 5 V from the charger only you have it connected via USB to a power source.

    In order to integrate the charger into your project, you would power the MDBT42Q using the BAT and GND pins of the charger, connect the LiPo battery to the charger and using the USB port of the charger to charge the battery when needed.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Oscar

    Well guys:

    I did a hard reset of the board, erased the saved code, did not physically change anything on the circuit but it is now working, that is, digitalRead can sense touches on the board.

    I have no idea what helped but thanks again for all the inpu!

    Oscar.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Oscar

    Both boards (MDBT42Q and Adafruit touch sensor) have common ground.
    I use power from a USB power supply (5V) to feed the MDBT42Q, then I use the output of the voltage regulator at 3.3V from the MDBT42Q to feed the Adafruit touch sensor, so that the sensor outputs 3.3V logic.

    Voltage between Vcc and GND on the touch sensor is 3.3V (as expected).
    Voltage between OUT and GND on the touch sensor is 3.22V (just slightly lower).

    This OUT voltage gets sensed as HIGH on my other microcontroller boards using CircuitPython and 3.3V logic. However, then connecting OUT to pin D25 or pin D28, touching the sensor (thus 3.22V) and having said pins pulled down (L2 of snippet1), digitalRead(pin) returns 0. In the case of D28, I can also try an analogRead(D28) and it returns 0.97, which means that the pin "sees" the voltage.

    In summary:
    I have a "high" signal from the touch sensor being 3.22V.
    Said signal gets read by an analog pin as being 0.97 but... when I do a digital read I get zero.

    Is this expected?

    Answers to #9:
    -both boards have common ground;
    -voltage between OUT and GND when the sensor is not touched is obviously 0V;
    -push button replacing the cap sensor works, as the "out" pin of the push button when pushed outputs 3.3V (and not 3.2V); that is, the associated pin of the MDBT42Q board senses correctly HIGH and LOW; no external resistance is used, as the pin on the MDBT42Q is pulled down;
    -setInterval with digitalRead would have the same problem as setWatch, my problem is that I can't detect the "high" using digitalRead.

    Thanks again for all the replies!

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Oscar

    Yes, I tested the touch sensor with a multimeter. When touched, the voltage between OUT and GND is just slightly lower than between VCC and GND (all around 3.3, 3.2V). And that appears to be the problem!

    I've also tried the same wiring replacing the touch sensor with a regular mechanical push button and the initial code works.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Oscar

    Digital-only PIN or ADC pin - both tried as digital with no difference.
    Pin 28 also as analog input using analogRead(), but then setWatch does not seem to work.

    I guess I could avoid the problem entirely using setInterval instead of setWatch and figure an interval that would feel quick enough to catch all "touches". In that case I would use analogRead(D28) > 0.5 as "high" and my problems would go away.

    3.3V input test: I connect D28 to the 3.3V pin of the board or the input pin of the touch sensor (the sensor is fed by the 3.3V pin of the board).

  • in Puck.js, Pixl.js and MDBT42
    Avatar for Oscar

    Hi,

    I'm just getting starting with Espruino and I'm new to the setWatch function.

    I have a MDBT42Q board that I want to read a button input from a capacitive touch sensor momentary switch from Adafruit (https://www.adafruit.com/product/1374). The code is as follows:

    digitalRead(D28);
    pinMode(D28, "input_pulldown");
    
    setWatch(function() {
      digitalPulse(LED2, 1, 50);
      console.log("Pressed");
    }, D28, {repeat:true, debounce:50, edge:"rising"});
    

    If I connect briefly D28 to the 3.3V pin it works as expected.
    But if I connect it to the output of the momentary switch (and I touch the switch) it doesn't.

    I played with the pin D28 as an analog input and I have observed the following:
    D28 reads 0.99 when connected to the 3.3V pin.
    D28 reads 0.97 when connected to the output of the switch (and the switch is touched). This corresponds to around 3.22V.
    D28 reads close to zero when the switch is in open position (no touch).

    All results make sense and in analog mode I can read the sensor being touched.
    But it appears that the setWatch function interprets in digitalRead mode 0.99 as high but 0.97 as low, as if the threshold for a high would be beyond 0.97.

    Is this an expected behavior? Can this threshold be changed? I would have expected that anything beyond 1V would be detected as high.

    The end application is a bluetooth media controller with a play/pause touch sensor and a next touch sensor to be integrated in the handle of my rowing machine, so that I can control playback while rowing.

    Oscar.

Actions