• First the hardware: Your connectivity is just fine with any Espruino board: Espruino talks and listens 3.3V and so does the Finger Print reader. Just make sure you connect the Finger Print Reader Ground to Espruino Ground and then the Finger Print reader power to 3.3 Volt or 5 Volt. I assume you run your Espruino for the beginning on USB as connected to the Espruino Web IDE on your computer.

    Now that we have done the hardware, we look at the initialization of the serial on Espruino. There is not much to say other than selecting the pins, the baud rate - which is 9600 (default of the finger print reader), and the format. I assume the format is just plain 8 bit with 1 stop and 1 start bit and no parity bit.

    To write to the device it is simple:

    mySerial.print(...);
    

    To read from the device, it is a bit more tricky - or better said - elaborate, and for sure different as you may have learned from other environments, such as Arduino. Let me fill you in with a bit background about Espruino.

    A major goal of Espruino's creator - @Gordon Williams - was: tiny, power frugal, easy to use / program micro controller setup.

    The easy part for programming is for one part JavaScript and for the other - painful - part, handle all the low level hardware stuff under the hood so that you have to act only when something happened that needs your attention - *** without you constantly checking, also called polling - in a program loop (as in Arduino) - every possible thing for which something may have happen ***. In Espruino, everything is Event Driven including your application. So you will never find a command like wait() or delay() or alike. In your case, when the finger print reader sends you - your application code - data, Espruino does it's magic and notifies you - your application code - with the data it received. In order that Espruino can notify - call - you, you have to 'leave your callback number' when you 'install' the communication. And this goes with a piece of code like this:

    mySerial.on("data", function(data) { console.log(data); });
    

    This tells the serial appliance built into Espruino, that on data reception it should call your function with the received data as parameter value. The (anonymous) function in above example prints the data in the console.

    That is all there is!

    ...no kidding... or just a little bit.

    Being very familiar with JavaScript, you will say "Sure, I can take it from here". Not so familiar, you may ask about some more details... Take a look at Espruino USART.

    But before going into more programming, lets play a bit and see some action. Reading through AD-TECH GT-511C3 datasheet V2.1, we can quickly see wether the connectivity is up.

    • (1) Connect your Espruino and Finger Print reader. Pick Espruino's Serial1 for now. Which pins these are, check in the espruino.com/Reference and board. For Pico: B6(TX) and B7(RX), Ground goes to Ground and Power goes to 3.3V or Bat (Bat is the USB 5V through a diode and is located between Ground and 3.3V pin on the 0.1" pins next to the USB tab).

    • (2) Connect Espruino with USB cable to your computer you run the Web IDE in Chrome (which you already have started).

    • (3) Connect to Espruino (top left yellow/orange button (Espruino board shows in drop down... pick any when more than one shows).

    • (4) In left-hand pane - the console - you enter Serial1.setup(9600, { tx:B6, rx:B7}); This initializes Espruino's serial appliance on port B6 and B7 with speed of 9600 baud.

    • (5) Then you enter Serial1.on("data", function(data) { console.log(data); });

    • (6) Now we send the command to turn the Finger Print reader LED on and we should get back an ACK, which shows as a '0' in Hex: 30 (0x30) in the console. For entering use copy paste from here:

    • (6.1) Open:

      
      - (6.2) LED on:
      

      Serial1.write([0x55,0xAA,0x01,0x00,0x01,­0x00,0x00,0x00,0x12,0x00,0x13,0x01]);```­

    • (6.3) LED off

      
      - (6.4) Close:
      

      Serial1.write([0x55,0xAA,0x01,0x00,0x00,­0x00,0x00,0x00,0x02,0x00,0x02,0x01]);```­

    For every command sent you get something back: some crazy characters but also a "U" - (0x55) and "0" (0x30).

    So much for now.

About

Avatar for allObjects @allObjects started