Picaxe control of RF remote device?

I just installed a motorised roller blind in my house which is controlled by a RF (433.92mhz) remote, it occurred to me that it would quite nice to have the blind close when light level falls below a certain level, and have it open when light gets above a set level, so in effect close at dusk and open at dawn. So I then thought that maybe I could use a picaxe 08m2 with a LDR to detect the light level and some kind of RF transmitter, my first thought was to buy a learning RF remote and jerry-rig it to the picaxe but I then saw the RFA001 kit and the AXE213 kit - however I am not sure how I would learn the included remote to the picaxe or even if that is feasible? Has anyone done anything similar? I'd be interested to hear if any similar projects or any thoughts on the idea, thanks!
 

Jeremy Harris

Senior Member
Most of these RF remote house automation systems use proprietary protocols for signalling, which can be decoded, but it's not for the faint hearted. If you're lucky, then the protocol may be one that has already been either decoded by someone else, or made public in some other way, in which case there is a reasonable chance that you can get a Picaxe to send the right data to an RF transmitter module to be able to do what you want. As an example, have a read of this old thread from when I was working on decoding the fairly common Byron/HomeEasy protocol with a Picaxe: http://www.picaxeforum.co.uk/showthread.php?23007-HomeEasy-Byron-433MHz-RF-decoding-with-a-Picaxe

A search of the web will probably help, for example if your motor is a Somfy one then there is a reasonably good chance that you may be able to get hold of the information you need, or if not, they seem to make a range of interface units that allow their products to be controlled using some form of serial data control.
 

hippy

Technical Support
Staff member
Having a PICAXE RF controller should in principle be no different to having a PICAXE IR remote control. If what comes out of the PICAXE is the same as what comes out of a genuine remote the receiver won't see any difference.

The challenge is knowing what to send. If the protocol is known and documented for what you have that will help. If not you will have to reverse engineer that by monitoring what an actual remote sends.

Once analysed and determined you can then assess if it is possible to replicate that signal with a PICAXE and set about doing that.

Reverse engineering an IR or RF protocol can be a challenge. A matched receiver and a scope or logic analyser is a good way to start and it is possible to use a PICAXE or a PC to help with that. Taking a tap off the receiver in the equipment itself is also an option.

Having such a setup is also handy for checking that what is being sent matches what one thinks one is sending and allows what is sent to be fine tuned.

I personally would be reluctant to start on a remote control signalling project for IR or RF without having a logic analyser to hand.
 

steliosm

Senior Member
I would start by taking apart the remote control unit and try to identify what encoder chip, if any, is used. I did this when I was too trying to control a set of Byron/Elron RF controlled electric outlets.
The second step, that is to actually replicate the signal, requires a logic analyzer in order to check if your timing is correct. I was using a Logic Sniffer from Dangerous Prototypes. It was easy to read the generated samples from the chip and tune the delays.

You can see my project and notes here: http://steliosm.net/site/?Projects:USB_Home_Automation. If you are lucky enough you might be using the same RF protocol.
 
Thanks for the replies, I have a bit of reading to do then :) I was hoping that I might be able to connect an RF receiver to the picaxe then have it read the output from the remote, then “just” duplicate the codes for sending from the transmitter connected to picaxe, ha perhaps a tad wishful.

The remote only has 2 commands of interest - up and down, so I might just go for one of those cheap RF learning remotes, have that learn the original remote codes and connect that electronically to the picaxe by soldering to the buttons or something similar, just to get it up and running for now. The brand of motor is Louvolite which appears to be a UK based brand, I might try to contact them to see if they will share the information about the codes, although maybe it is a big ask.

For the program I’m thinking of something like this
Read adc: if adc dark then close: else open. I guess I might need to set some amount of delay so that car headlights or whatever do not trigger it to open at night time, anyway probably jumping ahead of myself a bit here, so I’ll welcome any further input and post updates of progress. :cool:
 

Reloadron

