bphermansson / EspSparsnasGateway

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

No values? #22

Closed Naesstrom closed 5 years ago

Naesstrom commented 5 years ago

So I finally got around to assembling this, even added a sma contact and a 868 antenna to the breakout board. Serial monitor just gives me this:

Attempting MQTT connection...Connected to Mqtt broker as EspSparsnasGateway
Stored data: 
There are no stored frequency, using default value
There are no stored senderid, using default value
Senderid: 570631
Frequency: 868000000
61.04
Over The Air programming enabled, port: EspSparsnasGateway
Ready
IP addre

The senderid is the one I entered and the frequency looks right to, the strange thing is that it cuts out before it even tells me the IP... Debug is set to 1 btw.

On the mqtt side of things it repeats the following 4 rows a couple of times

{"status":"Connected to Mqtt broker as EspSparsnasGateway"}
{"status":"There are no stored frequency, using default value"}
{"status":"There are no stored senderid, using default value"}
{"status":"EspSparsnasGateway @ IP:192.168.1.201 SSID: Katrinelund"}

The really strange thing tough is that if I disconnect the ESP from everything and run it the monitor seems to work?

Attempting MQTT connection...Connected to Mqtt broker as EspSparsnasGateway
Stored data: 
There are no stored frequency, using default value
There are no stored senderid, using default value
Senderid: 570631
Frequency: 868000000
61.04
Over The Air programming enabled, port: EspSparsnasGateway
Ready
IP address: 192.168.1.201
EspSparsnasGateway @ IP:192.168.1.201 SSID: Katrinelund
In initialize, frequency = 868100000
Adjusted freq: 14222950
61.04
RFM69 init done
Radio initialized.
Listening on 1023999936hz. Done in setup.
Naesstrom commented 5 years ago

Did some more debugging, running the ESP with everything but the RFM69 unit I get a complete startup in the serial monitor to... starting to think that my module might be DOA...

bphermansson commented 5 years ago

What esp-module are you using? What kind of power supply?

Naesstrom commented 5 years ago

NodeMCU v3 (lolin) and just USB power from the PC atm.

Naesstrom commented 5 years ago

Running it with a 1A external poweradapter gives me:

Welcome to EspSparsnasGateway
Compiled at:Oct 30 2018 21:51:42
Debug on
Vcc=2923
Attempting MQTT connection...Connected to Mqtt broker as EspSparsnasGateway
Stored data: 
There are no stored frequency, using default value
There are no stored senderid, using default value
Senderid: 570631
Frequency: 868000000
61.04
Over The Air programming enabled, port: EspSparsnasGateway
Ready
IP address: 192.168.1.201
EspSparsnasGateway @ IP:192.168.1.201 SSID: Katrinelund
In initialize, frequency = 868100000
Adjusted freq: 14222950
61.04
Failed on waiting for ModeReady()
Unable to initialize the radio. Exiting.

Not sure what it means with Failed on waiting for ModeReady()

bphermansson commented 5 years ago

Can you try to set the frequency in the code?

Edit: That should already be done as you have no stored frequency. It seems to fail when initializing the Rfm. Have you checked the wiring? Some other code that uses the Rfm69?

Naesstrom commented 5 years ago

I made a PCB that looks like this from your schematic: esp_sparsnas_gateway_mcuv3_schem Measured all the connections and they seems to be just fine, even mounted my second RFM now but with the same problem. I'll try and connect them on a breadboard and see if that helps!

And no other code on the ESP then your repo.

Naesstrom commented 5 years ago

Redid the wiring on a breadboard but still the same result when connecting 12V power... Radio is getting 3.3V to.

Compiled at:Oct 30 2018 21:51:42
Debug on
Vcc=2928
Attempting MQTT connection...Connected to Mqtt broker as EspSparsnasGateway
Stored data: 
There are no stored frequency, using default value
There are no stored senderid, using default value
Senderid: 570631
Frequency: 868000000
61.04
Over The Air programming enabled, port: EspSparsnasGateway
Ready
IP address: 192.168.1.201
EspSparsnasGateway @ IP:192.168.1.201 SSID: Katrinelund
In initialize, frequency = 868100000
Adjusted freq: 14222950
61.04
Failed on waiting for ModeReady()
Unable to initialize the radio. Exiting.
Naesstrom commented 5 years ago

Been googling and trying to find what might be causing it... only thing I found is related to the rst pin but since it's been working for you it can't be that!

bphermansson commented 5 years ago

Maybe try another software to see if it's a hardware or software problem? Like this: https://github.com/bbx10/nanohab

Naesstrom commented 5 years ago

yup, that seems to be initializing the radio

RFM69 WiFi Gateway
External System
*WM: 
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result: 
*WM: 3
*WM: IP Address:
*WM: 192.168.1.201
connected
*WM: freeing allocated params!
MDNS responder started
Connect to http://rfm69gw1.local or http://192.168.1.201

Listening at 868 86 MHz
Attempting MQTT connection...failed, rc=-2 try again in 2 seconds

Having some problems with my mqtt atm. tough but thats unrelated.

