The Raspberry Pi Thread [4]


  1. Posts : 15,010
    Windows 10 IoT
    Thread Starter
       #1681

    Dodged a bullet tonight. I misswired my LED shim, really surprised I didn't blow it up. Every time I ran my new code I got an IO error when I tried to light up the LED shim. Checked and double checked my wiring. Didn't see it? I had my +5V and ground plug on the i2c pins and the i2c plug on the +5v and ground pins on the LED Shim. I was feeding +5V into one of the i2c pins SDA I think? My Pico Hat hacker is soldered on wrong way around I think. Anyway, with the correct wires going to the correct pins it worked. Only thing that saved it I think is with it misswired, nothing was grounded. The ground wire wasn't connected to ground. Blind luck.
    Anyway here is the code I used.
    Code:
     if sensor.get_sensor_data(): 
           p = sensor.data.pressure 
           p = round(p)
                
        if p > 0 and p < 982: # Very Low
            pc = [255, w, w]  # Red
            msg = "- Barometer is Very Low @ %smb - Storm Watch" % (p)
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            ledshim.set_all(255, 0, 0) # Red
            M = ((982 - P) / 3) * 4
            M = round(M)
            M = M - 1
            # R R R R R R R R R R R R R R R R R R R R R R R R R R R R
        elif p >= 982 and p < 1004: # Low
            pc = [255, 255, w]  # Yellow
            msg = "- Barometer is Low @ %smb - Possible Percipitation" % (p)
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            ledshim.set_all(255, 255, 0) # Yellow
            M = ((1003 - p) / 3) * 4
            M = round(M)
            M = M - 1
            # Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
        elif p >= 1004 and p < 1026: # Mid Range
            pc = [w, 255, w]  # Green
            msg = "- Barometer is Mid Range @ %smb" % (p)
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            ledshim.set_all(0, 255, 0) #Green
            M = ((1026 - p) / 3) * 4
            M = round(M)
            M = M - 1
            # G G G G G G G G G G G G G G G G G G G G G G G G G G G G
        elif p >= 1026 and p < 1048: # High
            pc = [w, w, 255]  # Blue
            msg = "- Barometer is High @ %smb" % (p)
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            ledshim.set_all(0, 0, 255) #Blue
            M = ((1048 - p) / 3) * 4
            M = round(M)
            M = M - 1
            # B B B B B B B B B B B B B B B B B B B B B B B B B B B B
        elif p >= 1048: # Very High
            pc = [255, o, w]  # Orange
            msg = "- Barometer is Very High @ %smb - Expect Dry Conditions" % (p) 
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            ledshim.set_all(255, 140, 0) # Orange
            M = ((1069 - p) / 3) * 4
            M = round(M)
            M = M -1    
            # O O O O O O O O O O O O O O O O O O O O O O O O O O O O
        if M < 0:
            M = 0
        ledshim.set_pixel(M, 0, 0, 0)
        ledshim.show()
    I think its time to get
      My Computer


  2. Posts : 5,695
    insider build 10586.3 win10 pro 64
       #1682

    I think its time to get
    sound likes good idea
      My Computer


  3. Posts : 5,695
    insider build 10586.3 win10 pro 64
       #1683

    just putting my new led-shim into my piano/drum/ and speaker phat setup .there is an example for the led-shim to work with the drum.

    edit, didnt work not sure why ,just put out a error message when i hit the drum hat ,will try tomorrow with just the drumhat ,im trying it on the phatstack with the speakerphat and piano hat
    Last edited by caperjack; 04 Jan 2019 at 22:12.
      My Computer


  4. Posts : 15,010
    Windows 10 IoT
    Thread Starter
       #1684

    Check the i2c address of the LED shim and make sure its not the same as any other device on the stack. If it is you'll get errors and both devices with the same address won't work.

    Already have plans to change my code for my LED Shim. I'm just going to use the middle 22 LED's for the marker. There will be 3 at each end that don't indicate anything but thats not a big deal, not to me anyway. It will make the math easier. Think I'm going to change the colors of those end LED's too. To match the bands above and below the one its in. (Top) Blue - Blue - Blue - Green-(middle 22)-Green - Yellow - Yellow _Yellow. (Bottom).

    EDIT: already changed @ 5:15 AM lol. Couldn't sleep, was just going to wake my wife up and piss her off so I got up. Just going to go get another cup of coffee. I now have a couple of hours to kill before the sun comes up and I can go for my morning walk with the dog. I can't test my code until my wife gets up. My spare monitor etc is in the bedroom at the moment on my spare media hutch. I don't have any other place to put it at the moment.
    Last edited by alphanumeric; 05 Jan 2019 at 04:17.
      My Computer


  5. Posts : 15,010
    Windows 10 IoT
    Thread Starter
       #1685

    Jack, did you solder a header on your LED Shim? Its designed to be able to use it without one, but I'm not sure thats the best way to go. I've seen a few posts saying thats iffy at best. Kind of depends on how good the male header is your putting it over. How straight the pins are etc.
    I used headers on mine, but that was more so I could remote mount them away from the Pi. And orientate them vertically instead of horizontally.
      My Computer


  6. Posts : 5,695
    insider build 10586.3 win10 pro 64
       #1686

    nothing solder on to it yet,i did get it to work alone n a pizero, didnt work when i added it to the drum and piano ,setup will try later with just the drum hat

    alphanumeric said:
    Jack, did you solder a header on your LED Shim? Its designed to be able to use it without one, but I'm not sure thats the best way to go. I've seen a few posts saying thats iffy at best. Kind of depends on how good the male header is your putting it over. How straight the pins are etc.
    I used headers on mine, but that was more so I could remote mount them away from the Pi. And orientate them vertically instead of horizontally.
      My Computer


  7. Posts : 15,010
    Windows 10 IoT
    Thread Starter
       #1687

    You could try plugging a pHat in on top of it I guess? Or just a female header if you have a spare. Run sudo i2cdetect -y 1 and see if there is a 75 in the list. If its a io error its most likely just not getting a good connection.
      My Computer


  8. Posts : 5,695
    insider build 10586.3 win10 pro 64
       #1688

    will do. thanks
    alphanumeric said:
    You could try plugging a pHat in on top of it I guess? Or just a female header if you have a spare. Run sudo i2cdetect -y 1 and see if there is a 75 in the list. If its a io error its most likely just not getting a good connection.
      My Computer


  9. Posts : 15,010
    Windows 10 IoT
    Thread Starter
       #1689

    Something else that "might" work is to take something non conductive and press it between the rows of GPIO pins on top of the shim. A folded up piece of paper. Just enough to gently very slightly spread the pins away from each other.
    The LED Shim only uses 5 pins. +5V and Ground, the i2c pins right next to them and pin 20 ground.
      My Computer


  10. Posts : 15,010
    Windows 10 IoT
    Thread Starter
       #1690

    My new code glitched overnight. Looks like it happened when the pressure went into the very low range. If I power cycle it, it works right up until its going to light up the LED Shim.
    Something in here is not right?
    Code:
     if p > 0 and p < 982: # Very Low
            pc = [255, w, w]  # Red
            msg = "- Barometer is Very Low @ %smb - Storm Watch" % (p)
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            set_multiple_pixels(range(0,3), 255, 255, 0)  # Yellow
            set_multiple_pixels(range(3,28), 255, 0, 0)   # Red
            M = ((981 - P) + 3)
            ledshim.set_pixel(M, 0, 0, 0)
            ledshim.show()
            # Y Y Y R R R R R R R R R R R R R R R R R R R R R R R R R
    The sense hat shows its message and right after it says Strom Watch it goes dark. Somethings messed up after the sense.show_message line. I can't see it?
    The whole code goes like this.

    Code:
      if sensor.get_sensor_data(): 
           p = sensor.data.pressure 
           p = round(p)
                
        if p > 0 and p < 982: # Very Low
            pc = [255, w, w]  # Red
            msg = "- Barometer is Very Low @ %smb - Storm Watch" % (p)
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            set_multiple_pixels(range(0,3), 255, 255, 0)  # Yellow
            set_multiple_pixels(range(3,28), 255, 0, 0)   # Red
            M = ((981 - P) + 3)
            ledshim.set_pixel(M, 0, 0, 0)
            ledshim.show()
            # Y Y Y R R R R R R R R R R R R R R R R R R R R R R R R R
        elif p >= 982 and p < 1004: # Low
            pc = [255, 255, w]  # Yellow
            msg = "- Barometer is Low @ %smb - Possible Percipitation" % (p)
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            set_multiple_pixels(range(0,3), 0, 255, 0)    # Green
            set_multiple_pixels(range(3,25), 255, 255, 0) # Yellow
            set_multiple_pixels(range(25,28), 255, 0, 0)  # Red
            M = ((1003 - p) + 3)
            ledshim.set_pixel(M, 0, 0, 0)
            ledshim.show()
            # G G G Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y R R R
        elif p >= 1004 and p < 1026: # Mid Range
            pc = [w, 255, w]  # Green
            msg = "- Barometer is Mid Range @ %smb" % (p)
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            set_multiple_pixels(range(0,3), 0, 0, 255)     # Blue
            set_multiple_pixels(range(3,25), 0, 255, 0)    # Green
            set_multiple_pixels(range(25,28), 255, 255, 0) # Yellow
            M = ((1025 - p) +3)
            ledshim.set_pixel(M, 0, 0, 0)
            ledshim.show()
            # B B B G G G G G G G G G G G G G G G G G G G G G G Y Y Y
        elif p >= 1026 and p < 1048: # High
            pc = [w, w, 255]  # Blue
            msg = "- Barometer is High @ %smb" % (p)
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            set_multiple_pixels(range(0,3), 0, 0, 255)     # Blue
            set_multiple_pixels(range(3,25), 0, 255, 0)    # Green
            set_multiple_pixels(range(25,28), 255, 255, 0) # Yellow
            M = ((1047 - p) + 3)
            ledshim.set_pixel(M, 0, 0, 0)
            ledshim.show()
            # O O O B B B B B B B B B B B B B B B B B B B B B B G G G
        elif p >= 1048: # Very High
            pc = [255, o, w]  # Orange
            msg = "- Barometer is Very High @ %smb - Expect Dry Conditions" % (p) 
            sense.show_message(msg, scroll_speed=s, text_colour=pc)
            set_multiple_pixels(range(0,25), 255, 140, 0)  # Orange
            set_multiple_pixels(range(25,28), 0, 0, 255)   # Blue
            M = ((1069 - p) + 3)
            ledshim.set_pixel(M, 0, 0, 0)
            ledshim.show()
            # O O O O O O O O O O O O O O O O O O O O O O O O O B B B
    Mid Range and Low work OK, Very low doesn't. I'll have to hook it up to a monitor to see the actual error message to figure it out. Can't do that just yet. Looks like I really really need to move my stuff out of the bedroom. I just don't have any other place to put it. Time to clean up and redo my layout it seems.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 22:39.
Find Us




Windows 10 Forums