LightwaveRF Arduino library

There is a first version of my LightwaveRF library on Github.

It sends and receive 10-byte LightwaveRF 434MHz messages. I have successfully used it to switch sockets on and off and to detect button presses on a remote control and to detect windows and door switches opening and closing.

I am using it with the Cool components 434Mhz transmitter and receiver.

I have tested it with an Arduino Uno and a JeeLink.

Advertisements
This entry was posted in Arduino, Electronics, Home automation. Bookmark the permalink.

103 Responses to LightwaveRF Arduino library

  1. That’s nice, just started working on my own arduino code just to talk to the wifi link, but this is way ahead. Good work.

    • Geek Grandad says:

      I have not bought a wifi link, and do not want to. I am trying to integrate devices with different wireless protocols and do not want to have an equivalent of the wifi link for each of them. Direct control via the RF protocol is much more convenient.

  2. mcmadhatter says:

    I have an example .ino file of using the lightwave wifi link with an arduino.

    http://pastebin.com/azZqPpXh

    It doesn’t modify/use your lightwaverf.c.h , but just the standard arduino udp class. You are welcome to add it as an example .ino file in your LightwaveRF library. Then all lightwave rf protocols are supported by your library.

    Thanks for sharing the 433Mhz library by the way, it is very useful, and your blog is most informative.

    • I have written some code that relies on the wifilink here https://github.com/pauly/robot-butler – I am controlling the arduino over the web too though, it accepts a get request and responds with some json.

      I’m getting the extra hardware from cool components as soon as I have the time though, not relying on the wifilink sounds very exciting.

      Hey Geek Grandad, you can mix and match nicely with some cheaper hardware like the older easyhome plugs then, if you can find them. I saw them 3 for £15 in B&Q just before christmas. The LightwaveRF sockets are the nicest looking though.

      • Geek Grandad says:

        I do not have any Home Easy plugs, so I have not been able to test them. I did buy some at a similar price fro Maplin for my mother, but did not investigate the protocol before I gave them to her. I may look into the Home Easy products some time. I think others have hacked the protocol.

        As I do not have a Wifi Link, I cannot try the code that uses that. I don’t think it would be a good idea to add that capability to my library, particularly because I cannot test it. I will add a comment to my code saying that use of the Wifi Link UDP protocol is another way to control LightWaveRF devices and I will link to your code.

        I m now working more with the RFM12B modules rather than the Cool Components one (which I think are from Sparkfun). However, the RFM12B is harder to use for LightWaveRF, as you have to swap a capacitor on the module to get reliable OOK signalling. As I don’t know if the RFM12B works with LightWaveRF, I think I will stick with the Cool Components transmitter and receiver for LightWaveRF devices. Most designs also seem to use the 868MHz version of the RFM12B.

        I will have this issue for my experiments with Current Cost/EDF Indvidual Appliance Monitors. The code by Jack Kelly uses 434MHz versions of the RFM12B for this. I might try converting his code to use the Cool Components devices.

    • Geek Grandad says:

      @mcmadhatter: See my answer to Paul Clarke. If you plan to put your code somewhere where it can be linked to, I will add a link to it from my library – possibly in a README file. I am not keen on adding your code as an example as I cannot test it, and it might become out of date.

  3. Marcus says:

    Thanks for publishing that. I had been using the Maplin plugs (which took many hours of playing to get going with the arduino and Pi), but as they aren’t required to be paired with the transmitter – anyone on the correct channel and id can turn them on/off which is no good securitywise. So Lightwaverf was the next option. Since I don’t want to use the wifi link but drive it directly (arduino now, Pi later) your code has undoubtedly saved me many hours of stress :). 30 minutes after unpacking the lw plugs I could turn them on and off using an arduino, your code and a 433 MHz tx. That’s definitely a record for me…

    • Geek Grandad says:

      Glad it was useful. Which transmitter and receiver are you using? I think the receiver code needs some improvement. It detects the remote control button presses fairly reliably for me, but it is not very good for the window/door switches. It may be a problem with the switches.

      • Marcus says:

        The transmitter is a bit of a hack – the Maplin remote (as supplied with the rf plugs) has been laid out in such a way that you can can cut the pcb in two if you are careful: see http://tinyurl.com/afd3zpn . Replace one resistor and you have a handy stand alone tx section. Originally the idea was to use this tx as a stop gap until a suitable tx / rx pair was bought, however it looks like it works very well with the Lightwaverf plugs – strangely it seems to have a better range than it had with the Maplin ones – so it may well stay for the moment.

        The current project is a bit of a hybrid between the existing conventional burglar alarm and an arduino (the HAH/Livebox project might be tacked on the end for good measure). Existing window and door switches are currently wired directly into the alarm system, the arduino is triggered when the alarm is set, turning on various lights etc through lightwave. So at the moment no receiver is used on the arduino side, however as things progress I was going to try the Sparkfun one and see how well it works.

  4. Benjie says:

    Thanks very much for this post – it greatly helped me solve my own LightwaveRF decoding problems – I was so close, and you shed that final bit of light! By the way, the signal doesn’t have to start with 0xf6 to be valid – e.g. the “all off” command on one of my remotes sends a different initial byte (and there are other modes too that also send a different initial byte, but I haven’t documented them yet). I use the longer period of time before the repeats to detect that the signal is relevant – you should find it’s around 10,250 microseconds – and I check that each duration is of an expected length. You can read about my findings (and find links to my code) here: http://www.benjiegillam.com/2013/02/reverse-engineering-lightwaverf/

    • Geek Grandad says:

      Thanks for the information, You are the second person who has told me that the first byte does not have to be 0xf6. It would be useful if we could combine our code to produce a better library. I am currently not detecting signals from the LightwaveRF magnetic window/door switches reliably. I don’t know if is my code, the switches, or the receiver that is the problem.

      • Benjie says:

        I fully understand the protocol now, there’s just some commands I haven’t coded yet. But I can do: on, off, dim to particular level, and 5 mood settings. Here’s an update on my progress: http://www.benjiegillam.com/2013/02/lightwaverf-rf-protocol/

      • johnnylightwave says:

        @Benjie, Have a look here http://www.dbzoo.com/livebox/universalrf#lightwaverf_dimmable_cfl_bulb . I used ElmuSoft – Parallel Port – 17 Channel – Logic Analyzer (google it its free, uses your parallel port and is very handy) and directly connected to the inside of one of my remotes, JSJSW100BLK, i get traces like the attached img.

        These can be decoded by hand using :- High for 270uS Low 260uS = encoded as ‘0’ , High for 270uS Low 1300uS = encoded as ‘1’ (My timings for these were measured using the analyzer although the http://www.dbzoo.com/livebox/universalrf#lightwaverf_dimmable_cfl_bulb link suggests values of 300uSHigh/250uSLow for a ‘0’ and 300uSHigh/1260uSLow for a ‘1’)

        Here is a complete trace for pressing “button 1 bank C on” https://googledrive.com/host/0B9sUqE1G8LkfMjRfZmtQM0xpaTA/Analyzer_0040.htm note there is a very small pulse then a gap 80mS then the first bunch of ten bytes but the start of those is corrupt but then settles down and produces 5 or 6 good frames of 10 bytes each (Ignore the dark red bits in the traces as thats when the cpu Context Switches away to do other things and so the parallel port readings are inaccurate) ‘Status 0’ is the parallel port line i’m using for input to the logic analyzer software.

        My son also wrote an Arduino program to capture the output stream using interrupts an display it see other attached image although this is very much a work in progress.

        Paul Cooper’s info on http://www.dbzoo.com/livebox/universalrf#lightwaverf_dimmable_cfl_bulb is slightly incorrect as he shows the remote ID as six bytes at the end of the stream but i have only observed the last 5 as ID bytes the 6th from the end changes when you press the mood button or the all off button.

        I also think that your statement that “each of these only ever take one of 16 values” is not strictly true as my captures show different, also your captures show you decoding many more ‘1’s than ‘0’s whereas mine decode as more ‘0’s than ‘1’s … a ‘1’ on my capture is when the remote actually transmits 433MHz and a ‘0’ is when it is quiet commonly known as on off keying (OOK), are you sure you havn’t inverted your decoding.

        If you look at my trace and go through it by hand it does decode as 050A884D00B1050524 you need to use about the 5th trace down… minimal disruption / context switching.

        I have used my captures in my own Home Automation Hub to replicate the LightwaveRF commands transmitting exactly what i have captured and my bulbs and switches react as if it was a proper remote sending the commands.

      • Benjie says:

        @johnnylightwave Rather than decoding as “0” and “1”, try decoding as “1” and “10”. Suddenly everything makes much more sense, e.g. see the tables in this post: http://www.benjiegillam.com/2013/02/reverse-engineering-lightwaverf/

        (That post is followed up with details on the full protocol: http://www.benjiegillam.com/2013/02/lightwaverf-rf-protocol/ )

        I also used Arduino for precision timing using interrupts – you can compare my code with your son’s if you’re interested (apologies for the hacky nature, never had time to tidy it up…): https://github.com/benjie/rf-experiments/blob/03d07dd4469542d0fdfdcfd659136250c8324b91/signal_capture.ino (use this revision: the latest one sends but doesn’t receive, I’ve not combined the two yet…)

        There’ll be more to come when I get time to write about it again (and I’ll be fixing and tidying my code!).

  5. Great work on decoding the protocol.

    I’ve been trying out your libraries in order to construct a gateway that will allow me to control my lighting from my Android Tablet mostly with success.

    I have noticed though that I have no control over one of the dimmable CFL bulbs that Lightwave supply. It responds to the original remotes but not to any commands sent from the Arduino using lw_send. I also noticed that running a pair of Arduinos with send and receive code running that none of the sent commands are received and decoded by the receiving software. Original remote codes are fine. I wonder if there is a slight timing issue with the sending code that is causing this discrepancy.

    Anyway, thanks again for the great work in getting us all started with this.

    • Do you have more than 1 CFL bulb? I have a pair which are both programmed to the same remote code, and I cannot control them either. Have you made any progress getting this to work?

      • Slumberjack says:

        I did get the CFL to work. I found that there is a timing issue with the original lw_send method. My remote sockets didn’t seem to mind this but the CFL appears to be more picky.

        I compared the output from an original remote with the output from the Arduino code and although the pattern was the same the spacing of the pulses was slightly out.

        What I think is happening is when you send a “LOW” bit to the code the arduino ADC doesn’t have to switch the state from high to low so the output is too short.

        Adding a simple delay when sending a “LOW” bit solves the problem.

        Updated function is here:

        /**
        Transmit a 1 or 0 bit to a LightwaveRF device
        **/
        void lw_send_bit(byte b) {

        delayMicroseconds(25);
        digitalWrite(lw_tx_pin,b);
        delayMicroseconds(lw_bit_delay/2);
        digitalWrite(lw_tx_pin,LOW);
        delayMicroseconds(lw_bit_delay/2);
        if (b == LOW)
        {
        delayMicroseconds(300);
        }
        }

        I also changed the static declaration for lw_bit_delay at the top of the code.

        static const int lw_bit_delay = 560;

        I can’t remember what the original value was but I think that this is smaller.

        This has been working 100% since I installed it last month.

        Cheers

        Richard

      • I did get the CFL to work. I found that there is a timing issue with the original lw_send method. My remote sockets didn’t seem to mind this but the CFL appears to be more picky.

        I compared the output from an original remote with the output from the Arduino code and although the pattern was the same the spacing of the pulses was slightly out.

        What I think is happening is when you send a “LOW” bit to the code the arduino ADC doesn’t have to switch the state from high to low so the output is too short.

        Adding a simple delay when sending a “LOW” bit solves the problem.

        Updated function is here:

        /**
        Transmit a 1 or 0 bit to a LightwaveRF device
        **/
        void lw_send_bit(byte b) {

        delayMicroseconds(25);
        digitalWrite(lw_tx_pin,b);
        delayMicroseconds(lw_bit_delay/2);
        digitalWrite(lw_tx_pin,LOW);
        delayMicroseconds(lw_bit_delay/2);
        if (b == LOW)
        {
        delayMicroseconds(300);
        }
        }

        I also changed the static declaration for lw_bit_delay at the top of the code.

        static const int lw_bit_delay = 560;

        I can’t remember what the original value was but I think that this is smaller.

        This has been working 100% since I installed it last month.

        Cheers

        Richard

    • That’s great. Thanks for the input, I’ll give it a spin later.

      James

  6. Alex Tatham says:

    This is brilliant.

    I purchased the bits from Cool components. Put the parts on a breadboard and connected to an Arduino with jumper wires and in under an hour I had read the bytes from a few switches and got the Arduino turning lights on and off.

    Nice work and thanks so much for sharing.

  7. roger says:

    Just found your Lightwave RF libary
    lwsend and lwreceive load into ardunio OK
    How do I use them, is there a script to read the incomming data from the remote controller and then how do I send data to the ardunio.
    I am using Linux Ubuntu to talk to the Ardunio
    many thanks

    • Geek Grandad says:

      Have you looked at the examples? If you run the lwreceive example, and click on a remote, it will show you the 10 byte packet received. You can edit the lwsend example to send the data you have received. The last six bytes of the packet is the id of the remote control. You can use that value in the lwdim example to control lights. Let me know if it works for you. The library still needs some improvement.

      The examples use a 57600 bps serial connection to communicate with the Arduino. You can use this from the Arduino IDE or from any language or tool that supports serial connections.

      • roger says:

        Can I view the lwreceive using the ardunio serial monitor , if so how as I cant see anything.
        Tried using python script and ocassionaly I manage to see some data so I am happy that the hardware is OK.
        Is there a example python script
        thanks

    • Geek Grandad says:

      I don’t know why you don’t see any data in the Arduino serial monitor. Try add some Serial.println commands to the example to check that you are receiving data. Do you have the bit rate set to 57600 in the serial monitor?

      I do not have a python script, but any simple script using pyserial should work. I use Java to receive the data for my home automation system.

      It may be that your hardware + my library is not picking up packets very reliably. It has worked for some other people but I doubt in many people have used the library.

      • roger says:

        Problem solved all working
        I had all the hardware setup as I was sucessfully using Maplin remote sockets then I went over to Lightwave dimmer switch and double sockets. I am using a 4 inch piece of wire in the breadboard as an aerial. I was monitoring the signal on pin 2 with and oscilloscope and it apeared OK. When I move the Seimens transmitter to within 9 inches of the aerial wire bingo every thing works OK.
        On further testing the Maplin Tx works to the other end of the house (at least 12 mtrs ) but the Seimens hardly works in the next room (3 mtrs ) with the Seimens sockets and dimmer switch. Either I have a bad Tx (remote controller ) or they are not upto the mark, need to buy another Tx before saying too much.

    • Geek Grandad says:

      There could also be a problem with the receive code in my library. I have only used it with the remote close to the receiver and it does not work for LightwaveRF window/door switches that are further away. I am planning to look at it again some time to see if I can make it more reliable.

      • roger says:

        hi
        I have passed the remote controller codes from my python script into the Ardunio as a string. How do I convert the string that I now have in the Ardunio script into the byte on[] and byte off[].
        What I am trying to do is to create a file of all the remote controllers codes in my python script and select the required code and then pass it to the Ardunio.

  8. roger says:

    Hi
    Just tried your lwdimino which I have loaded into Ardunio
    Changed byte myid[] to the same as the last 6 that I use in your lwsend routine (which actually works ON & OFF) . Serial monitor shows setting level to (numbers upto 31 and restarts but nothing happens to the dimmer switch. Am I doing something wrong?
    Also how do I change the byte on & byte off to a string value in lwsend

    many thanks

    • Geek Grandad says:

      The problem might be the channel parameter to lw_cmd. That is set to 6 is the example as that was the “channel” on the LightwaveRF remote control that I was using. The channels are numbered from 0, so 0 is channel a1 and 6 is b3.

      You should pair your dimmer switch with the LightwaveRF remote and then set the channel parameter to the channel code for the button you used.

      I don’t understand your question about byte on and off. If you are saying you want to use a String rather than a byte array in lw_send, you will have to work out how to do that yourself. I am not an Arduino or C++ expert.

      • roger says:

        Thanks for your help
        The dimmer switch is paired an works with the remote control OK. I can also switch the the dimmer switch On & Off OK with lwsend OK. I have not yet got it to dim but will investigate further and let you know.
        What I am currently trying to do is to keep all the remote control codes in a file and then get python to send the required code to your lwsend sketch.

        Current Problem
        I can receive a string into your Ardunio sketch containing either F6 F6 F6 F6 6F ED 7E ED DE BB or 0xf6,0xf6,0xf6,0xf6,0x6f,0xed,0x7e,0xed,0xde,0xbb etc. or any other string no problem. All I need to do is convert my data to replace your pre-coded
        byte on[] = {0xf6,0xf6,0xf6,0xee,0x6f,0xeb,0xbe,0xed,0xb7,0x7b}; with my own data but I can’t figure out the correct syntax as I am new to C++.
        Many thanks

  9. roger says:

    Hi
    Thanks for your help & library
    Update – Now Got things working.
    Python script stores remote codes and sends the required string to Ardunio. Arduino decodes string and activates the lightwaveRf equipment. On / Off / Dim & mood all working OK.
    Questions
    1 Can I set the mood using your library?
    2 Have you a protocol that you send to the Ardunio? If not would it be worth establishing one to make other peoples all compatable.
    3 Is it possible to read information coming from Lightwave units like Pir’s etc

    I understand that there is a central heating controller due out soon but I beleive it’s going to be on the 800 Mhz band.
    I am just going to order a LightwaeRf in line relay to control my blinds.
    Many thanks

    • Geek Grandad says:

      1. I have not tried setting moods, but it should work in lw_cmd by setting cmd to LW_MOOD.

      2, I currently send a single byte to the Arduino with 3 bits used for the channel and 5 for the level. I reserve the highest values for switching lights and sockets on and off. I currently only have 4 light switches and 5 sockets, so this is enough for me. I might look at a better protocol when I get more devices. Feel free to propose something.

      3. I expect the Pirs etc will work, but I don’t have any. I use Jeenode devices for motion detection. The heating stuff is 868Mhz, so that will not work.

      What motorised blinds do you have?

      • roger says:

        Hi
        The blinds are units which come as a roller tube with integeral 12 volt DC motor/ gear box with limit switches. You have to change the polarity to change direction and then the limit switch stops the motor. I bought them over a year ago now and and operating them at present with a rechargable battery. I intend to get some more soon.
        I dont have the details to hand but from memory I think they are German made by Becker or similar type name. There is a UK distributer in Burton on Trent because I remember picking them up. If you can’t locate them I will try and find the details. Worked well for over a year no problem, I bought some Dunn-Elm roller blinds and removed the material and fitted the material to the motor units. “easy”

        Just ordered a 3 channel relay (new product just comming onto the market) from LightwaveRf.com, waiting for delivery

  10. Rico (@rm83) says:

    Masive thanks for the code – I have this running on my Raspberry Pi and works really well 🙂

  11. thompsonson says:

    Hi Grandad,

    Thanks for sharing this, I’ve got a lightwaverf dimmer switch and an Arduino so I’m interested to see if I can get those to talk. How do you have the TX and rx components set up on the Arduino?

    Thanks,
    Matt

    • Geek Grandad says:

      Connecting the TX and RX is simple. The TX has 5v and ground connection, and data from digital port 3. The RX has 5v, ground and data to digital port 2. They both have a 17cm wire as aerial. I have them on a small prototype board in a box I bought from Maplin. . I cut a hole for the USB port. There are no other components. I used the documents on the Cool Components site. Let me know if you need more information. The transmitters and receivers are probably available on ebay but they are fairly cheap from Cool Components.

  12. Chaps, I have been monkeying around with ByeBye Standby, HomeEasy , RF transmitter/Rx 433 mhz modules and arduinos for a while, you should find these two modules work fine as well from Farnell.
    http://uk.farnell.com/jsp/search/productdetail.jsp?sku=1699486&_requestid=995811
    http://uk.farnell.com/jsp/search/productdetail.jsp?sku=1699488&_requestid=995976

    My blog is here with further details, including pin connections for those who need them.

    http://martgadget.blogspot.com

    HTH

  13. Steve says:

    Hi i got really excited when I saw your blog… THEN…. i tried uploading lwrecieve up to the arduino and got and error ISO C++ forbides declaration of lw_msg_len with no type… gutted. any ideas thanks

    • Geek Grandad says:

      What version of Arduino are you using and have you installed the library?

      • steve says:

        Thanks for the quick response.

        I am using the latest arduino software. I haven’t installed a library I didn’t realise I had to. Is the library with the rest of the files. I am a noob to all this. I have managed to decode the maplin home easy sockets with a simple script but the same script produces nothing for the lightwaverf.

      • Geek Grandad says:

        With recent version of Arduino, you install libraries by going to Sketch > Import Library … > Add Library and then selecting the downloaded zip file.

  14. Steve says:

    When i try and import https://github.com/lawrie/LightwaveRF it says that the zip file does not contain a library?

    • Geek Grandad says:

      You will need to extract the zip file, rename LightwaveRF-Master as LightwaveRF, and then zip it to LightwaveRF.zip. You can then import that.

      • steve says:

        Thanks I will give it a go

      • Steve says:

        I still get the same error, i am using Arduino 1.0.5-r2

        java.io.IOException: Zip doesn’t contain a library
        at processing.app.Base.handleAddLibrary(Base.java:2408)
        at processing.app.Base$4.actionPerformed(Base.java:955)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
        at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1225)
        at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1266)
        at java.awt.Component.processMouseEvent(Component.java:6263)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:6028)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4630)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
        at java.awt.Container.dispatchEventImpl(Container.java:2085)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

      • Geek Grandad says:

        It worked when I tried it. There must be a problem with the zip file you created. If you open the zip file it should contain a folder called LightwaveRF, and that should contain a folder called examples, and LightwaveRF.cpp, LightwaveRF.h, and a few other files.

  15. Steve says:

    k I will try again, what zip utility are you using i am using winrar (but creating a zip) yes all those files were there. Am i correct in thinking you only have one version on GITHUB?

  16. Steve says:

    OK we are one step further I have managed to import the library and upload LWDECODE to the arduino. Should I be able to see decodes in the serial monitor when i press the remote, because there is no output at all. I have serial monitor set to 57600 and i have my RF receiver on pin 2 of the arduino.. Thanks for all your help by the way.

  17. Steve says:

    I am using a generic 433Mhz receiver like this http://www.ebay.co.uk/itm/KDQ5-NEW-1PCS-433MHZ-RF-TRANSMITTER-AND-RECEIVER-LINK-KIT-FOR-ARDUINO-SCA-1710-/300970643268?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item46133f8f44

    It works Ok with the maplin homeeasy, and the transmitter portion transmits to the homeeasy as well. i have put a few debug statements in your code and see that it just loops round lw_rx_wait() (obviously just waiting)

    • Geek Grandad says:

      They are not quite the same as the ones I use, but I don’t see any reason why they shouldn’t work. I have just bought a couple as they are so cheap, but they will take a while to arrive from China. I don’t know what to suggest other than putting some diagnostics in the code of the library. The library will be in My Documents/Arduino/libraries. You can just edit and save the code in LightwaveRF.cpp or Lightwave.h and recompile the sketch.

      • Steve says:

        Just bought a new battery in case that was the problem, but still no joy. Just one question will your sketch only work with lightwave remotes, by that i mean if i used a homeeasy one, will i receive anything in the serial monitor, even if its only junk.

  18. Steve says:

    am i correct in thinking that the receiver goes to pin 2 of the arduino

    • Geek Grandad says:

      Yes. I accepted a push request on github recently that made the pin numbers selectable, and I don’t think I have tried the library since then, but it looks OK and the default pin is still 2 for receive and 3 for transmit. I will try the latest version of the library with the latest version of Arduino and the decode example, tomorrow, to check that it is still all working.

      • steve says:

        Much appreciated

      • Geek Grandad says:

        I tried the lwdecode example with the latest library and Arduino IDE, and it worked fine. I got a series of:

        Level = 64
        Channel = 0
        Command = Off
        Id = 6F EB EE ED 7D DE

        So, I don’t know what your problem is, unless it is something about the receivers. I will try them when mine arrive.

        Is your remote close to the receiver? Are you certain the remote is working? Have you checked the wiring to the Arduino?

      • steve says:

        Hi
        Yes I think the setup is ok I can receive codes from a homeeasy transmitter and can also receive homeeasy codes when auto transmitted from another arduino. I don’t know if the device is faulty only just bought it and don’t have any other lightwave devices yet. Forgive my ignorance but what will I do with the codes that your app gives me. With the homeeasy I get digital tri state and raw. I can switch the homeeasy using digital or tri state. I presumed your sketch would give the same info. Maybe I need a bit more education in this area.

      • Geek Grandad says:

        What LighwaveRF device do you have? Is it a remote that you are trying to receive codes from?

        The way I use the LightwaveRF library, is that I first pair the device with a remote. I then use the library to emulate the remote. You need the 6 code ID of the remote for this, which lwdecode gives you.

        The library then lets you switch devices on and off and dim devices that support it. It should also support moods, but I have not tried that. You can also receive the codes from a remote so that you can detect when a device has been switched on and off using a remote, rather than the library, and keep track of its status. Unfortunately, LightwaveRF devices do not let you track the status when the physical switch is used.

        If you are using LightwaveRF window switches, you can also detect when windows (or doors) are opened.

      • steve says:

        Should your app be also able to mimic the socket locker. Maybe i have a faulty item however i also don’t get anything from the socket locker. I will install a socket tonight and try to pair them

      • Geek Grandad says:

        I have never used the socket locker, just the 16-way remotes, but I just looked at the user guide for the socket locker, and I believe it should work. If you have not used it with a socket yet, have you removed the plastic film battery isolator?

        The user guide for the socket locker does not seem to tell you about pairing which is odd, but I assume it is done in the normal way. You don’t need to pair for lwdecode to work.

        Does the socket locker work with just one socket?

      • steve says:

        I hope the locker works with all sockets but haven’t tried yet. Regarding the plastic isolator should that have been on the 16 way remote. I didn’t actually see one on it and when I press the buttons the blue led lights up so I suppose it has been removed. Which would them suggest that someone has played with the remote before me.

  19. Steve says:

    I have come to a complete blank trying to get the decoder working. I wonder what 433mhz receiver you are using. my current receiver seems to work ok however to eliminate it i thought I would get the same as you as long as it doesn’t cost an arm and a leg

    • Geek Grandad says:

      This is the receiver I am using – http://www.coolcomponents.co.uk/rf-link-receiver-4800bps-434mhz.html. It links to the corresponding transmitter.

      I have bought both a LightwaveRF socket locker and the same transmitters and receivers that you are using, and will let you know how they work for me when they arrive.

      Being able to lock my LightwaveRF sockets might be quite useful for some of them.

    • Geek Grandad says:

      My socket locker arrived quickly from Amazon. I tried it and it does not work for me either. So the problem is probably the device rather than your transmitters and receivers. I will investigate.

      I do not really understand how it is supposed to be used, as it has no way to to select a channel like on the 16-way remote. So it looks like you either have to use it on a single socket, or you have to keep pairing and unpairing it, or you can use it on multiple sockets as long as you want to turn them all on or off (or lock/unlock them) at the same time.

      • steve says:

        There was a post somewhere that said they could be used on infinite sockets. Think I will ring lightwave and ask

      • Geek Grandad says:

        The problem with my Socket Locker was the battery. It would not pair with a socket so I bought a new battery for it, and it then paired. It now works the lwdecode.

        I suspect that may be your problem. These devices are obviously being sold with run down batteries. Mine did not have a battery isolator either, despite what the instruction manual said.

        The old battery lit the amber LED and registered over 3 volts, but must not have had enough power to work the radio,

      • steve says:

        I think the battery is ok in the remote as it flashes blue and stays on for a couple of seconds. I did however return the socket locker but will get another one. Would you happen to have a schematic of how you configured yours or is it as simple as gnd to gnd vcc to vcc and data to pin 2 no resistors or other other wiring

      • Geek Grandad says:

        If you are only going to use the socket locker to lock sockets (which is all I want it for)., then it is probably reasonable to pair it with the socket and then unpair it.

        I have some sockets that I want on all the time, and don’t want children (or adults) switching them on or off with the physical switches.

        The device does not look much good for switching sockets on and off.

        I need to update my library to support the lock functions, and then I won’t need the device at all.

      • Geek Grandad says:

        Yes, the wiring is as simple as you say, It should be the Arduino 5v power to Vcc. Are you saying that you have a remote as well as the socket locker, and that the remote also does not work with lwdecode?

      • steve says:

        Yes neither work. But I have a homeeasy which works obviously with a different sketch

  20. Steve says:

    Just bought a new battery in case that was the problem, but still no joy. Just one question will your sketch only work with lightwave remotes, by that i mean if i used a homeeasy one, will i receive anything in the serial monitor, even if its only junk.

    • Geek Grandad says:

      I have never tried it with HomeEasy and am not sure what the protocol is for that, but I very much doubt that you would see anything, as anything with the wrong bit lengths or the wrong bit pattern is ignored.

  21. Paul says:

    Has the protocol changed at all? i seem to get a start byte that is different to all the others. on bytes 2-10 i get a short pulse 110us followed by 330us. wher as all the normal 1 are 240us on and 330 off.

  22. Steve says:

    hi. i bought the 433 receiver that you use, and everything is now working, what is strange is that the Chinese transmitter i bought which comes with the receiver (that you bought and doesnt work) does work if that makes sense. Also do you have any codes for the socket locker?

    • Geek Grandad says:

      I didn’t quite understand your comment, but it is a good that you have it working. It sounds like the receivers and transmitters I bought on ebay won’t be much use, but they were very cheap and I can investigate what the problem is or use them for other things. The library should support the socket locker for turning a socket on and off, but I have not investigated the protocol for locking and unlocking yet. I will probably do it in the next few days.

  23. Steve says:

    What I was trying to say was the Ebay receiver didnt work, however the transmitter that comes with it does work and works very well. Am I right in thinking that you can only send on pin 10, I tried pin4 and it didnt work.

    • Geek Grandad says:

      The default transmit pin is 3.

      • Geek Grandad says:

        I have added a lwlock example program to the library, to emulate what the Socket Locker does. The library already supported it, but I have added a constant LW_LOCK which is the value used for the command. It seems to use the level bytes for bit significant values rather tha a level value, so the code passes rather strange values for the level parameter. This should allow you to lock any socket without buying a Socket Locker.

  24. steve says:

    That’s great I will take a look is it on git hub. This electronics stuff is starting to fry my brain. Been messing with various circuits for the last few weeks and have just been introduced to audacity. Think I now have enough components to start a mini Farnell.

  25. BrianC says:

    I’m new to this kit but have read your forum with interest. My requirement is simply to control 3 on/off sockets using an RPi and the RF module you describe. Is there any need to use the remote to initiate the pairing? Couldn’t one simply ‘make up’ a remote ID and then pair with the RPi?

    • Geek Grandad says:

      Yes, I think you could, but I am not sure whether all possible IDs are valid.

      • BrianC says:

        Thanks for the swift response; I take your point, I assumed the ID’s were akin to MAC addresses. Maybe we could collate known ID’s to try to establish any pattern and thus create list of valid codes for people to use without having to do the learning phase? This would also necessitate including a ‘pair’ function in the code but from what I read this is just a long send string?

        Do you by any chance have code that would run on the RPI to stop me reinventing the wheel?

      • Geek Grandad says:

        Its probably simpler than this. You can probably use any ID that has valid values for the nibbles – I just haven’t tried. I don’t think you need a pair function as all you have to do is put the device in pair mode, and then switch the device on from the code. It should then pair. I have not done any of this on the Raspberry Pi lately, so don’t have any code for that.

        Which RF module are you planning to use with the Raspberry Pi?

        I have an RFM12Pi module that I have used with the Raspberry Pi, but that does not work with my library. However, someone commenting on this site did manage to switch LightwaveRF modules using the 434Mhz version of that radio,

        Connecting the simpler (Cool Components/Sparkfun/ebay) 434Mhz radios that I use with my Arduino library directly to a Raspberry Pi may have some 3.3v/5v level conversion issues. Raspberry Pi with a serial connection to an Arduino would work.

      • BrianC says:

        You may be right with the pairing thing. I am using the 433 modules from cool components,hadn’t thought of the 3v3/5v0 issue as I assumed they were 0.3/0.7Vdd, however a simple level shifter/buffer would fix that. I am currently porting your code into C for the RPi to run directly from the wiringpi library

  26. jonl101 says:

    Hi

    Did you ever have any luck with the cheap ebay 433Mhz receivers? Im having no luck getting mine to work. Ive ordered some more expensive ones from cool components so hopefully i will have more luck with them

    • Geek Grandad says:

      I tried the receiver and it did not work. I have not investigated why it doesn’t work.

      • BrianC says:

        I had no success either.

        On an unrelated topic… I have some python code that runs using the RPi.GPIO library and sets up some interrupt driven events on selected GPIO ports. This calls some C code to control my lightwave devices. However executing the C code (which calls WwiringPiSetupGpio()) destroys the interrupt events so they no longer work. Is there a way to get them to play nicely together or do I have to re-setup the interrupts after calling the C code? (Other than writing it all in C!)

  27. Svarven says:

    Do anyone of you have an example how to get a switch on one Arduino to light up a LED on another Arduino with this 433 mhz transmitter/receiver. I have figure out to get the sending between the two, but not succeed with an switch on one and LED on the other.. I’m using wirtualwire library

  28. Ryan. says:

    Hi Geek Grandad,

    Another big thank you for your work on this, all working well with little hassle. I too tried a cheap eBay RX module with no luck, but found the cool components device worked without a problem.

    I don’t suppose anybody knows what the command for ‘stop’ is? I have the inline relay that accepts on, off and stop – unfortunately I don’t have the special remote with the stop key to decode. Any clues?

    Cheers,
    Ryan.

  29. Roger says:

    Hi
    Have you used lightwaverf InLine Relay
    I can switch it On & Off but dont know how to use the stop function.
    Any help would be aprecited
    many thanks

    • Ryan. says:

      Hi Roger,

      You are in luck. In the end I ‘borrowed’ the special remote and got the codes from it. The remote works a little differently from the other remotes, but the inline relay understands it just the same and I have confirmed it working.

      These are the commands that I received from it:

      UP (ON) – EE 6F F6 BE 6F DE DD DE 77 7E
      Level = 31
      Channel = 0
      Command = 7
      Id = 6F DE DD DE 77 7E

      DOWN (OFF) – F6 F6 F6 BE 6F DE DD DE 77 7E
      Level = 0
      Channel = 0
      Command = 7
      Id = 6F DE DD DE 77 7E

      STOP – 7D F6 F6 BE 6F DE DD DE 77 7E
      Level = 192
      Channel = 0
      Command = 7
      Id = 6F DE DD DE 77 7E

      As you can see, all of the buttons use the same subunit and command (3rd and 4th nibble) but change the parameter (1st two nibbles). The decoding library doesn’t handle this very well, but if you just send the commands as you see them here, I don’t see why it wouldn’t just work for you 🙂

      Ryan.

  30. Roger says:

    Hi Ryan
    Thanks for the Info – Will try it in the next few days
    Roger

  31. Roger says:

    Hi Ryan
    I have got my inline relay working using the following
    Relay Examples
    byte on[] = {0xee,0xf6,0xeb,0xee,0x6f,0xed,0x7e,0xed,0xde,0xbb};
    byte off[] = {0xf6,0xf6,0xeb,0xbe,0x6f,0xed,0x7e,0xed,0xde,0xbb};
    byte stop[] = {0x7d,0xf6,0xeb,0xbe,0x6f,0xed,0x7e,0xed,0xde,0xbb};
    Many Thanks

  32. Roger says:

    Range Extender
    Has anybody made a range extender?

    I belive there are some Ardunios available with the Tx & Rx fitted and if so could these be used as range extenders.

  33. Pembo says:

    So there’s something amiss with the new megaman JSJSLW400 series dimmers that I’ve bought.
    They respond to on and dim commands, but not the off command.

    I’ve raised a ticket to ask if the protocol has changed slightly but I’ve had no response just yet though it’s only been a day.

  34. pembo says:

    Megaman responded saying protocol hadn’t changed, but there must be something different as the 200 series dimmers work, versus the new 400 series.

    I tried pairing the 400 series to an older mood switch and sure enough this does work, so I guess it might be just timing of the pulses that has been tightened up. I’ve asked if they can share any info on this.
    It’s odd that it only affects off, where as on and dim commands all work fine.

    I’ll wait and see how they respond and play around a little more!

  35. Ryan says:

    I appreciate i’m digging up an oooold thread here, but I’ve just upgraded to 400 series dimmers myself and had the same problem as pembo. Previously i’d send 0 as my parameter (0xF6F6 encoded) when sending an off command, it worked fine for 200 series but not 400 series dimmers. Some other literature I had read suggested sending the parameter 64 instead (0xDEF6 encoded) with the same off command, I can confirm that this works 🙂

    • Glenn says:

      Hi Ryan,

      I have fumbled my way through getting my Lightwaverf setup working, but i’m still not clear on what I have been doing (lots of googling and trial and error!!)… Can you explain where I change the parameter to get the 400 series dimmer working? I can turn it on but not off.

  36. pembo says:

    Ryan – you’re a star 🙂
    I’ going to give this a try

  37. Ross says:

    is there any explanation of the hardware set for this. What pins are used for tx and rx.

  38. Pingback: Using LightwaveRF switches to control other stuff – Automate Everything

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s