Just a thought, I'm using a RFM69HCW and in the software you linked he differs between them for some reason with radio.setHighPower(); // Only for RFM69HCW & HW! can that be something?

Sorry for being such a PITA btw

bphermansson commented 5 years ago

Might be, try to comment that line?

Naesstrom commented 5 years ago

Not sure I follow what you mean right now, this software that you linked https://github.com/bbx10/nanohab managed to initialize the radio- The part with radio.setHighPower is from that git and not yours. Do you mean I should comment that out from the above mentioned firmware and see if it still initializes the radio?

Naesstrom commented 5 years ago

After switching mosi/miso I got it booting up atleast... D6 --> MOSI and D7 --> MISO Can't really understand why since according to all the sheets I can read it shouldn't work this way... dsc_0548

Compiled at:Nov  8 2018 16:43:01
Debug on
Vcc=2928
Attempting MQTT connection...Connected to Mqtt broker as EspSparsnasGateway
Stored data: 
There are no stored frequency, using default value
There are no stored senderid, using default value
Senderid: 570631
Frequency: 868000000
61.04
Over The Air programming enabled, port: EspSparsnasGateway
Ready
IP address: 192.168.1.201
EspSparsnasGateway @ IP:192.168.1.201 SSID: Katrinelund
In initialize, frequency = 868100000
Adjusted freq: 14222950
61.04
RFM69 init done
Radio initialized.
Listening on 1023999936hz. Done in setup.
Freland commented 5 years ago

After switching mosi/miso I got it booting up atleast... D6 --> MOSI and D7 --> MISO Can't really understand why since according to all the sheets I can read it shouldn't work this way... dsc_0548

Compiled at:Nov  8 2018 16:43:01
Debug on
Vcc=2928
Attempting MQTT connection...Connected to Mqtt broker as EspSparsnasGateway
Stored data: 
There are no stored frequency, using default value
There are no stored senderid, using default value
Senderid: 570631
Frequency: 868000000
61.04
Over The Air programming enabled, port: EspSparsnasGateway
Ready
IP address: 192.168.1.201
EspSparsnasGateway @ IP:192.168.1.201 SSID: Katrinelund
In initialize, frequency = 868100000
Adjusted freq: 14222950
61.04
RFM69 init done
Radio initialized.
Listening on 1023999936hz. Done in setup.

Seems like it is exactly the same issue I had when I tried getting it up and running a while back ago (https://github.com/bphermansson/EspSparsnasGateway/issues/20 )

Naesstrom commented 5 years ago

hehe, ja det var ditt förslag i elektronikforumet som gav mig iden att testa att switcha plats på dom! Har du någonsin fått det att fungera @Freland

Naesstrom commented 5 years ago

Efter att ha diskuterat på FB, granskat kopplingsscheman etc. har jag en ny fundering... Enligt sommarlov's skiss så skall ju NSS kopplas till GPIO15 och det skriver @bphermansson i sin schematic!

Kollar jag däremot på Adafruits egna inkopplingsschema för RFM69HCW så har dom ingen koppling till EN då den automatiskt är på men däremot från samma GPIO till CS adafruit_products_rfm69_bb

Naesstrom commented 5 years ago

Typ såhär: esp_sparsnas_schem2

Naesstrom commented 5 years ago

I'll just continue add my comments, and for some reason return to english... Tried connecting the cables with D8 going to CS, even tried adding a 10KOhm between GND and D8 but when I have the tha cables correctly connected _(MOSI=MOSI, MISO=MISO) I just keep getting

Failed on waiting for ModeReady()
Unable to initialize the radio. Exiting.

I really can't grasp what I'm doing wrong here compared with what the rest have done to get it working, the NodeMCU shouldn't matter so what's left is the RFM69HCW... tried 2 of them now...

kalj commented 5 years ago

Today I hooked up my version of the circuit and after some hassle (#24) managed to get the code running. I can confirm all of your observations @Naesstrom:

  1. The RFM is only enabled if the MOSI/MISO connections are swapped.
  2. The frequency ends up wrong.
  3. The nanohab code manages to connect to the RFM, but fails at connecting to the MQTT.

I will try to look into this a bit further.

kalj commented 5 years ago

The problems seem to have been due to the Adafruit RFM69HCW BoB requiring the RST pin to be wired to GND. In fact, swapping the MISO/MOSI connections did not make it setup successfully at all, we just didn't check. The 'wrong frequency' was due to simply reading 0xFF for any registers, and 0xFFFFFF*FSTEP = 16777215*61.03515625 = 1023999938.96. This can probably be closed.

Please add to the README that the Adafruit BoB suggested requires the RST to be wired to GND.

dogmatic69 commented 5 years ago

RST - this is the Reset pin for the radio. It's pulled high by default. Pull down to ground to put it into reset

Seems that you should pull it down to reset.

Naesstrom commented 5 years ago

Hmm, then it should be done in the code then... I'm running mine now with gnd connected to it and it seems to be running fine

dogmatic69 commented 5 years ago

I'm going to go ahead and close this issue as the code fixes are now in and the other part seems to be a hookup issue. If you still got an error open a new ticket for it.