Connecting a New Component to Your esieabot
If you want to connect a new component to your esieabot but it is not listed as an example in the Programming on esieabot documentation, don’t panic! You can very likely get it working with your esieabot. This documentation covers the questions to ask yourself and the steps to follow to connect a new component to your esieabot.
How is my component powered?
The first question you need to ask yourself is: “How is my component powered?”. This is an essential question, as incorrect power supply could destroy your component or your esieabot. Several cases are possible:
Your component is powered at 3.3V: in this case, you can connect it directly to your esieabot (see below)
Your component is powered at 5V: in this case, you can power it from your esieabot, but if it sends signals back at 5V, you must use a logic level converter to avoid damaging your esieabot (see below)
Your component is powered at a different voltage: in this case, you must power it separately. If it sends signals back at a voltage other than 3.3V, you must use a logic level converter to avoid damaging your esieabot (see below)
Note
The information below concerns “bare” components. If you want to connect a USB or Bluetooth device, you can refer to the use/common/common section for instructions.
In any case, the ground of your component must be connected to the ground of your esieabot. The ground of your component is often labelled “GND”, “-”, or less commonly “VSS”. On your esieabot, the ground is labelled “GND” or “-”. Multiple ground points are available on your esieabot; they can be used interchangeably as they are all connected together.
For the power supply, the pin on your component should be labelled “VCC”, “VDD”, or “+”. You must connect it to a compatible power source depending on its voltage (see above). Your esieabot provides 3.3V power pins (number 7 in the image) and 5V power pins (number 8 in the image). Be careful not to mix up the different voltages, as this could damage your esieabot or your component.
Finally, your esieabot cannot supply an unlimited amount of current. If your component draws a lot of current, your esieabot may trigger a safety cutoff and restart. As a guideline, if your component is powered at 3.3V it must not draw more than 500mA. If your component is powered at 5V, it must not draw more than 1A. If your component draws more than that, you must power it separately.
How does my component communicate with my esieabot?
Case 1: your component communicates via a bus
Some components communicate via a communication bus, such as I2C or SPI. Refer to its documentation if needed. If you are unsure, you can identify certain buses fairly easily:
If your component has an “SDA” pin and an “SCL” (or “SCK”) pin, it probably communicates over I2C. In this case, you must connect the “SDA” and “SCL” pins of your component to the “SDA” and “SCL” pins of your esieabot respectively.
If your component has a “MOSI” pin, a “MISO” pin, and an “SCK” pin, it probably communicates over SPI. In this case, you must connect the “MOSI”, “MISO”, and “SCK” pins of your component to pins 10, 9, and 11 of your esieabot respectively.
The advantage of a communication bus is that you can connect multiple components to the same pins on your esieabot. For example, you can connect multiple I2C components in parallel on the “SDA” and “SCL” pins of your esieabot. However, each component must have a different address so that your esieabot can tell them apart.
Note
Several components are already connected to the I2C bus of your esieabot, such as the OLED display, the gyroscope, or even the power board!
With I2C, you need to determine the address of your component in order to communicate with it. If you cannot find the component address in its documentation, you can determine it by performing an I2C scan. To do this, you can use the “i2cdetect” utility which is pre-installed on your esieabot. Run the following command: i2cdetect -y 1 directly in your robot’s terminal. A grid will appear showing addresses. If an address is occupied by a component, its address will be shown in the grid. If an address is not occupied, “–” will be shown instead.
Note
Try connecting and disconnecting the component while performing multiple scans to confirm your component’s address. If you have multiple components on the same bus, try connecting them one at a time to distinguish their addresses.
Case 2: your component communicates via standard input/output pins
If your component communicates via standard input/output pins, you must connect it to an available GPIO pin on your esieabot. These components (for example a button, an LED, etc.) are simpler to connect. They simply send or receive electrical signals through one or more pins. You just need to connect the pins of your component to available GPIO pins on your esieabot (number 2 in the previous image).
- The GPIO pins available by default are the following:
GPIO 4
GPIO 5
GPIO 7
GPIO 8
GPIO 9
GPIO 10
GPIO 11
GPIO 12
GPIO 14
GPIO 15
GPIO 19
GPIO 20
GPIO 21
Warning
In all cases, these pins cannot receive a voltage higher than 3.3V. If your component sends signals at a voltage higher than 3.3V, you must use a logic level converter to avoid damaging your esieabot.
Note
The GPIO pins of your esieabot can only send or receive values of 0 or 1. If your component sends analog values, you must refer to case 3.
Case 3: your component communicates via analog pins
If your component communicates via analog pins (for example a photoresistor), you must connect its output pin(s) to the analog inputs of your esieabot (number 6 in the image above). Your esieabot has 4 analog inputs, numbered 0 to 3. You can connect your component to any available analog input. You must then use in your program a library that reads values from the TLA2024 analog converter on your esieabot, for example: https://github.com/adafruit/Adafruit_CircuitPython_TLA202x
Warning
The analog converter built into your esieabot (the TLA2024) cannot read voltages higher than 3.3V. If your component sends signals at a voltage higher than 3.3V, you must use a logic level converter to avoid damaging your esieabot.
Note
Analog values read are encoded on 12 bits, meaning they range from 0 to 4095. If your component sends a voltage of 0V, you should read a value close to 0. If your component sends a voltage of 3.3V, you should read a value close to 4095.