rstrouse / ESPSomfy-RTS

A controller for Somfy RTS shades and blinds
The Unlicense
429 stars 32 forks source link

Pinout #353

Closed Boosmoo closed 2 weeks ago

Boosmoo commented 2 months ago

I have a esp32 c3 super mini and I have a dumb question about the pinout. Should the RX pin on the esp32 be connected to the TX pin of the cc1101 and vise versa? because of tx should be connected to tx because then I cant select the right pins.

rstrouse commented 2 months ago

The communication between the cc1101 and the ESP32 is not using a serial protocol like rsXXX. The chip communicates over SPI which is the top row of pins in the config pages and the transceiver over gpio. Simply assign the tx pin to GDO0 on the transceiver and the rx to GDO2. Ignore the rx and tx assignments those are for another purpose.

Boosmoo commented 2 months ago

Okay. But its not available in the menu then the tx pin is 21 on my esp but the menu only goes to 20

rstrouse commented 2 months ago

Use another pin. The pin marked tx on the c3 is likely a jtag pin.

Boosmoo commented 2 months ago

Used 9 and 10 but it still doesnt work. It keeps saying radio not initialized.

rstrouse commented 2 months ago

Then that is not because of the rx and tx pins. The upper row of pins are the spi chip configuration. If the pin selection does not match the wiring for sck,mosi,miso,and csn it will not be able to initialize the transceiver. Just to be sure you did you check the enable radio checkbo?

Boosmoo commented 2 months ago

Yes I triple checked the connections and the radio is enabled.

Boosmoo commented 2 months ago

c286595a99d202f8a3aef6d6caf1f2c90474200d

I used this pinout.

rstrouse commented 2 months ago

I would not connect anything to the rx/tx pins on that board. Most often that is attached to uart0 and is for serial console.

Boosmoo commented 2 months ago

I connected them to 9 and 10 but it still doesnt work.

rstrouse commented 2 months ago

Take some pics of your wiring on both the CC1101 and the ESP32 so I can look at how you have this wired up as well as a screenshot of your radio configuration. Are you getting a Radio not Initialized message?

Boosmoo commented 2 months ago

IMG_7516 Schermafbeelding 2024-05-01 212320

Yes im getting that message.

rstrouse commented 2 months ago

EDIT: Please ignore this I went back and looked at the pic again and you do have the correct wiring.

For some reason I got all twisted around looking at the picture. Double check your solder joints to make sure they are making good contact and are not making contact with any other pin.

According to your pic the wiring is setup like below and does not match the configuration screen.

Tr Pin Color Func ESP32
1 White GND GND
2 Yellow 3v3 3v3
3 Purple GDO0/TX GPIO7
4 Gray CSN GPIO9
5 Yellow SCLK GPIO6
6 Orange MOSI GPIO4
7 Green MISO GPIO10
8 Brown GDO2/RX GPIO5

Your configuration looks like it should be like below

image

rstrouse commented 1 month ago

@Boosmoo Did you get your issue resolved or is there anything more that I can do to help?

Boosmoo commented 1 month ago

It still doesnt work

rstrouse commented 1 month ago

Just in case I missed something, I inventoried your wiring again. I assume the wire going from pin 3 on the E07-M1101D is gray and terminates at GPIO9. Please verify that the connections are as I believe they are since I assumed this from your picture.

Tr Pin Color Func ESP32
1 White GND GND
2 Yellow 3v3 3v3
3 Gray GDO0/TX GPIO9
4 Purple CSN GPIO7
5 Orange SCLK GPIO4
6 Yellow MOSI GPIO6
7 Brown MISO GPIO5
8 Green GDO2/RX GPIO10

If this is how you have it wired and your configuration is as pictured on from your screenshot above we should do some additional troubleshooting. First update your firmware to v2.4.3 pre. This uses the Arduino core 2.0.16 which has fixes to the C3 chips. I did rewire a C3 as above and it worked fine for me on v2.4.2. However, mine is a Seeed Studio board and not ICBuy board and according to the PRs in the Arduino core there have been fixes for the SPI interface.

