Outils pour utilisateurs

Outils du site


communication_protocole_i2c

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
communication_protocole_i2c [2022/09/07 09:01] – [Exemple entre Raspberry Pi et Arduino Leonardo] sergecommunication_protocole_i2c [2022/09/07 09:33] (Version actuelle) – [Communication avec le protocole I2C] serge
Ligne 1: Ligne 1:
 ====== Communication avec le protocole I2C ====== ====== Communication avec le protocole I2C ======
 +{{ :media_16:2_codeurs_ok.png?600 |}}
  
 =====Ressources===== =====Ressources=====
Ligne 7: Ligne 7:
   * **[[https://www.gammon.com.au/i2c|I2C par Nick Gammon]]** This post describes how the I2C (Inter-Integrated Circuit, or "Two-Wire") interface works, with particular reference to the Arduino Uno which is based on the ATmega328P microprocessor chip. A lot of the details however will be of more general interest.   * **[[https://www.gammon.com.au/i2c|I2C par Nick Gammon]]** This post describes how the I2C (Inter-Integrated Circuit, or "Two-Wire") interface works, with particular reference to the Arduino Uno which is based on the ATmega328P microprocessor chip. A lot of the details however will be of more general interest.
   * https://github.com/nickgammon/I2C_Anything   * https://github.com/nickgammon/I2C_Anything
 +
 +
 +=====Installation sur une Pi=====
 +
 +From https://gist.github.com/ribasco/c22ab6b791e681800df47dd0a46c7c3a
 +
 +<code bash>
 +sudo nano /boot/config.txt
 +
 +# Find the line containing dtparam=i2c_arm=on
 +# Add i2c_arm_baudrate=<new speed> (Separate with a Comma)
 +dtparam=i2c_arm=on,i2c_arm_baudrate=400000
 +</code>
 +
 +Reboot Raspberry Pi\\
 +Create a simple test script to verify the speed
 +
 +Switch to home directory 
 +  cd ~
 +Create shell script 
 +  nano i2cspeed.sh
 +Copy and paste the following lines of code
 +<code bash>
 +#!/bin/bash
 +var="$(xxd /sys/class/i2c-adapter/i2c-1/of_node/clock-frequency | awk -F': ' '{print $2}')"
 +var=${var//[[:blank:].\}]/}
 +printf "%d\n" 0x$var
 +</code>
 +Change file permissions
 +  chmod +x i2cspeed.sh
 +
 +Execute test script
 +  ./i2cspeed.sh
 +
 +=====Installation sur Arduino=====
 +  * https://docs.arduino.cc/learn/communication/wire
 +  * https://radiostud.io/howto-i2c-communication-rpi/
 +  * [[https://www.arduino.cc/reference/en/language/functions/communication/wire/|la doc arduino pour la lib Wire]]
 +
 +=====smbus2=====
 +La lib I2C python
 +  * https://github.com/kplindegaard/smbus2
 +
  
 =====Exemple à revérifier===== =====Exemple à revérifier=====
   * https://github.com/sergeLabo/furuta/tree/main/doc/NickGammon_I2C l'exemple de Nick simplifié   * https://github.com/sergeLabo/furuta/tree/main/doc/NickGammon_I2C l'exemple de Nick simplifié
- 
  
 =====Exemple entre Raspberry Pi et Arduino Leonardo===== =====Exemple entre Raspberry Pi et Arduino Leonardo=====
Ligne 113: Ligne 155:
 </code> </code>
 =====Pull-up Resistors===== =====Pull-up Resistors=====
-https://learn.sparkfun.com/tutorials/pull-up-resistors +  * https://learn.sparkfun.com/tutorials/pull-up-resistors 
 +  * **[[https://www.gammon.com.au/forum/?id=10896&reply=5#reply5|Nick explique tout]]**
  
-{{:media_16:pull_up_resistor.png?400|}}+On tire le signal vers le **+** avec une résistance sur SDA et SDL: 
 +{{ :media_16:pull_up_resistor.png?200 |}}
  
  
communication_protocole_i2c.1662541316.txt.gz · Dernière modification : 2022/09/07 09:01 de serge