Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. falbriard
    F
    • Continue chat with falbriard
    • Start new chat with falbriard
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    falbriard

    @falbriard

    3
    Reputation
    25
    Posts
    1120
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    falbriard Follow

    Posts made by falbriard

    • RE: RFID2 Unit and Core2 Processor

      @falbriard An attempt to write a logic with Blockly & MicroPython code (via UIFlow), able to store up to 1000 characters on a RFID tag:

      # by Claude Falbriard - QcLab Brazil
      # RFID tag with RC522 layout    
      from m5stack import *
      from m5stack_ui import *
      from uiflow import *
      import time
      import unit
              
      screen = M5Screen()
      screen.clean_screen()
      screen.set_screen_bg_color(0x000000)
      rfid_0 = unit.get(unit.RFID, unit.PORTA)
          
      inputsrt2 = None
      elecounter = None
      alldata = None
      inputstr1 = None
      inputdata = None
      inputstr4 = None
      cardready = None
         
      
      label0 = M5Label('RFID Reader', x=10, y=10, color=0xf5f2f2, font=FONT_MONT_14, 
      parent=None)
      text_2 = M5Label('text_2', x=10, y=113, color=0xb1ed94, font=FONT_MONT_14, 
      parent=None)
      text_4 = M5Label('text_4', x=10, y=138, color=0xccf1a6, font=FONT_MONT_14, 
      parent=None)
      debug1 = M5Label('Debug: ', x=10, y=226, color=0xf09a9a, font=FONT_MONT_14, 
      parent=None)
      alldata_label = M5Label('alldata', x=10, y=170, color=0xdff2d7, font=FONT_MONT_14, 
      parent=None)
      inputd1 = M5Label('input data', x=10, y=48, color=0xe8f081, font=FONT_MONT_14, 
      parent=None)
      text_1 = M5Label('text_1', x=10, y=88, color=0xcbeeb9, font=FONT_MONT_14, 
      parent=None)
         
      
      elecounter = 0
      # constructing an RFID RC522 compliant data writer
      # https://www.blindtextgenerator.com/lorem-ipsum
      # generate a string with max length of 1000 characters
      ipsumstr = """Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo 
      ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient 
      montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium 
      quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, 
      vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam 
      dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum 
      semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat 
      vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. 
      Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam 
      ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. 
      Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet 
      adipiscing sem neque sed ipsum. N"""
      # chop test data string to 256 bytes
      ipsumstr = ipsumstr[:256]
      
      # split a text into 16 bytes elements, max size = 1000
      def split_by_n(seq, n):
          '''A generator to divide a sequence into chunks of n units.'''
          while seq:
              yield seq[:n]
              seq = seq[n:]
      
      rc522list = list(split_by_n(ipsumstr, 16))
      blkcount = len(rc522list)
      # process list by RC522 element max 1000 char
      validptr = [1,2,4,5,6,8,9,10,12,13,14,16,17,18,20,21,22,24,25,26,28,29,30,\
                  32,33,34,36,37,38,40,41,42,44,45,46,48,49,50,52,53,54,56,57,58,\
                  60,61,62,64,65,66,68,69,70,72,73,74,76,77,78,80,81,82,84,85,86]
      keyptr =  [3,7,11,15,19,23,27,31,35,39,43,47,51,55,59,63,67,71,75,79,83]
      
      while True:
        alldata = ''
        inputstr1 = ''
        inputsrt2 = ''
        inputdata = ''
        inputstr4 = ''
        cardready = False
        wait(1)
        debug1.set_text('start reading ...')
        if rfid_0.isCardOn():
          debug1.set_text('card found')
          inputdata = rfid_0.readUid()
          speaker.playTone(740, 1/2)
        inputd1.set_text(str(inputdata))
        elecounter = 0
        for ele in rc522list:
           blkdata = ele
           blkaddr = validptr[elecounter]
           rfid_0.writeBlock(blkaddr,blkdata)
           elecounter += 1
        wait_ms(400)
        # read data only for debug   
        inputstr1 = rfid_0.readBlockStr(1)
        inputsrt2 = rfid_0.readBlockStr(2)
        inputstr4 = rfid_0.readBlockStr(4)
        # all data stored on tag 
        for blkcount in range (0,elecounter):
            blkaddr = validptr[blkcount]
            record = rfid_0.readBlockStr(blkaddr)
            alldata += record
        if inputdata == '1e1cb67cc8':
          power.setVibrationIntensity(80)
          power.setVibrationEnable(True)
          wait(0.5)
          power.setVibrationEnable(False)
        # show data for debug and validation   
        text_1.set_text(str(inputstr1))
        text_2.set_text(str(inputsrt2))
        text_4.set_text(str(inputstr4))
        alldata_label.set_text(str(alldata))
        wait(2)
      posted in Units
      F
      falbriard
    • RE: RFID2 Unit and Core2 Processor

      Using the UIflow code, I wrote data into the RFID addr 1, 2 and 4. Checking the result with Android "NFC Tools", function "Read Hex Memory" I see all the data written into the corresponding sectors in a hex format.

      "addr 1" is "sector 0, Block 1"
      "addr 2" is "sector 0, Block 2"
      "addr 4" is "sector 1, Block 0"
      ...

      My guess is that the following write sequence will preserve the formatted key addresses
      and make good use of the available Mifare tag memory space, organized in 16 bytes blocks.
      The resulting addressing table for writing data is:

      Data addr: 1,2,4,5,6,8,9,10,12,13,14,16,17,18,20,21,22 .. etc
      reserved
      UID addr: 0
      Key addr: 3,7,11,15,19,23 .. etc

      0_1665581580009_write_into_block_4_small.png

      posted in Units
      F
      falbriard
    • RE: RFID2 Unit and Core2 Processor

      @falbriard 0_1665413893147_rfid-mirafecard_layout.png Might be useful to illustrate the topic, attached you find the RC522 Mifare tag memory layout.

      posted in Units
      F
      falbriard
    • RFID2 Unit and Core2 Processor

      I've bought an RFID2 reader/writer unit which I connected to the M5 CORE2 processor.

      Using the web based UIFlow, I do not see a specific unit type RFID2 to add to the unit list. For this reason I've added the default RFID and the basic functions are OK and support functions like "card near", tag ID, read and write from address x, like 1. With few UIflow commands and a logic loop I was able to build a basic RFID Tag reader & writer and also to get the UID information.

      Please clarify in some more depth the use of read from "addr" and write to “addr”.

      My guess is that "addr" means sector number, where we find 16 sectors each constructed with 4 blocks, as shown in the memory reader of the "Android NFC Tools – function Memory Hex". There are 3 blocks of data, each 16 characters long, followed by one block of keys.
      Sector 0 is used for UID.

      Sector 0 → UID
      Sector 1 → Data1
      Sector 2 → Data2
      Sector 3 → Key
      Sector 4 → Data3, etc

      My doubt: By writing into "addr" 3, does it overwrite the key in sector 3, or does it write into sector 4 data field, by this preserving the key address? Overwriting a key field possibly would destroy the default RFID tag format. Hope there is code example available for this topic. Below see a hardcopy of my code: 0_1665152588676_rfid_code_sample1.png

      posted in Units
      F
      falbriard
    • RE: Core 2 unit with M5Go2, Serial Port C and external Elechouse RFID V 1.2

      @felmue You are right, it seems to be a voltage mismatch. The UART requests 5V, but ESP32 delivers only 3.3V.
      Reading: "On-board level shifter, Standard 5V TTL for I2C and UART, 3.3V TTL SPI"
      Find more: https://manuals.plus/elechouse/pn532-nfc-rfid-module-manual#introduction
      Time to buy a M5stack reader unit and use the standard UiFlow drivers. Thanks!

      posted in Modules
      F
      falbriard
    • Core 2 unit with M5Go2, Serial Port C and external Elechouse RFID V 1.2

      On a Core 2 unit with M5Go2 bottom, I need to connect an external RFID board (Elechouse) but its not working yet, just getting a "None" or b'x\00' data return.

      The connection is UART based using Port C (Blue), Pins TXD2 14, RXD2 13 : Supports UART with 115200 data rate configured to UART2). In order to test the Core2 side I did loop configuration sending RX to TX with a jumper wire and I worte a string "Testing_Serial" by an UART write command. This worked fine. When connecting the external board I get back a string with b'x\00'. The wires to the external device are crossed TX->RX, RX<-TX and the two power wires. Not sure, if there is a command sequence required to activate the data transmission and RFID data readout at the device. The board is reading tags and is blinking. Any insight are welcome.

      posted in Modules
      F
      falbriard
    • RE: Issue with Analog Voltage Measurement on Core2

      @felmue Now got some useful readings of Volts using the following code. Not sure about accuracy due to logarithmic scale. I've tested it with an AA 1,5 battery as input signal, connecting GND and ADC pin 32. As I already use a GPS and an expansion board, so at the moment SDA pin 32 at Core2 unit is the only available choice. My code:

      execute:
      from machine import ADC
      adc=ADC(32)
      adc.atten(ADC.ATTN_11DB)
      while true (with blockly), execute:
      signal = int(adc.read())
      if signal == 4095:
      signal = 0
      percentage = float(signal / 4095 / 100)
      volts = float(3.9 * percentage * 100)
      label2 show volts (with blockly)

      Now getting 0 at idle connection and +- 1.5 V when testing it with an AA battery as analog signal.

      posted in Core 2
      F
      falbriard
    • Issue with Analog Voltage Measurement on Core2

      Under UIflow, I execute the following code on a Core2 device, signal from Port A, pin 32,
      using a Micro-Python execution block:

      from machine import ADC
      adc=ADC(32)
      signal = int(adc.read())

      label1 show signal

      The value obtained is always 4095, even if no voltage is present at the input pin 32.

      Please give me some explanations how to connect and measure an analog signal (V) using the
      M5stack core2 device.

      Regards, Claude

      posted in Core 2
      F
      falbriard
    • RE: uiflow running, but cannot connect to using the api key

      Same situation here with a Core2 device (Location: Brazil, GMT-3, at 14:50, 02/02/2022). Thanks for checking.

      posted in Bug Report
      F
      falbriard
    • RE: Is the https://flow.m5stack.com/ running?

      The UIFlow web site is still down (location Brazil, GMT-3, 02/02/2022 at 10:15). Thanks for checking.

      posted in Bug Report
      F
      falbriard