Next please look very closely and make sure that no stray strands of wire are connecting especially between GPIO5, GPIO6, or GPIO7. Look very closely on the transceiver as well. The Radio not Initialized message happens when the configuration is sent to the E07M1101 over the SPI interface and it cannot be read back.

If after performing these steps it still does not initialize then you must have either a defective ESP32 or E07M1101D board. There is no real way to tell which one is goofy.

rstrouse commented 1 month ago

@Boosmoo have you figured out what the issue is. I have confirmation that once the wiring was fixed in the issue linked above for the same hardware that it worked fine.

Nickduino commented 1 month ago

I would not connect anything to the rx/tx pins on that board. Most often that is attached to uart0 and is for serial console.

I used them myself image

Are they used only to receive data when the radio is listening?

rstrouse commented 1 month ago

The rx pin is attached to an interrupt when listening and the tx pin is pulsed to send the frame. However, the tx pin also receives when listening. Typically a uart pulls the pins but I think it depends on how it is implemented.

Nickduino commented 1 month ago

But they're used to listen only, so the fact they're assigned to UART pins should not negatively impact the emitting range of the device, right?

rstrouse commented 1 month ago

Actually a uart is a transceiver chip where TX pin is pulled low. I don't know if this is done even if the UART is not enabled or if this is simply the wiring. I guess it depends on its implementation on the board.

See this issue. #367 It looks like the board maker hooked those up on that board to the CH340 chip.

Nickduino commented 1 month ago

I mean by ESPSomfy. The use of the TX/RX pins is for receiving frames from other remotes, right? When the CC1101 is receiving.

Said differently, can you omit the TX/RX connection and still control the blinds?

rstrouse commented 1 month ago

No you cannot. The transceiver does not operate the same way as a typical full duplex serial device. While one could use the SPI interface to send sequences for some protocols on the CC1101, this does not work reliably for the RTS protocols for a variety of reasons. As a result ESPSomfy RTS, does bit banging to send and receive and GDO0 must be connected to the pin configured as TX to send out signals.

The transceiver has a GDO0 pin that when in transmit mode, must be pulsed to modulate the signal. This is what is connected to the pin configured in the ESPSomfy RTS configuration as TX. When in transmit mode pulsing this pin from low to high and high to low is what encodes the symbol data on the airwaves. ESPSomfy RTS floats this pin when it is not transmitting but the transceiver will pull it high and low depending on the detected signal.

The ESPSomfy RTS RX pin is connected to the GDO2 pin on the transceiver. This pin is pulsed when the radio signal goes from high to low or low to high. Each transition when compared with the timing represents a symbol timing and ESPSomfy RTS translates these into the encoded frame from the transceiver.

There is one other thing to note here is that when in receive mode, the CC1101 will pulse GDO0 meaning you can completely omit the connection to GDO2. However, I have special code to switch modes so that the receive and transmit mode is multiplexed and does not get reflections from its own transmissions. In this instance you set the RX and TX to the same pin connected to GDO0. ESPSomfy RTS will happily send and receive on this pin.

Unfortunately, some of the boards are not very well documented and it is just better to avoid pins that can be used for peripherals that are soldered onto the board. For instance, there are a number of boards that have JTAG and CH340 usb chips on them. In most cases those pins labeled as RX/TX on the board are connected to that chip. Which depending on the implementation may pull these pins high and low so that they hook the stdout serial console.

It is just better off not using them. Otherwise, you could experience issues that require you to dig into the schematics and documentation to see how it is implemented. ESPSomfy RTS can reliably transmit and receive on virtually any digital pin that is not being used for some other purpose.

Nickduino commented 1 month ago

Alright, thank you!

I had made this assumption because at some point I made a mistake and inverted the Tx and Rx pins but the frames were still sent. Not received, though.

rstrouse commented 1 month ago

Yeah most of us have been through through some level of full duplex serial communication and its hard to get the twisted pair out of our heads.

Unfortunately, with some of the board manufacturers they leave out important details regarding their implementation. A simple footnote on the pinout diagram would suffice. Especially, when they solder their own peripherals onto the board.

rstrouse commented 2 weeks ago

@Boosmoo I am going to close this as I assume you have gotten the issue resolved by now.