Senior Member
I just installed a motorised roller blind in my house which is controlled by a RF (433.92mhz) remote, it occurred to me that it would quite nice to have the blind close when light level falls below a certain level, and have it open when light gets above a set level, so in effect close at dusk and open at dawn. So I then thought that maybe I could use a picaxe 08m2 with a LDR to detect the light level and some kind of RF transmitter, my first thought was to buy a learning RF remote and jerry-rig it to the picaxe but I then saw the RFA001 kit and the AXE213 kit - however I am not sure how I would learn the included remote to the picaxe or even if that is feasible? Has anyone done anything similar? I'd be interested to hear if any similar projects or any thoughts on the idea, thanks!
With that in mind you already have a transmitter to Open and Close. Without seeing the internals my guess is they have a bi directional motor with limit switches. Not quite sure I understand when you say "have the blind close when light level falls below a certain level, and have it open when light gets above a set level", I would have thought in low light you would want to Open to allow more light in and in high level close to reduce the light but really matters not. I would think you could mount the picaxe at the window. Use the picaxe to drive a few low coil current reed type relays in a parallel configuration with what you have. When using the remote when you press the Open or Close buttons something is happening at the receiver end and possibly you could parallel that action be it turning on a transistor, driving a H-Bridge or whatever the system does on Open and Close from the remote.

Ron
 

sghioto

Senior Member
Why not just use the 08M2 to control the transmitter? That's what I did to control a 5 channel RF device to turn lights on and off. This should be fairly easy with only two buttons to control. I used a 08M2 with a CD4066 connected directly to the transmitter. Yeah you have to open the transmitter and connect a few wires but might be easier then trying to replicate the code.

Steve G
 

hippy

Technical Support
Staff member
Perhaps provide details of the manufacturer and model of your blinds. That may help others to better help you.
 

Jeremy Harris

Senior Member
Thanks for the replies, I have a bit of reading to do then :) I was hoping that I might be able to connect an RF receiver to the picaxe then have it read the output from the remote, then “just” duplicate the codes for sending from the transmitter connected to picaxe, ha perhaps a tad wishful.

The remote only has 2 commands of interest - up and down, so I might just go for one of those cheap RF learning remotes, have that learn the original remote codes and connect that electronically to the picaxe by soldering to the buttons or something similar, just to get it up and running for now. The brand of motor is Louvolite which appears to be a UK based brand, I might try to contact them to see if they will share the information about the codes, although maybe it is a big ask.
It's very doubtful that a learning remote would be able to decode the specific protocol, I think, although you may just get lucky. My experience of the cheap learning remotes is that they are OK for the dead simple Chinese made RF remote control systems, but just aren't capable of deciphering the much longer code sequences used by most of the proprietary home automation systems.

On that link I gave are details of the Byron/HomeEasy protocol, with some shots of the data stream. From that it wasn't that difficult to find out which bits did what. I found that I could just sniff the RF from the remote with a cheap, wideband, 433 MHz receiver and store a sample that contained the entire burst of data with a fairly low spec USB oscilloscope. From that, I could see that there was just a single bit change between on and off for a particular device, address, type etc.

As suggested above, if you're prepared to sacrifice the existing remote transmitter, it should be pretty easy to just get a Picaxe to effectively operate the buttons.
 

Reloadron

Senior Member
Why not just use the 08M2 to control the transmitter? That's what I did to control a 5 channel RF device to turn lights on and off. This should be fairly easy with only two buttons to control. I used a 08M2 with a CD4066 connected directly to the transmitter. Yeah you have to open the transmitter and connect a few wires but might be easier then trying to replicate the code.

Steve G
Yeah, that could work but then your transmitter won't have the mobility it now has and where do you place the light sensor? The light sensor goes with the picaxe doesn't it? Also in writing the code it needs to be so the picaxe doesn't go from for example light to dark, sense dark and go to light and sense light and just keep cycling back and forth. Thinking all of this would go better if the guts of the receiving end were known. :)

Ron
 

hippy

Technical Support
Staff member
Or better still, at the transmitter end, where there's no background noise and the signal itself is much cleaner.
That should work, and in theory it shouldn't matter which is used.

I did however find with an IR setup that, where I had matched a PICAXE sender to a genuine remote, though the signals appeared the same when sending, they were slightly different at the output of the receiver. I put that down to having different transmitter drives for the IR LED, the receiver recognising genuine remote signals quicker than it recognised the signals from the PICAXE.

There should usually be some tolerance to timing so in practice it probably doesn't matter where one takes the tap from.

For RF you are right, the signal will be cleaner at the transmitter, which likely would make that the better choice for RF.

Tapping both, using the transmitter signal as the trigger to allow better receiver correlation is perhaps the best combination.
 

AllyCat

Senior Member
Hi,

