Error in the PyScan Pinout document



  • @gijs The pinout for the 10 pin connector below the development module is wrong. It is show in the upper right edge of the pinout page. The fault: The two rows are swapped. E.g. the square shaped pin is actually GND, and so on.



  • @robert-hh You are correct, Im not sure yet how they messed it up, but it seems to be a mirrorring issue. From what I see, the connector is labeled from the top view, but the square pad is definitely connected to GND, instead of PWR_EN

    I'll make sure it gets fixed, thanks!



  • @gael-cobert I cannot tell anything about the Pycom IDE with either Atom or VSCode. The seem to fail constantly.
    I prefer to use primitive tools, like picocom | putty | beagle term for REPL, and plain ftp | filezilla or in the absence of wifi pyboard.py + mpr.py for file transfer.



  • @robert-hh yes do you know why it's so long ? ( around 3 sec )

    i have another question, i am using atom IDE, i want to use the NFC scan, but sometimes it stop, if i click "run selected files"
    if i transfer main.py file via FTP it don't seem to execute when the board start, it's a little bit strange

    import epaper4in2
    from machine import Pin, SPI
    
    # NFC
    
    from pyscan import Pyscan
    from MFRC630 import MFRC630
    from LIS2HH12 import LIS2HH12
    from LTR329ALS01 import LTR329ALS01
    import binascii
    import time
    import pycom
    import _thread
    
    ttf_dir = 'ttf' 
    # var NFC
    # This is the default key for an unencrypted MiFare card
    DEBUG = True  # change to True to see debug messages
    
    
    VALID_CARDS = [[0x43, 0x95, 0xDD, 0xF8],
                   [0x43, 0x95, 0xDD, 0xF9],
                   [0x8C, 0x43, 0x00, 0x5C],
                   [0x46, 0x5A, 0xEB, 0x7D, 0x8A, 0x08, 0x04]]
    
     
    py = Pyscan()
    nfc = MFRC630(py)
    lt = LTR329ALS01(py)
    li = LIS2HH12(py)
    
    RGB_BRIGHTNESS = 0x8
    
    RGB_RED = (RGB_BRIGHTNESS << 16)
    RGB_GREEN = (RGB_BRIGHTNESS << 8)
    RGB_BLUE = (RGB_BRIGHTNESS)
    
    counter = 0
    
    # SPIV on ESP32
    sck = "P9"
    miso = None
    mosi = "P10"
    dc = Pin("P3", Pin.OUT)
    cs = Pin("P19", Pin.OUT)
    rst = Pin("P11", Pin.OUT, value=1)
    busy = Pin("P15", Pin.IN)
    spi = SPI(0, baudrate=20000000, polarity=0, phase=0, pins=(sck, mosi, None))
    
    e = epaper4in2.EPD(spi, cs, dc, rst, busy)
    e.init()
    
    w = 400
    h = 300
    x = 0
    y = 0
    
    # --------------------
    
    # use a frame buffer
    # 400 * 300 / 8 = 15000 - thats a lot of pixels
    import framebuf
    buf = bytearray(w * h // 8)
    fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
    black = 0
    white = 1
    fb.fill(white)
    print('print hello world')
    fb.fill(white)
    fb.text('bienvenue sur le système secureangel',30,0,black)
    e.display_frame(buf)
    
    
    
    
    
    
    # Make sure heartbeat is disabled before setting RGB LED
    pycom.heartbeat(False)
    
    # Initialise the MFRC630 with some settings
    nfc.mfrc630_cmd_init()
    
    
    def check_uid(uid, len):
        return VALID_CARDS.count(uid[:len])
    
    def print_debug(msg):
        if DEBUG:
            print(msg)
    
    def send_sensor_data(name, timeout):
        while(True):
            print(lt.light())
            print(li.acceleration())
            time.sleep(timeout)
    
    def discovery_loop(nfc, id):
        while True:
            # Send REQA for ISO14443A card type
            print_debug('Sending REQA for ISO14443A card type...')
            atqa = nfc.mfrc630_iso14443a_WUPA_REQA(nfc.MFRC630_ISO14443_CMD_REQA)
            print_debug('Response: {}'.format(atqa))
            if (atqa != 0):
                # A card has been detected, read UID
                print_debug('A card has been detected, read UID...')
                uid = bytearray(10)
                uid_len = nfc.mfrc630_iso14443a_select(uid)
                print_debug('UID has length: {}'.format(uid_len))
                if (uid_len > 0):
                    s =  binascii.hexlify(uid[:uid_len],' ').upper()
                    card_id = ("{:02X}"*len(s)).format(*s)
                    print_debug('card_id : -> {} <-'.format(card_id))
                    tst = s.decode("utf-8") 
                    print_debug('tst : {} <-'.format(tst))
    
                     
                    if(tst == "8C 43 00 5C") :
                        print_debug('hello gael')
                        fb.fill(white)
                        fb.text('Hello Gaël ! :)',30,80,black)
                        e.display_frame(buf)
                    
                    print_debug('Checking if card with UID: [{:s}] is listed in VALID_CARDS...'.format(binascii.hexlify(uid[:uid_len],' ').upper()))
                    if (check_uid(list(uid), uid_len)) > 0:
                        print_debug('Card is listed, turn LED green')
                        pycom.rgbled(RGB_GREEN)
                    else:
                        print_debug('Card is not listed, turn LED red')
                        pycom.rgbled(RGB_RED)
                        fb.fill(white)
                        fb.text('carte introuvable :p',30,0,black)
                        e.display_frame(buf)
                        
            else:
                # No card detected
                #print_debug('Did not detect any card...')
                pycom.rgbled(RGB_BLUE)
            nfc.mfrc630_cmd_reset()
            time.sleep(.5)
            nfc.mfrc630_cmd_init()
    
    # This is the start of our main execution... start the thread
    _thread.start_new_thread(discovery_loop, (nfc, 0))
    _thread.start_new_thread(send_sensor_data, ('Thread 2', 10))
    


  • @gael-cobert Wonderful. Although the display update times are pretty long. So it's more suited for signs.



  • @robert-hh said in Error in the PyScan Pinout document:

    import epaper4in2
    from machine import Pin, SPI

    SPIV on ESP32

    sck = "P9"
    miso = None
    mosi = "P10"
    dc = Pin("P3", Pin.OUT)
    cs = Pin("P19", Pin.OUT)
    rst = Pin("P11", Pin.OUT, value=1)
    busy = Pin("P15", Pin.IN)
    spi = SPI(0, baudrate=20000000, polarity=0, phase=0, pins=(sck, mosi, None))

    e = epaper4in2.EPD(spi, cs, dc, rst, busy)
    e.init()

    w = 400
    h = 300
    x = 0
    y = 0

    --------------------

    use a frame buffer

    400 * 300 / 8 = 15000 - thats a lot of pixels

    import framebuf
    buf = bytearray(w * h // 8)
    fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
    black = 0
    white = 1
    fb.fill(white)
    print('print hello world')
    fb.fill(white)
    fb.text('Hello World',30,0,black)
    e.display_frame(buf)

    it works !!!!!!!!



  • @robert-hh P11 is to the left of P13 ?

    https://drive.google.com/file/d/12uRecBvZEub8N-LTEvIxTz0T2M0FdGH_/view?usp=sharing

    can you give me a photo of your board ?



  • @gael-cobert Yes. I used Pyscan for that. The same 0.7 version that you have. with long male/male adapter pins.
    If that does not work, the problem may be somewhere else.



  • @robert-hh said in Error in the PyScan Pinout document:

    sck = "P9"
    miso = None
    mosi = "P10"
    dc = Pin("P3", Pin.OUT)
    cs = Pin("P19", Pin.OUT)
    rst = Pin("P11", Pin.OUT, value=1)
    busy = Pin("P15", Pin.IN)
    spi = SPI(0, baudrate=20000000, polarity=0, phase=0, pins=(sck, mosi, None))

    did you try it with a piscan ? i changed my code with your example but not change ... i changed P8 to P11
    I changed other pin

    https://drive.google.com/file/d/12dhAIFz4ND_cvRy4eSzi3o79BKnx_9EB/view?usp=sharing



  • @gael-cobert Could not give it a rest, so I made a shot. This setting worked, all on the camera connector:

    import epaper4in2
    from machine import Pin, SPI
    
    # SPIV on ESP32
    sck = "P9"
    miso = None
    mosi = "P10"
    dc = Pin("P3", Pin.OUT)
    cs = Pin("P19", Pin.OUT)
    rst = Pin("P11", Pin.OUT, value=1)
    busy = Pin("P15", Pin.IN)
    spi = SPI(0, baudrate=20000000, polarity=0, phase=0, pins=(sck, mosi, None))
    
    e = epaper4in2.EPD(spi, cs, dc, rst, busy)
    e.init()
    
    w = 400
    h = 300
    x = 0
    y = 0
    
    # --------------------
    
    # use a frame buffer
    # 400 * 300 / 8 = 15000 - thats a lot of pixels
    import framebuf
    buf = bytearray(w * h // 8)
    fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
    black = 0
    white = 1
    fb.fill(white)
    print('print hello world')
    fb.fill(white)
    fb.text('Hello World',30,0,black)
    e.display_frame(buf)
    

    The only problem that I had was the USB of the pyscan. I never used it before, and so the driver needed am update. I skipped that and connected with telnet.



  • @robert-hh ok thank you so much for your help :) i learned a lot of things indeed. See you tomorrow.



  • @gael-cobert Just give it a break. The connector where you have P11 now, is labeled as camera connector. As long as the camera is not used, all pins should be available. So let's focus on that, but not today. I will try to use the pyscan for that test tomorrow. At the moment, I use a simple expansion board.



  • @robert-hh no it don't works :p
    i don't know what to do ...



  • @gael-cobert Did it work? I'm not sure about using pins on the pyscan. Most of them have multiple labels, and when they are driven by the pyscan itself, they may not be usable.

    Your small test script works here.



  • @robert-hh said in Error in the PyScan Pinout document:

    CS

    i put CS in P11

    https://drive.google.com/file/d/12chEnjlWTnu94V6AZnhyeMdt583pmbWF/view?usp=sharing

    and changed the code

    import epaper4in2
    from machine import Pin, SPI
    
    # SPIV on ESP32
    rst = Pin('P8')
    dc = Pin('P10')
    busy = Pin('P15')
    cs = Pin('P11')
    clk = Pin('P9')
    mosi = Pin('P19')
    
    spi = SPI(0, mode=SPI.MASTER, baudrate=2000000, polarity=0, phase=0, pins=(clk, mosi, None))
    
    e = epaper4in2.EPD(spi,cs , dc, rst, busy)
    e.init()
    
    w = 400
    h = 300
    x = 0
    y = 0
    
    import framebuf
    buf = bytearray(w * h // 8)
    fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
    black = 0
    white = 1
    fb.fill(white)
    
    print('print hello world')
    fb.fill(white)
    fb.text('Hello World',30,0,black)
    e.display_frame(buf)
    
    


  • @gael-cobert I made a test with the static CS, and it did NOT work. So you have to connect cs. That's a little bit surprising, but .. You could try to use that P11 pin on the connector, or solder in another row of pins to get access to p4 and p10.



  • @robert-hh

    yes

    """
    	Example for 4.2 inch black & white Waveshare E-ink screen
    	Run on ESP32
    """
    
    import epaper4in2
    from machine import Pin, SPI
    
    # SPIV on ESP32
     
    
    rst = Pin('P8')
    dc = Pin('P10')
    busy = Pin('P15')
    cs = Pin('P4')
    clk = Pin('P9')
    mosi = Pin('P19')
    
    
    spi = SPI(0, mode=SPI.MASTER, baudrate=2000000, polarity=0, phase=0, pins=(clk, mosi, None))
    
    e = epaper4in2.EPD(spi,cs , dc, rst, busy)
    e.init()
    
    w = 400
    h = 300
    x = 0
    y = 0
    
    # --------------------
    
    # use a frame buffer
    # 400 * 300 / 8 = 15000 - thats a lot of pixels
    import framebuf
    buf = bytearray(w * h // 8)
    fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
    black = 0
    white = 1
    fb.fill(white)
    
    print('print hello world')
    fb.fill(white)
    fb.text('Hello World',30,0,black)
    #fb.pixel(30, 10, black)
    #fb.hline(30, 30, 10, black)
    #fb.vline(30, 50, 10, black)
    #fb.line(30, 70, 40, 80, black)
    #fb.rect(30, 90, 10, 10, black)
    #fb.fill_rect(30, 110, 10, 10, black)
    #for row in range(0,36):
    #	fb.text(str(row),0,row*8,black)
    #fb.text('Line 36',0,288,black)
    e.display_frame(buf)
    
    
    # --------------------
    
    


  • @gael-cobert Yes. That is P8. Did you change your script accordingly?



  • @robert-hh
    no change, photo of the white cable to pin P8
    is it right ?
    https://drive.google.com/file/d/12bptWVKfvO_Y1f_0ghyce_tIOygcBiVy/view?usp=sharing

    i changed the code too

    @robert-hh

    yes

    """
    	Example for 4.2 inch black & white Waveshare E-ink screen
    	Run on ESP32
    """
    
    import epaper4in2
    from machine import Pin, SPI
    
    # SPIV on ESP32
     
    
    rst = Pin('P8')
    dc = Pin('P10')
    busy = Pin('P15')
    cs = Pin('P4')
    clk = Pin('P9')
    mosi = Pin('P19')
    
    
    spi = SPI(0, mode=SPI.MASTER, baudrate=2000000, polarity=0, phase=0, pins=(clk, mosi, None))
    
    e = epaper4in2.EPD(spi,cs , dc, rst, busy)
    e.init()
    
    w = 400
    h = 300
    x = 0
    y = 0
    
    # --------------------
    
    # use a frame buffer
    # 400 * 300 / 8 = 15000 - thats a lot of pixels
    import framebuf
    buf = bytearray(w * h // 8)
    fb = framebuf.FrameBuffer(buf, w, h, framebuf.MONO_HLSB)
    black = 0
    white = 1
    fb.fill(white)
    
    print('print hello world')
    fb.fill(white)
    fb.text('Hello World',30,0,black)
    #fb.pixel(30, 10, black)
    #fb.hline(30, 30, 10, black)
    #fb.vline(30, 50, 10, black)
    #fb.line(30, 70, 40, 80, black)
    #fb.rect(30, 90, 10, 10, black)
    #fb.fill_rect(30, 110, 10, 10, black)
    #for row in range(0,36):
    #	fb.text(str(row),0,row*8,black)
    #fb.text('Line 36',0,288,black)
    e.display_frame(buf)
    
    
    # --------------------
    
    


  • @gael-cobert Using my Multimeter I see that the white cable is actually at P11. The pinout drawing is wrong. The next pin to the left is P8. So use that one for the moment. P8 an dP4 are used for the SD card, but as long as you do not use it, it's OK.
    By chance I had a Waveshare 4in2 epaper display here, and it works with the sample code.


Log in to reply
 

Pycom on Twitter