1technophile / OpenMQTTGateway

MQTT gateway for ESP8266 or ESP32 with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility & LoRa.
https://docs.openmqttgateway.com
GNU General Public License v3.0
3.55k stars 782 forks source link

[FEATURE REQUEST] Support decoder and parser for IKEA Sparsnas electricity meter? #165

Open Hedda opened 6 years ago

Hedda commented 6 years ago

Would it be possible to add this decoder for IKEA Sparsnäs (Ikea Sparnas electricity meter) to OpenMQTTGateway?

@bphermansson already has an existing similar project that does this with ESP8266 & RFM69:

https://github.com/bphermansson/EspSparsnasGateway

Some more information and links are posted here which I copy below:

http://www.letscontrolit.com/forum/viewtopic.php?f=10&t=3726

+1 request for IKEA Sparsnäs (Ikea Sparsnas) electricity meter with wireless display

http://www.ikea.com/se/sv/catalog/products/90292645/

At least in Sweden these are often on sale every so often with a large rebate via IKEA FAMILY and as such they can also be found relativly cheap from rebate scalpers on eBay (and its Tradera action-site in Sweden) following closely aften a sale.

http://www.ikea.com/se/sv/manuals/sparsnas-energidisplay__AA-1201480-1.pdf

"[i]SPARSNÄS energy display assists you to monitor the total usage of electricity in your home. The energy display consists of a transmitter and a display. The transmitter, which you attach to your electricity meter, continuously registers the usage of electricity and transfers the data wireless to the display. Place the display where it becomes a natural part of daily life in your home"

Again, @strigeus created the original an open source RTL-SDR decoder and parser for it:

https://github.com/strigeus/sparsnas_decoder

"SPARSNÄS uses a CC1101 chip configured for GFSK modulation at 868MHz. The two FSK symbol frequencies once downconverted to baseband are roughly 67kHz and 105kHz. (EDIT: It seems like with a different RTL-SDR the baseband frequencies are 12.5khz and 50khz. Maybe my first RTL-SDR was inaccurate). The packet length is 18 bytes, including the length byte, and a 16-bit CRC is appended to the end. The CC1101 sync word is 0xD201. The packet payload byte 5 to 17 are encrypted using a key derived from the sender device's ID. The encryption key is a repeating XOR key"

@tubalainen also has a fork of the above RTL-SDR project which convert and output as JSON to be used to pipe data to MQTT broker:

https://github.com/tubalainen/sparsnas_decoder

@Naesstrom in addition made a node-red flow to pipe/transfer from Sparsnas MQTT data script to InfluxDB for diplaying in for example Grafana. This uses the mqtt script from @tubalainen found here and splits up the json string to each value and puts it in a influxdb database.

https://github.com/Naesstrom/sparsnas_mqtt_nodered_influxdb

"The packet data is encrypted using your sender's ID. The sender ID is the last 6 digits of the serial number located under the battery."

"A BIG thanks to the https://www.facebook.com/groups/SHgruppen on Facebook"

@kodarn also has very detailed information how to decode and record the radio transmission from Sparnas transmitter:

https://github.com/kodarn/Sparsnas

Hedda commented 6 years ago

Here is also code projects to emulate an electricity meter to to send a signal to Sparnas wireless display:

https://github.com/MagnusThome/sparsnas-esp8266-01

https://github.com/MagnusThome/sparnas-raspberry

posicat commented 6 years ago

I did some research over lunch on how the IKEA Sparnas works. It reads an LED on the power-meter that blinks every time a specific number of watt hours are used.

It would be far cheaper to build in functionality to OpenMQTTGateway that could read the LED pulses than to worry about interfacing to the Sparnas. I hope to try experimenting with my own meter this weekend. However for people who already have a Sparnas or are thinking of getting one, it would be nice to have code to read it.

Hedda commented 6 years ago

@posicat cheaper maybe but not userfriendly to those who already own an Ikea Sparnäs & have it installed.

Sparnäs cheap as both transmitter & receiving display are 99 Swedish krona ~ $9(US) on sale in Sweden.

Hedda commented 6 years ago

FYI; here are more detailed information information on how exactly Sparnäs work with power-meters :

https://github.com/kodarn/Sparsnas

@kodarn include a "LedBlinkerHelperToo" to emulate power-meter to help develop without Sparnäs.

@MagnusThome have also created similar LED blinkers for for it to do send a value to Sparnäs display, ex:

https://github.com/MagnusThome/sparsnas-esp8266-01 https://github.com/MagnusThome/sparnas-raspberry

This and other projects for the Sparnäs transmitter and the receiving display in this Swedish forum thread:

http://elektronikforumet.com/forum/viewtopic.php?f=2&t=85006

I think that this hardware is very interesting to people because its really cheap and profesionally buildt.

posicat commented 6 years ago

@Hedda I pointed out that we could build a similar interface easily just for those interested in monitoring their meters, that the Ikea Sparsnas wasn't the only option. Especially for people like me in the US who's Ikea sadly doesn't sell them.

If you have one and are enjoying it, absolutely keep using it and add support. At the same time the code to support the Sparsnas could include code to use a sensor directly. Then both Sparsnas and Makers could get their results in the exact same format.

1technophile commented 1 year ago

@NorthernMan54 could this sensor using FSK (compatible rtl_433) be read with OMG your library and a CC1101?