Yes, as said above, you really need to identify the "encoder" chip, or have access to the "wireless protocol" of the system, or to a logic analyser (a "saleae" is excellent for this task). A (digital) storage 'scope (even the PICaxe store "PCB 'scope") might be satisfactory, but often the data streams are too long to fit conveniently into a single sweep/scan. Don't underestimate how difficult "reverse engineering" can be if you don't have any "clues" to start with.

Also, beware that any "security" intended wireless application (e.g. car door locking) may (should) use a "rolling code", i.e. a different data pattern is transmitted each time the button is pressed (to prevent any thief simply "recording" the wireless pattern and replaying it later). The "key" data-pattern uses a predictable, "pseudo random" sequence, so the receiver "knows" what to look for next time. However, if the transmitter and receiver become "out of synchronisation", then the receiver requires at least two consecutive valid codes to be transmitted (which is why you sometimes need to press your car key-fob twice before the doors will open).

Cheers, Alan.
 
Great input from all you guys! I really appreciate it, in response to some of the questions/comments.

The brand is Louvolite, sadly the remote looks like it was made to not be easily opened without possibly damaging it, it is about as thick as a smartphone and looks welded rather than screwed together. The added complication is I don’t think my beloved would be too keen on me possibly breaking the remote in my quest, ha.

The reason for the light sensor to close blind when dark and open blind when light is because the light sensor will be looking at outside light levels.

I have a scope so looking at the transmission might be an option although at present I do not have anything to recieve that I could connect to the scope, and if the rf uses rolling codes it might make it too complicated.

The other thing that crossed my mind was coming up with a electro-mechanical solution, perhaps using a servo or some solenoids to press the buttons on the actual remote, the remote comes with a small holster designed to mount it on a wall so I might be able to make a kind of rig which sits beside that and when the remote is holstered it would mechanically interface with the buttons. Of course the problem here is if the remote is not present it won’t do much. Maybe seems a bit “McGyver” but could be an option?
 

Jeremy Harris

Senior Member
It looks like at least one third party makes an interface that works with the Louvolite One Touch, RFXCOM: http://www.rfxcom.com/WebRoot/StoreNL2/Shops/78165469/MediaGallery/Downloads/RFXtrx_User_Guide.pdf

That may well mean that the protocol used has already been decoded and may well be around somewhere on the web. The key may well be finding out if this same protocol is used by other companies, and so may be described under another name. It could be worth some digging around on some of the home automation web sites and forums to see if someone has already done the hard work. Knowing the protocol is 99% of the work; getting a Picaxe to send the right signals to a suitable 433 MHz module should be relatively easy.
 

hippy

Technical Support
Staff member
I have a scope so looking at the transmission might be an option although at present I do not have anything to recieve that I could connect to the scope
If you need to reverse engineer you can either buy an RF receiver or tap into the transmitter or receiver.

You might be able to croc-clip jumper the transmitter so batteries are external, insert a low value resistor, measure the voltage dropped across that which might give some indication of what's being transmitted.

if the rf uses rolling codes it might make it too complicated.
It might. Unfortunately one won't know until the protocol is known.

The other thing that crossed my mind was coming up with a electro-mechanical solution
That should work. Or you could buy another remote which you can pull apart to create something less mechanical.
 
Progress update - I bought a 433mhz tx/rx pair kit from ebay and decided to try to decode the signals, I was able to connect a LED to the output pin of the receiver and observe that it was correctly receiving from the blind remote indicating a flash pattern consistent with the flashing LED on the remote, I then though of connecting the output of the receiver to a small powered speaker, and lo and behold the pulsetrain was audible, so next I connected a small Tascam handheld recorder and recorded the output from the receiver, I was curious at this point if it would be possible to now playback the recorded file into the transmitter unit to see if it made the blind activate, and much to my delight it did!

So now I am thinking to either try to decode the high/low sequence into data to be loaded into picaxe OR using the audio as-is with SPE035 Serial MP3 kit that I bought a while back and connecting that to the transmitter, quite a hack eh? I would prefer to do it the "proper" way but at least I now have another option which in theory should work.
 

hippy

Technical Support
Staff member
I am surprised recording and playing back worked. I am not sure I'd say that would be the way to go as it's a lot of extra if a PICAXE could generate the signal itself.

It would be worth looking at the recorded file in some sort of audio editing program to see if you can determine what the protocol is from that.
 
I have the file in audacity not sure how to proceed next, I guess it is a case of determining the high and low transistions and their durations and converting it to binary?
 

PhilHornby

Senior Member
I was curious at this point if it would be possible to now playback the recorded file into the transmitter unit to see if it made the blind activate, and much to my delight it did!
Well top marks for ingenuity!

If you make your recording file available, someone may recognise the format of the data stream.
 

hippy

Technical Support
Staff member
I have the file in audacity not sure how to proceed next, I guess it is a case of determining the high and low transistions and their durations and converting it to binary?
Yes, working out what's high and low, and figuring out what the bit timing is, would be the best start.

If you can take a screenshot and post that as an image that might be good enough for others to help.
 

PhilHornby

Senior Member
I've not seen this before - but it doesn't look too difficult to replicate (without necessarily understanding it!)

My interpretation is as follows :-

There is a 'sync' 'bit' :-
Code:
         <------Preamble-----> 
     ....+           +-------+ 
         |           |       | 
Previous |<--2.5mS-->|<1.6mS>|   Data bits follow..
  Data   |           |       |
         +-----------+       +--...
Followed by 41 bits of data :-

Code:
        +------+   +-.......
        |      |   |
        |  L   | S |  'Long' pulse, 'Short gap'  - a "1"?
        |      |   |
   ...--+      +---+
 OR
        +---+      +-.......
        |   |      |
        | S |  L   | 'Short' pulse, 'Long' gap  - a "0"?
        |   |      |
   ...--+   +------+
My definition of 'long' is approx. 640µS and 'short' is approx. 320µS. (I played the .WAV file into my 'scope to obtain these figures)

That would equate to :-

Code:
[COLOR=#ff8c00]Stop[/COLOR] Button sends [COLOR=#0000ff]1110 1111 0111 1111 1000 [/COLOR][COLOR=#ff0000]1010 [/COLOR][COLOR=#0000ff]1000 0110 0101[/COLOR] [COLOR=#ff0000]1010 [/COLOR]1
[COLOR=#ff8c00]Down[/COLOR] Button sends [COLOR=#0000ff]1110 1111 0111 1111 1000[/COLOR] [COLOR=#ff0000]1000 [/COLOR][COLOR=#0000ff]1000 0110 0101[/COLOR] [COLOR=#ff0000]1001 [/COLOR]1
[COLOR=#ff8c00]Up[/COLOR]   Button sends [COLOR=#0000ff]1110 1111 0111 1111 1000[/COLOR] [COLOR=#ff0000]0011 [/COLOR][COLOR=#0000ff]1000 0110 0101[/COLOR] [COLOR=#ff0000]0111 [/COLOR]1
The "1" on the end, is possibly a 'stop' bit, rather than data. Only 2 nybbles change between buttons. The last one could be a checksum, or a CRC, but I couldn't figure it out, if it is. (Of course, to simply replay the data, it doesn't matter). Each packet is sent 8 times, with a 5mS gap between packets.

Deciphered packet: Blinds.jpg
 

Jeremy Harris

Senior Member
This looks similar in basic format to the code used by the HomeEasy/Byron units, but with a different number of bits. The pattern is similar, bits consist of a sequence of a positive pulse and negative pulse of a set duration for each, there is a pause between data bursts, and a longer start /sync bit to tell the unit that the next bit received will be data. In all probability there will be some sequence to this data stream that breaks it up into functions, so some bit sequences will define the type of device, some will be a unique address for a device, one bit may be the "on" or "off" bit and there may be some form of error check, in the form of a checksum or CRC, as suggested.

Trying to decode the whole sequence would be useful for those who want to build a universal remote system for this product range, but as already suggested, for this application just replicating the pulse sequence will almost certainly do the job just as well.
 
That is great Phil, thank you, I actually only need down and up in the finished project but I thought that recording the stop command might help with decoding, it is good to see that each of the 3 commands seem so similar.

First of all I will try to just duplicate the remote, 2 buttons, 1 for down, 1 for up then add the dawn/dusk stuff later, so next question how do I instruct the pin connected to the transmitter to send the sequence with the correct timing of the 1s and 0s? I will be using a 08m2 and presumably would need to run it at 32mhz in order to send the pulses fast enough, I understand that I would need to have something like:

Declare "down" and "up" as subroutines, where 1.6ms high, then do (41 bits are sent, low 5ms) until 8 times
If "button down" pressed - do "down"
If "button up" pressed - do "up"

Building the circuit and setting up the pins is the easy part for me, but quite how to do the rest is a bit puzzling, I have looked at the other examples posted earlier by Jeremy and Stelios and also the 3 examples here http://www.picaxe.com/Circuit-Creator/Miscellaneous/RF-Radio-Transmitter/ but I can't understand how to convert to my needs. Could anyone post a example to get me started?

Thanks again guys, once I get it working I will post the finished code and details of the project.
 

hippy

Technical Support
Staff member
For bit-banging the output, the simplest approach is having two routines of setting the output low ( perhaps high ), then a series of PAUSEUS and TOGGLE instructions.

It is best to structure your code like this ...

Code:
PowerOnReset:
  Goto MainProgram

BitBangUpCommand:
  :
  Return

BitBangDownCommand:
  :
  Return

MainProgram:
  Do
    :
  Loop
Then you need to work out what the PAUSEUS values need to be. It is probably best to run at 32MHz, at least during the bit-banging routines, as that allows greater control over timing.

You can probably make a good guess at what the values should be but how the token code is placed in memory may affect some of the timing which may need to be tweaked. This is where a logic analyser or scope comes in useful.

The other alternative is to create a loop which generates one bit at a time, feed the data for the command to that. If you can build a list of PAUSEUS values in RAM you can do something like this ...

Code:
SendBitBangCommand:
  bPtr = ?
  Low TX
  PauseUs ?
  Do
    PauseUs @bPtrInc
    Toggle PIN
  Loop Until bPtr = 0
  Return
That allows the code timing to be more easily set and the two routines to send up and down commands can just '@bPtrInc=Tshort' and '@bPtrInc=Tlong' poke times into the RAM. Or you can create a routine to do that and just pass a bit pattern into that routine for up and down commands.

One has to check that the routine above can create pulses as short as what the minimum pulse time is, which seems to be 320us here. I suspect and 08M2 can but one would have to check. If not, the initial idea of a sequence of PULSOUT and TOGGLE commands would need to be used.
 

PhilHornby

Senior Member
Building the circuit and setting up the pins is the easy part for me, but quite how to do the rest is a bit puzzling, I have looked at the other examples posted earlier by Jeremy and Stelios and also the 3 examples here http://www.picaxe.com/Circuit-Creator/Miscellaneous/RF-Radio-Transmitter/ but I can't understand how to convert to my needs. Could anyone post a example to get me started?
I posted some code here: http://www.picaxeforum.co.uk/showthread.php?28662-Code-for-controlling-Energenie-(and-similar-)-RF-Remote-Control-Mains-sockets (two versions)

This is for use with Energenie Remote Controlled Mains Sockets, which use HS1527 encoded signals. These use a HIGH:LOW ratio of 3:1, rather than 2:1 in your case (and the preamble is different).
 
Thanks guys. I had a look through your code Phil (great job!) and read with interest the thread linked where you were troubleshooting the earlier version, to be honest it all seems way over my head, I understand some of the concepts but really have no clue at present how to adapt it to my own scenario, still I will endeavor to cobble something together.
 
I have not had much free time to work on this but here is what I have so far (not much I'm afraid!) Basically for now I just want to have 2 buttons and duplicate the existing remote, once that is done then I will look at more sophisticated control, either light levels or some other method of control.
Code:
;Louvolite blind test program not working yet!
#picaxe 08m2
#no_data 	;do not send empty data block
disconnect 	;stops chip looking for downloads
setfreq m32	;32mhz clockfrequency
dirsC = %00000100 	;sets pin 2 as output
symbol RFtx = pin2 	;RF transmitter data pin
symbol close = pin3	;close button
symbol open = pin4	;open button
pins = %00000000 	;initialise all pins low

main:	;stuff happens
if close = 1  then 
    GOTO close_blind
    endif
if open = 1  then 
    GOTO open_blind
    endif
;if close = 0 and open = 0 then sleep 1 ;sleep if no button pressed to save power
;GOTO main
    
; this is where I get stuck
close_blind:
RFtx = %1110 1111 0111 1111 1000 1000 1000 0110 0101 1001 1

open_blind:
RFtx = %1110 1111 0111 1111 1000 0011 1000 0110 0101 0111 1
Obviously I am getting syntax errors in the close_blind part because I do not know how to do that bit.
 

saunj

Senior Member
I make my own hand—held transmitters with a 08m2 powered by a coin cell. They only consume power while transmitting. See my web site Nader rf control.
 
Top