Products > Embedded Computing

[SOLVED] [newbie] How do pins work? How to talk with sensors?



I have two newbie questions:

1. I see that on boards, the same I/O pin has different names (eg. IO17 = I/O/T, RTC_IO17, DAC1, ADC2_CH6, UART1_TX). I would like to understand why. Does each pin use a different voltage + current? Can each only be used for a specific task?

2. It seems there are several protocols to talk to a sensor (Modbus, I2C, SPI, UART, possibly others.) Is there a good article that explains the differences, and how to work with each?

FWIW, I need to interact with a sensor through the serial port (UART?).

Thank you.

Within a microcontroller there can be many peripherals having different functions. Like UART, SPI, I2C, timers, etc. To make things more flexible most also have a way to connect one of these peripherals to an io pin. These are often called alternate functions.

That is why you see multiple signal names next to an io pin. It can be one of these functions based on the settings in the MCU.

You are misusing the term protocols in your second question. I2C, SPI, UART, CAN, etc. are hardware interfaces that connect your MCU to a sensor. It then depends on the sensor what the communication protocol over this hardware interface is.

Modbus on the other hand is a protocol. It can work on top of some of the hardware interfaces mentioned above.

Without knowing which sensor you want to connect with, there is no good referral to be made.

In the old days you only had one feature per pin.  But it was annoying because if you didn't need that feature those pins were totally useless to you. Also you could only have as many features in the chip that you had pins to use for them.

So they decide to routed the signals to all pins with internal switches that you can control in software.
Then they can add even more features and you can select the ones you need and connect them to the pins that suit your design.

Thanks very much. This page also makes it clear that different components on a board share pins.

It's to communicate with a CO2 sensor ("Communication: UART (Modbus)")

Don’t overlook the fact that the one UART of the ESP32 is used for the USB connection. That is needed to get your firmware image loaded into the device and for serial prints to the console for debugging.

Low speed serial devices like your sensor will usually work ok with “software serial” were the UART hardware functionality is duplicated with software.


[0] Message Index

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod