2
\$\begingroup\$

I have a pressure sensor as follows, tested and works great with the Arduino Uno:

pic

Output is digital through SCL/SDA.....

Will I be able to use this directly with the ATtiny4313 coding with Arduino language? On the Arduino Uno it's a piece of cake to connect up and use. I have not yet got the hang of the protocols and the datasheets are beyond my current knowledge and understanding.

\$\endgroup\$

1 Answer 1

5
\$\begingroup\$

Stop thinking Arduino and challenge yourself learning the bare metal microcontroller. 4k flash is not a lot for an Arduino sketch and none of the Arduino libraries are guaranteed to work, although some do. It is not supported though and there is no definitive list of libraries or library calls that work on different microcontrollers.

Check the ATtiny4313 datasheet and search for TWI (two wire interface). The datasheets is like the bible for your microcontroller, everything you ever wanted to know about it is written in there and in my opinion the Atmel datasheets are pretty good to read. From experience I know I2C is a bit tricky to get working, but you can check the Arduino library for how they solved it. The ATtiny and ATmega families are closely related and the code will be reasonably easy to port.

Acutally what you can do is work from your Arduino and port the Arduino specific code line by line until all Arduino specific commands are ported. Easy to test, and you can do it step by step. Then porting from ATmega to ATtiny is pretty straightforward.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks for the answer :) I've been intending to drop Arduino for some time. It was something I learnt at home due to the great documentation, but now at Uni it's time to do it properly :) \$\endgroup\$ Feb 26, 2014 at 18:05
  • \$\begingroup\$ Acutally what you can do is work from your Arduino and port the code line by line until all Arduino specific commands are ported. Easy to test, and you can do it step by step. Then porting from ATmega to ATtiny is pretty straightforward. \$\endgroup\$
    – jippie
    Feb 26, 2014 at 18:17
  • \$\begingroup\$ I would say that the TWI and USI peripherals are marginally similar; there are things you can do with a real TWI that the USI will fail badly at. \$\endgroup\$ Feb 27, 2014 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.