Guidance on the Compatibility of Rust with STM32F3 Microcontroller and Various Sensors/Device

Hello everyone,

I'm currently interning at a company where we need to select the appropriate technology and hardware for our project. As a beginner, I'm feeling a bit overwhelmed. I have experience with Rust but not with embedded technology. They have assigned me the task of researching whether the following sensors and devices can work with Rust and the STM32F3 microcontroller:

  1. Serial Module FTDI Basic
  2. MQ-4 Gas Detector
  3. AHT20, BMP280, F-28, DS18B20, AM2302, DHT22, AM2303, AHT10, BME280, BMP180
  4. Soil NPK Sensor Probe
  5. ElecHouse V3

I would greatly appreciate guidance on the steps I should take and where to begin. I want to determine if it is possible to use these components with Rust/STM32F3 or if we should consider an alternative technology altogether.

Thank you in advance for your assistance!

I'm not sure what this has to do with Rust. Talking to peripherals is usually a question of implementing their protocol, using either dedicated hardware (eg. I2C or SPI) or GPIO, and it's rarely impossible. The presence or absence of dedicated hardware interface is not a matter of the programming language, and Rust can bit-bang just as well as any other language.

Do you have something more specific in mind?

the rust embedded eco system is quite usable I would say, at least for ARM cortex-m based devices. as far as I know, the toolchain and runtime support for the STM32 series SoCs are generally very good. see documentation for the corresponding hal and pac crates for details.

as for those specific devices, it's hard to say, you probably need to write drivers for them anyway, except for those using standard protocols like I2C or SPI, and possibly for some widely used custom protocols such as DS18B20 or DHT22 etc.

  1. Find the data sheets for all the devices you want to use. I'm sure there are PDF's available.

  2. For each device determine from its data sheet what interface it presents. Typically serial (RS232, RS485, RS422, logic level), I2C, SPI, parallel bit banging etc. I guess some might have analog outputs.

  3. From the data sheet of the micro-controller determine what kind of hardware support it has for all those interfaces and how many of each is possible. Note that for some interfaces it is possible to hang multiple devices on the same micro-controller pins. The "bus" is shared and devices selected by some kind of address.

Now you know if it is even physically possible to hook up all those devices to your micro-controller. If not start looking for a different micro-controller. Or perhaps looking for ways to expand the interface possibilities with I/O expanders and such.

  1. And so to software. With luck you can find some drivers already written for your devices. If not you may have some work to do there.

Take a look at the awesome embedded Rust. There is a list of supported devices, i.e., for which known drivers exist.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.