Raspberry Pi ATTiny85 I2C Interfacing

Discussion about other hardware (including other Pi-like boards)
User avatar
bouke
Posts: 18
Joined: Sun Jun 18, 2017 8:28 am
Location: Enschede, The Netherlands
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: Raspberry Pi ATTiny85 I2C Interfacing

Post by bouke » Fri Jul 14, 2017 8:48 am

kite wrote:
Fri Jul 14, 2017 8:34 am
In order to do all this you will probably have to enable use of the 'reset' pin, which does make programming it more difficult but hey an extra pin :)
I was just thinking about using the reset pin indeed... In my case I could supply the switch with 5v on one side and 3.3v on the other side, wiring the middle pin to the 'reset' pin. This way I have one pin free for the MOSFET and still one for measuring the voltage of the LiPo.
Currently figuring out how to build my first Game Boy Zero. 8-)

User avatar
moosepr
Posts: 435
Joined: Wed Jan 25, 2017 6:18 am
Has thanked: 50 times
Been thanked: 175 times
Contact:

Re: Raspberry Pi ATTiny85 I2C Interfacing

Post by moosepr » Fri Jul 14, 2017 9:12 am

well i had thought of having the standard 1 pin to trigger the shutdown and 1 pin to detect a live pi, but then i thought i may as well use those 2 pins and use i2c for extra geek cred (and it means the pi can know the battery voltage)

its a shame the pi cant report on its 5v levels. That would allow for low battery safe shutdowns with no MCU on my unboosted projects
Get a small cheep LCD in your project http://www.sudomod.com/forum/viewtopic.php?f=22&t=2312
Wrap it all round a battery http://www.sudomod.com/forum/viewtopic.php?f=13&t=2292
Or use a custom PCB to make it really small http://www.sudomod.com/forum/viewtopic.php?f=13&t=2512
or make it really really really really tiny!! http://www.sudomod.com/forum/viewtopic.php?f=13&t=2919

User avatar
bouke
Posts: 18
Joined: Sun Jun 18, 2017 8:28 am
Location: Enschede, The Netherlands
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: Raspberry Pi ATTiny85 I2C Interfacing

Post by bouke » Sat Jul 15, 2017 6:32 am

Forked the repository from Camble which is a great start for the I2C communication between the Pi and ATTiny85. https://github.com/regnerus/Safe-Shutdo ... controller

Changed the communication library from TinyWire to Wire since I am testing/developing with an Arduino Uno instead of an ATTiny85.

Also updated my first post with what I've learnt so far... currently looking at the ATTiny167 as an alternative with more pins.
Currently figuring out how to build my first Game Boy Zero. 8-)

LeopoldVonBuschLight
Posts: 2
Joined: Sat Aug 12, 2017 9:52 am

Re: Raspberry Pi ATTiny85 I2C Interfacing

Post by LeopoldVonBuschLight » Sat Aug 12, 2017 10:13 am

Hi all! I've been working on (well, more like envisioning...) almost the exact same thing! At this point I'm just running some simple tests to see if it's possible using the usitwislave library (what TinyWireS uses) - trying to avoid the Arduino and TinyWireS libraries in order to save space.

For some reason, I haven't been able to get the tiny to be recognized by the pi. I guess there's a bug with the pi's hardware but I suspect that's not the issue.

Has anyone had any luck using the TinyWireS library to communicate between a pi and AtTiny? If so, what clock speed are you using? I'm using a tiny84 (14 pin) by the way.

User avatar
bouke
Posts: 18
Joined: Sun Jun 18, 2017 8:28 am
Location: Enschede, The Netherlands
Has thanked: 1 time
Been thanked: 7 times
Contact:

Re: Raspberry Pi ATTiny85 I2C Interfacing

Post by bouke » Sun Aug 13, 2017 11:34 am

LeopoldVonBuschLight wrote:
Sat Aug 12, 2017 10:13 am
Hi all! I've been working on (well, more like envisioning...) almost the exact same thing! At this point I'm just running some simple tests to see if it's possible using the usitwislave library (what TinyWireS uses) - trying to avoid the Arduino and TinyWireS libraries in order to save space.
Interesting, I hadn't really looked into the TinyWire library itself and didn't know there is actually another library behind it.
LeopoldVonBuschLight wrote:
Sat Aug 12, 2017 10:13 am
For some reason, I haven't been able to get the tiny to be recognized by the pi. I guess there's a bug with the pi's hardware but I suspect that's not the issue.
Untill now I used the Arduino Uno for the uploading convenience etc...
Currently figuring out how to build my first Game Boy Zero. 8-)

User avatar
moosepr
Posts: 435
Joined: Wed Jan 25, 2017 6:18 am
Has thanked: 50 times
Been thanked: 175 times
Contact:

Re: Raspberry Pi ATTiny85 I2C Interfacing

Post by moosepr » Sun Aug 13, 2017 11:43 am

I have been making a tiny board that might be of use. It's got an attiny85, neopixel, FET, and a switch.

It's untested at the moment, just waiting for the boards to land from oshpark (0.8mm boards take forever)

https://oshpark.com/projects/de5u0PZw

I have broken the i2c pins and the switch pins to the edges. You don't have to use i2c of course, they are MCU pins after all
Get a small cheep LCD in your project http://www.sudomod.com/forum/viewtopic.php?f=22&t=2312
Wrap it all round a battery http://www.sudomod.com/forum/viewtopic.php?f=13&t=2292
Or use a custom PCB to make it really small http://www.sudomod.com/forum/viewtopic.php?f=13&t=2512
or make it really really really really tiny!! http://www.sudomod.com/forum/viewtopic.php?f=13&t=2919

LeopoldVonBuschLight
Posts: 2
Joined: Sat Aug 12, 2017 9:52 am

Re: Raspberry Pi ATTiny85 I2C Interfacing

Post by LeopoldVonBuschLight » Tue Aug 15, 2017 6:00 pm

Untill now I used the Arduino Uno for the uploading convenience etc...
Sorry, I meant that I was unable to communicate between the pi and tiny via i2c. I think I'll try burning the arduino bootloader to the tiny and seeing if the TinyWireS library works any better for me.

User avatar
Camble
Posts: 838
Joined: Thu May 05, 2016 2:31 am
Location: Scotland
Has thanked: 260 times
Been thanked: 474 times

Re: Raspberry Pi ATTiny85 I2C Interfacing

Post by Camble » Sat Aug 19, 2017 6:06 am

I had a crack at this a while ago. I had planned to incorporate analog battery reads into my boards, but never completed it. The battery level is periodically monitored, but I never fully implemented the I2C communication. I'm looking to revisit it, which is how I ended up here.

My code might help:
https://github.com/Camble/RPi-I2C - the battery monitor for ATTiny85.
https://github.com/Camble/Safe-Shutdown-Microcontroller - this is something i was working on for the ATTiny167. It obviously won't fit on the ATTiny85, but I think the I²C code is a little further along so might be worth looking at.

Both sketches function as a keyboard, so if you connect the board by USB, it will output the battery voltages as keypresses.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests