# New install Piano Hat not working

**URL:** <https://forums.pimoroni.com/t/new-install-piano-hat-not-working/3513>\
**Category:** Support\
**Created:** [December 7, 2016, 2:30am UTC](https://forums.pimoroni.com/t/new-install-piano-hat-not-working/3513 "2016-12-07T02:30:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anitatech](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@anitatech](https://forums.pimoroni.com/u/anitatech)\
**Post date:** [December 7, 2016, 2:30am UTC](https://forums.pimoroni.com/t/new-install-piano-hat-not-working/3513/1 "2016-12-07T02:30:29Z")

</div>

Installed Piano Hat on RPi3 per website [https://learn.pimoroni.com/tutorial/piano-hat/getting-started-with-piano-hat](https://learn.pimoroni.com/tutorial/piano-hat/getting-started-with-piano-hat) and rebooted. Basic example program (listed below) throws errors:

Traceback (most recent call last):  
File “/home/pi/Documents/piano\_test.py”, line 1, in   
import pianohat  
File “/usr/lib/python3/dist-packages/pianohat.py”, line 175, in   
\_piano\_ctog = cap1xxx.Cap1188(i2c\_addr=0x28, alert\_pin=4)  
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 282, in **init**  
self.product\_id = self.\_get\_product\_id()  
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 468, in \_get\_product\_id  
return self.\_read\_byte(R\_PRODUCT\_ID)  
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 493, in \_read\_byte  
return self.i2c.read\_byte\_data(self.i2c\_addr, register)  
OSError: [Errno 5] Input/output error

import pianohat  
import time  
def handle\_note(channel, pressed):  
if pressed:  
print (“You pressed key {}”.format(channel))  
else:  
print (“You released key {}”.format(channel))

pianohat.on\_note(handle\_note)

while True:  
time.sleep(0.001)

I’m a teacher with 25 eager Python students. Please help!

---

<div class="post-metadata">

**Author:** ![gadgetoid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/gadgetoid/32/13_2.png) [@gadgetoid](https://forums.pimoroni.com/u/gadgetoid)\
**Post date:** [December 7, 2016, 10:19am UTC](https://forums.pimoroni.com/t/new-install-piano-hat-not-working/3513/2 "2016-12-07T10:19:03Z")

</div>

Looks like a problem talking to the HAT from the Pi.

Is the Piano HAT located properly on the Pi’s GPIO pins? Are you using any sort of ribbon cable extension setup?

What do you see if you run: `i2cdetect -y 1` in terminal?

---

<div class="post-metadata">

**Author:** ![anitatech](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@anitatech](https://forums.pimoroni.com/u/anitatech)\
**Post date:** [December 7, 2016, 9:28pm UTC](https://forums.pimoroni.com/t/new-install-piano-hat-not-working/3513/3 "2016-12-07T21:28:10Z")

</div>

PianoHat seated properly. i2cdetect gives 28 and 2b.  
Would love to get this working!! will be at PiCademy Austin next two days  
and would like to share success with other attendees!

---

<div class="post-metadata">

**Author:** ![gadgetoid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/gadgetoid/32/13_2.png) [@gadgetoid](https://forums.pimoroni.com/u/gadgetoid)\
**Post date:** [December 7, 2016, 9:52pm UTC](https://forums.pimoroni.com/t/new-install-piano-hat-not-working/3513/4 "2016-12-07T21:52:31Z")

</div>

Well that’s all sane, very odd that i2cdetect would show a result but it would fail at the first attempt to talk to the devices!

Try:

```bash
i2cget -y 1 0x28 0xfd

```

and

```bash
i2cget -y 1 0x2b 0xfd

```

This is basically asking to grab the Product ID (register 0xfd) from each devices (the first hex number being the address).

A register, in loose terms, is a slot where a single 8bit (0-255) number can be stored/retrieved. All communication with Piano HAT is done by reading and writing numbers to these slots.

---

<div class="post-metadata">

**Author:** ![anitatech](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@anitatech](https://forums.pimoroni.com/u/anitatech)\
**Post date:** [December 7, 2016, 10:31pm UTC](https://forums.pimoroni.com/t/new-install-piano-hat-not-working/3513/5 "2016-12-07T22:31:43Z")

</div>

So for some reason, the example code is working now. Am happy but puzzled

- wonder if the hat or Pi connector is flaky (gave it a snug before running  
code)…These Pis are used in classes with 6th graders and take some  
abuse…will let you know if problem recurs. Thanks a ton for the _very_  
prompt help!!!

---

<div class="post-metadata">

**Author:** ![gadgetoid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/gadgetoid/32/13_2.png) [@gadgetoid](https://forums.pimoroni.com/u/gadgetoid)\
**Post date:** [December 7, 2016, 10:33pm UTC](https://forums.pimoroni.com/t/new-install-piano-hat-not-working/3513/6 "2016-12-07T22:33:26Z")

</div>

I had exactly the same error as you with a different product not 5 minutes after I replied. Turned out I’d been handling it too gingerly and hadn’t pushed the pHAT all the way onto my Pi :D D’oh.

Glad it’s up and running!

---

<div class="post-metadata">

**Author:** ![OldCodger](https://avatars.discourse-cdn.com/v4/letter/o/45deac/32.png) [@OldCodger](https://forums.pimoroni.com/u/OldCodger)\
**Post date:** [December 30, 2017, 6:17pm UTC](https://forums.pimoroni.com/t/new-install-piano-hat-not-working/3513/7 "2017-12-30T18:17:15Z")

</div>

Hi,

I cannot get the basic piano hat download to work.  
I copied the the line:  
curl [https://get.pimoroni.com/pianohat](https://get.pimoroni.com/pianohat) | bash  
From the website to avoid typos, ifails saying it cannot connect to the internet. If I put:  
[https://get.pimoroni.com/pianohat](https://get.pimoroni.com/pianohat)  
Into the web browser on the same Pi it downloads the script !!  
I have tried updating curl, I tried adding sudo to the beginning of the command but that didn’t work. When I tried putting sudo in front of the bash if failed saying “Running as root. Please login as a regular user with sudo rights”  
I tried the ic2commands mention here and I got the same numbers as Anitatech.

Any ideas what I’m doing wrong ?

Regards Dave

---

<div class="post-metadata">

**Author:** ![gadgetoid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/gadgetoid/32/13_2.png) [@gadgetoid](https://forums.pimoroni.com/u/gadgetoid)\
**Post date:** [January 2, 2018, 1:32pm UTC](https://forums.pimoroni.com/t/new-install-piano-hat-not-working/3513/8 "2018-01-02T13:32:57Z")

</div>

See my answer over on: [Piano Hat script not downloading using curl](https://forums.pimoroni.com/t/piano-hat-script-not-downloading-using-curl/6769/2)
