pr3y / Bruce

Firmware for m5stack Cardputer, StickC and ESP32
GNU Affero General Public License v3.0
278 stars 47 forks source link

Add CustomRF / SubGhz (help needed) #66

Closed eadmaster closed 1 month ago

eadmaster commented 1 month ago

compatibile with flipper sub files https://github.com/Zero-Sploit/FlipperZero-Subghz-DB

possibly reuse code from my repo.

I am looking for a way to convert sub raw codes to the format supported by the rc-switch lib, if you have some example code, please post here.

bmorcelli commented 1 month ago

what's up @eadmaster ,I really liked your suggestions and I've spoken to pr3y about what you are doing.

We are expecting your Pull Request to merger your Serial CLI solution into Bruce in the next update.

Feel free to contact us on Discord! @bmorcelli or Pirata#5263

eadmaster commented 1 month ago

no problem, i still have to test if the changes i've made did break some other feature (e.g. badUSB) EDIT: added a test build here.

Regarding this issue, maybe i've found something here, i will try to see if it works.

bmorcelli commented 1 month ago

Nicee!!! I Pulled your repo this morning and I'm making changes over it regarding other Settings and other stuff..

eadmaster commented 1 month ago

I've managed to add an experimental implementation via a new "Custom Subghz" menu, but has some important limitations:

Switching to a CC1101 would remove these limitations, but there is no easy way to connect it via a Groove connector afaik.

In order to test if my current implementation is working correctly i need either:

As a bonus, i've added a "Recent" menu to quickly select previously sent commands, but it is still not working correctly (suggestions are welcomed).

Petitoursbr1 commented 1 month ago

Hi Mr. Eadmaster,

On this project https://github.com/bmorcelli/io433, you can find a diagram for the connection of a CC1101 to an M5Stick C+.

tGOFaofI

I don't know if it helps, but I'm trying because I'm very hyped about the project.

eadmaster commented 1 month ago

There are no free Gpio pins on the cardputer, i think i need another solution like this: https://www.reddit.com/r/M5Stack/comments/17lwkrd/i_was_disappointed_with_the_number_of_useful_pin/ (Which i'd like to avoid)

Maybe a bridge like this would be better, but i am not sure if fast enought for this use case: https://www.dfrobot.com/product-2002.html https://learn.adafruit.com/adafruit-mcp23017-i2c-gpio-expander/arduino

bmorcelli commented 1 month ago

We intend to use the ext I/O from M5Stack to integrate with cc1101, but there's a lot of things to consider to make it work, like:

Other thing that should work (easily I think) is programming a ESP32S3 mini to interface with CC1101 through SPI and with Cardputer/StickCs with I2C(Grove port)... It would be an easy port though, but will need to buy an extra mcu ..

I have all these devices at home, but need time to make things happen

eadmaster commented 1 month ago

I am not very fond of this solution because:

Another solution could be using one of these modules, since they only require 1 data pin, you could re-purpose the SDA and SCL pins on the groove connector to drive them directly (e.g G1->TX, G2->RX). I actually have 1 set of these so i might give it a try in the future.

Btw in the meanwhile i'll stick to the RF433T module i already have. Since It is able to use the same codes i've captured on Tasmota (tested with this serial cmd), I am going to add an unofficial protocol to the Subghz File Format to support these codes directly. e.g.:

Filetype: Flipper SubGhz Key File
Version: 1
Frequency: 433920000
Preset: FuriHalSubGhzPresetOok270Async
Protocol: RcSwitch
Bit: 24
Key: 44 55 33
TE: 174

This should correspond to {"Data":"0x445533","Bits":24,"Protocol":1,"Pulse":174,"Repeat":10}'

I've also made this script to generate raw codes, but it not working as expected, so i will use these custom sub files in the meanwhile.

bmorcelli commented 1 month ago

Me neither.. but the only downside of the M5modules and these single pinned modules is that they work only in 433Mhz..

But the thing is, we keep developing for what we have in hand, that are the M5 RF433T and R (that will work with the cheaper ones, regarding the pin setting)

I'm very curious and excited to see your code running in this project..

Ademolght commented 1 month ago

Can work like this I think image

eadmaster commented 1 month ago

Can work like this I think image

In theory it could, but in pratice there are a few caveats to sort out as stated before: different logic voltage, rc libraries expecting to write directly to gpio pins instead if i2s, extra latency due to the i2c bus itself. I've tried bitbanging SPI in the past and it is not an easy task, so i won't be trying this again here.

The easier solution would be having 4 extra gpio pins on the cardputer. According to this table there are actually GPIO16-18, 45, 47, and 48 which are unused, but afaik they are not easily accessible , maybe they could via an hardware mod.

Ademolght commented 1 month ago

Okay

eadmaster commented 1 month ago

Prolly this is easier:

  1. reconfigure the groove port as a software serial / uart port
  2. wire a 2nd microcontroller running this firmware https://github.com/mcore1976/cc1101-tool

No need of bitbanging spi, no voltage shifting required, and much easier protocol to work with.

do you know if 1. can be done on a cardputer?

IncursioHack commented 1 month ago

I didn't really have time to test much, but come on.

M5Stack's PCA9554 can solve this problem with CC1101, this insight came from an old Everson project that demonstrates the use of PCA9554 with radio frequency devices.

https://www.youtube.com/watch?v=ft_q9qrzepI

With reference to the voltage regulator, a KIA1117PI33 is used to reduce from 5V to 3.3V, I believe that this can be fitted to the CC1101 itself, not generating a cost or a large amount of wires.

https://semiconductors.es/datasheet/KIA1117PI33.html

Another possibility is to get the 3.7V from the battery and bring a wire to the outside area of the Cardputer, this increase in voltage is about 10%, the CC1101 should hold up without problems, but more tests are needed.

https://docs.m5stack.com/en/core/Cardputer

bmorcelli commented 1 month ago

reconfigure the groove port as a software serial / uart port wire a 2nd microcontroller running this firmware https://github.com/mcore1976/cc1101-tool No need of bitbanging spi, no voltage shifting required, and much easier protocol to work with.

This is what I mean by:

Other thing that should work (easily I think) is programming a ESP32S3 mini to interface with CC1101 through SPI and with Cardputer/StickCs with I2C(Grove port)... It would be an easy port though, but will need to buy an extra mcu ..

But your idea of inteerfacing them by Serial is much better! the MCU is very cheap

eadmaster commented 1 month ago

quick recap on this:

Test build here for the cardputer only.

mmjud commented 1 month ago

Has anyone tried using the HC-11 RF module?

eadmaster commented 1 month ago

HC-11 and HC-12 cannot be used for custom SubGhz:

the main purpose of the HC-12 is to create a transparent wireless link between two HC-12's rather than being a generic board. If you are looking to have wireless detectors, switches and other "home automation" gadgets then it's probably not the way to go.

(source)

Little update for CC1101 support:

The uSD card mod could also work via ribbon cables, as suggested on reddit. So no need to desolder the SD socket, but would need to solder the ribbon cable to the CC1101 module. I've fould also these breakout boards that may be easier to work with.

Speaking of ribbon cable mods, the LCD is also using SPI, and 2 devices can share to the same bus via the CS=ChipSelect pin. The hard part here is to make a PCB to split the lines between the 2 modules.

eadmaster commented 1 month ago

Closing this as it was merged already, open other issues for bugs/improvements /etc