How to use soft SPI to connect my sensor chip while hard SPI is used for radio?



  • Hello, I have to say Thanks to Hek and all the MySensors team for this useful work, You are a great team guys!.
    I have designed a nice PCB, I already have received this from PCBWay and I am ready to solder it. This board has a NRF24L01 connected to the SPI on Arduino pro-mini pins, same as described in “connecting radio” in the MySensors build section. The board also has an Atmel chip ATM90E26A, a smart metering chip. My intention is to make a mysensor energy smart meter. This ATM90E26 has SPI pins connected to Arduino pro-mini pins as follow:
    -- MOSI to pin D5
    -- MISO to pin D6
    -- CLK to pin D7
    -- CS to pin D8
    I did these connections because I though this will prevent problems of SPI sharing and different SPI settings, (I though It can be better if I use MySensors soft_SPI for the energy chip, I though it would be easy to declare in the sketch) but now I am in trouble because I have spend a lot of time trying to make it work unsuccessfully. I cannot re assign the hardware connections pins because the PCB is now done. It is my mistake I should have tested it in a protoboard before to design the PCB. Then any hardware changes cannot be made.
    I see that MySensor library can set SOFT_SPI pins but when you declare your radio type or gateway type, this SPI is assigned to the radio. My question is How to use soft SPI for my sensor chip and the hard SPI for the radio? Thank in advance, Please help me.


  • Mod

    Hi.

    The devices should be able to share the hardware SPI, but some hardware and libraris don't play well on a shared SPI so using software SPI might be easier. And since the PCB is done, I guess Software SPI is the only option anyway unless you patch the board (which could be an option).

    Are you using a library for the ATM90E26A? If so, does that library support Soft SPI? If it does, all you should need to do is to include a Soft SPI library and instruct the ATM90E26A library to use the Soft SPI instance. MySensors would not be affected at all; just like it wouldn't be affected by connecting something using oneWire or SoftSerial.



  • @mfalkvidd Thank you for answer. Yes, I am using a library for the ATM90E26A that is in github written by Tisham Dhar whatnick it support UART and SPI for this chip but not softSPI.
    I was making some code experiments using other softSPI libraries trying to combine them to make the ATM90E26A works with softSPI. I tried to use also digitalIO and other for RFID using SoftSPI, no successful and probably I will have to contact to Tisham Dhar for SoftSPI implementation in the ATM90E26A library.
    I was thinking (when I design the PCB) is to use the MySensors Soft_SPI feature to read the energy chip, but now as you said, I understand it need to be supported in the ATM90E26A library and not in the MySensor library. Anyway if anyone of you has any idea please let me know, I will be happy to try it. If the ATM90E26A library got softSPI support I will update this post. Many thanks.



  • @jimy-aguirre I have contacted Tisham the ATM90E26 smart energy chip Arduino library author. He suggest to submit an issue against the library in github to request the softSPI feature support by the library, then I did it, here it is the link. If anyone can write any suggestion or constructive comment on github it is very welcome.
    Of course if there is any "alternatively solution" to assign the mysensors library softSPI pins to the sensor chip and it works while the radio is connected to the SPI (hardware SPI) I will be happy to test it.
    Thanks to all.


Log in to reply
 

Suggested Topics

  • 1
  • 1
  • 5
  • 6
  • 1
  • 10

17
Online

11.4k
Users

11.1k
Topics

112.7k
Posts