Good afternoon, I plan to make a controller for the smokehouse. with the ability to control the inclusion of heating and smoke. To determine the temperature, I plan to use thermocouples that will be connected to esp 32. In the description, I see that several devices can be connected to esp 32 via the spi bus, but I can not find an example code and how many devices can be connected to esp32. can anyone have experience with this?
I don´t have experience (yet as I am waiting for mine to arrive), but it depends on the ESP model you have. I just googled and found a good ESP reference guide and I am sure there are more of these. Programming can be done in the same way as an Ardiuno through the Arduino IDE environment.
from the description, I see that esp 32 has two sets of spi vspi and hspi ports, but can they be used simultaneously? in the description for esphome there is a line spi_id (Optional, ID): Manually specify the ID of the SPI Component if you want to use multiple SPI buses. but how to use it is not clear.
Hi.
I have not used the spi with multiple connections.
But I have one SPI display.
So if you check the documentation for this display. The Spi alternative.
You will find that there is a option for that display to specify which spi configuration:
spi_id ( Optional , ID): Manually specify the ID of the SPI Component if you want to use multiple SPI buses.
So based on the example it probably be something like this if you want use the second spi configuration for the display:
spi:
clk_pin: D?
mosi_pin: D?
id: otherSpi
spi:
clk_pin: D0
mosi_pin: D1
id: myId
display:
- platform: ssd1306_spi
model: "SSD1306 128x64"
cs_pin: D2
dc_pin: D3
reset_pin: D4
spi_id: myId
lambda: |-
it.print(0, 0, id(font), "Hello World!");
Note! that I have not tested this. So I hope it right.
I think it should look like this,
spi:
id: otherSpi
clk_pin: D?
mosi_pin: D?
id: otherSpi2
clk_pin: D0
mosi_pin: D1
but can it be used simultaneously vspi и hspi,
I figured it out a bit, vspi and hspi are equivalent buses, you can connect up to 3 devices to each bus, miso_pin and clk_pin will be common to 3 devices, but each has its own CS. it remains to understand what pins can be CS
In case you can’t connect all you need then you can use a thermometer with resistive output.
ESP32 usually have a few analog pins.
You can connect as many devices to an SPI bus as you have available CS pins (more or less, there are electrical characteristics like capacitance that must be observed).
A CS pin is simply an IO pin on the MCU, connected to the SPI device, that is driven low by the MCU to select that device.
There is nothing fundamentally special about the CS pin. Any good library that uses an SPI device will allow you to select any arbitrary GPIO as the CS pin.
Thanks for the help, I will order thermocouples.
Did anyone get this to work? I can’t get the second spi set up without yaml errors. Can’t find a working example either, which I think is strange.
I’m just waiting for a thermocouple. I think that in January I can test it. but I decided to write the code myself through arduino ide
I just got mine to work with the following. Note the dash at the start of the id lines for the spi and then just specify the same spi_id for each temp probe for each sensor.
spi:
- id: probe01
miso_pin: D8
clk_pin: D6
- id: probe02
miso_pin: D2
clk_pin: D4
sensor:
- platform: max6675
name: "Probe01 Temperature"
spi_id: probe01
cs_pin: D7
update_interval: 10s
- platform: max6675
spi_id: probe02
name: "Probe02 Temperature"
cs_pin: D3
update_interval: 10s