bphermansson / EspSparsnasGateway

Reads data from Ikea Sparsnäs energy meter and publish via Mqtt.
MIT License
39 stars 27 forks source link

SPI write problem #17

Closed leifmariposa closed 5 years ago

leifmariposa commented 6 years ago

Hi,

I have built my own EspSparsnäsGateway with the same parts as in your parts list, but cannot get SPI to write any values. Reading is fine, I always read the default values of the RFM69, no matter what values I have written. For example, first thing that happens in your program is writing 0xAA to REG_SYNCVALUE1, but it always reads as 0x00. I have connected a logic analyzer on the SPI signals, and it looks fine, MSB is set in the address byte when doing a write.

Also, shouldn't the connection D8(NodeMCU) - EN(RFM69) be D8(NodeMCU) - CS(RFM69) ?

Any help appreciated!

BR Leif Persson

bphermansson commented 6 years ago

Have you got any further? Tried another rfm69?

leifmariposa commented 6 years ago

I tried to simplify the software as much as possible, but of course the didn't help, the output on SPI is the same according to the logicanalyzer and that seems correct to me after reading the data sheet of the RFM69HCW many times. Today I have ordered new nodemcu and rfm69hcw, will be interesting to see if that will work...

leifmariposa commented 6 years ago

OK, got a new nodemcu and a new rfm69hcw but with the same result. This is what the logic analyzer sees: https://ibb.co/bSVzKS

bphermansson, could you please check your connection? Because I changed the connection between nodemcu-D8 from EN on rfm69 to CS on rfm69, at least reads are working with this. Should the EN on rfm69 be connected?

When studying the logic analyzer output closer you can see that MISO (slave output) goes high immediately after the address byte is sent, regardless if the write bit in the address byte is set or not. Not sure what to make of this though.

Still so confused...

bphermansson commented 6 years ago

Sorry to hear that. It must be some confusion with the connections. I will take a closer look. Exactly which components did you buy?

leifmariposa commented 6 years ago

I bought in at Lawicel,

RFM69HCW Transceiver BoB Artikelnr: ADA-3070

NodeMCU V3 with ESP-12E / CH340 Artikelnr: K-NM-ESP12E

It should be the components that you recommended but your links doesn't work anymore. I think they changed the url's at Lawicel.

bphermansson commented 6 years ago

Now I've built another circuit on a protoboard with another RFM69 and another Nodemcu. I used my schematic, unmodified, and the pinout for the Rfm from https://www.mysensors.org/build/connect_radio. Works just like it should. Hmm.

leifmariposa commented 6 years ago

Thanks for taking the time to investigate! When checking mysensors.org I can't fint any break out boards, does this mean you connected directly to a RFM69(HCW) ? Because I can't find any EN signal on the RFM69, only on the break out board, and I left it unconnected on my circuit. Could this maybe be the problem?

bphermansson commented 6 years ago

Indeed it can. I used a plain Rfm without any breakout board. As noted in my schematic NSS=En.

leifmariposa commented 6 years ago

OK, so I connected the EN signal on the RFM69 as well, to another output on the nodemcu and then I have tried all possible combinations using the CS and EN signals. NSS=CS, not EN, EN controls the power on/off on the break out board. So the EN signal must be held high, andwhen it's unconnected it's held high through a pull-up resistor on the break out board. But I can still not get it to work, from what I can tell the logic analyzer shows that the SPI output is correct, but the RFM69 refuses to make any writes... The only thing I can think of is that the compunents that I bought is not compatible, could the power supply be too weak? @bphermansson, exactly which components did you use? And where did you by them? Or would you be willing to sell me a pair of working NodeMcu/RFM69 if you have extra?

bphermansson commented 6 years ago

This is your breakout? https://www.adafruit.com/product/3070 It has a level converter and a voltage regulator. Do you connect 5V to Vin? I have a RFM to sell if you want, but not many Nodemcu:s.

leifmariposa commented 6 years ago

Yes, that is the breakout I'm using, I have tried with both 3.3V and 5V supply, same problem. I've recently found this, Adafruit Feather M0 RFM69HCW Packet Radio https://www.lawicel-shop.se/catalog/product/view/id/5656/s/adafruit-feather-m0-rfm69hcw-packet-radio/ so I will by that one instead to get rid of all this hassle, it's not very expensive. Anyway, thanks for all your help!

bphermansson commented 6 years ago

Ok, hope that works!

mircopz commented 3 years ago

@leifmariposa did you solve the write error problem with RFM69? I'm facing the same issue...

leifmariposa commented 3 years ago

No, I couldn't get it working...

mircopz commented 3 years ago

@leifmariposa I don't know if you are still interested in... I saw that you participated in this topic https://forums.adafruit.com/viewtopic.php?f=19&p=672114 I had the same registers dump when reading, and I solved it when I changed reset pin logic. It's not active low (as the 99% of devices), but active high! So I was communicating with it in reset conditions, and maybe only some registers latch the default values. Inverting the reset logic everything works correctly.

leifmariposa commented 3 years ago

Great that you got it working! I'm using another solution now, but thanks for the info!