Page 7 of 8

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 10:31 am
by ilovemipi
7ewis wrote:How do I pair my Nexa plugs to PiHAT?

I received them yesterday, they are a standard 3 pack with a remote, I believe they are the self learning set.

How do I find out the ID and channel to attempt a connection? It doesn't say anywhere on the packaging.

And for the aerial, it just has to be 16cm of any wire touching that particular pin?
Preferably solid wire rather than stranded wire and yes start with 16cm. I am not familiar with the Nexa sockets but you should have 2 options to obtain the ID. The ID's are never included within the manuals as they are factory set to different numbers.
The options you have are:

1. Use the bash scripts in this thread to try all possible ID's within the 64,000 range. It is likely to take many hours but should eventually find the code.

or

2. Build a simple decoding circuit i.e. record the signal and run it through software again included within this thread. You will need a 433mhz receiver to do this.

To start with you should set up PiHAT without the use of the remote control and you can pick any ID i.e. 0 or 1. The ID you pick can be the same, but doesn't have to be, for each socket if you are not using the remote control.

Pretty sure the channels are the same as the Status sockets but again when testing without the remote you can just pick one, say channel 7. Put the Nexa in pairing mode and run the PiHAT commands (assuming it is in /usr/bin/) e.g.

/usr/bin/sudo pihat --brand=0 --repeats=50 --id=1 --channel=7 --state=1

Once paired turn on with:

/usr/bin/sudo pihat --brand=0 --repeats=15 --id=1 --channel=7 --state=1

and off with:

/usr/bin/sudo pihat --brand=0 --repeats=15 --id=1 --channel=7 --state=0

(if using Status sockets change --brand=0 to --brand=5)

Once you are happy running from the PiHAT move on to decoding the remote. Hope this helps.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 11:06 am
by 7ewis
ilovemipi wrote:
7ewis wrote:How do I pair my Nexa plugs to PiHAT?

I received them yesterday, they are a standard 3 pack with a remote, I believe they are the self learning set.

How do I find out the ID and channel to attempt a connection? It doesn't say anywhere on the packaging.

And for the aerial, it just has to be 16cm of any wire touching that particular pin?
Preferably solid wire rather than stranded wire and yes start with 16cm. I am not familiar with the Nexa sockets but you should have 2 options to obtain the ID. The ID's are never included within the manuals as they are factory set to different numbers.
The options you have are:

1. Use the bash scripts in this thread to try all possible ID's within the 64,000 range. It is likely to take many hours but should eventually find the code.

or

2. Build a simple decoding circuit i.e. record the signal and run it through software again included within this thread. You will need a 433mhz receiver to do this.

To start with you should set up PiHAT without the use of the remote control and you can pick any ID i.e. 0 or 1. The ID you pick can be the same, but doesn't have to be, for each socket if you are not using the remote control.

Pretty sure the channels are the same as the Status sockets but again when testing without the remote you can just pick one, say channel 7. Put the Nexa in pairing mode and run the PiHAT commands (assuming it is in /usr/bin/) e.g.

/usr/bin/sudo pihat --brand=0 --repeats=50 --id=1 --channel=7 --state=1

Once paired turn on with:

/usr/bin/sudo pihat --brand=0 --repeats=15 --id=1 --channel=7 --state=1

and off with:

/usr/bin/sudo pihat --brand=0 --repeats=15 --id=1 --channel=7 --state=0

(if using Status sockets change --brand=0 to --brand=5)

Once you are happy running from the PiHAT move on to decoding the remote. Hope this helps.
These are the Nexa sockets I have purchased: http://www.clasohlson.com/uk/Nexa-EYCR2 ... ck/18-2651

Okay, I'll give the aerial a go, and it's GPIO Pin 4 right?

Ah right, I didn't know that. Although I have just noticed on the back of my remote, it has 'Data Code: 1106' could that be useful? I tried it as the ID without success.

I don't have a receiver, so I guess I'll find the BASH script and start running it asap then!

So I don't need to know a certain ID or channel to be able to pair them? Because I have already been trying multiple variations of the code above, and nothing works. Although, I am not quite sure how pairing mode works on the Nexa, as it is 'self learning'.

Whenever I try to send a command, it just says:

Tune to 144.64 MHz
0000000001000010100101110

With the bottom number varying depending on the channel and ID.

Thank you for your reply.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 11:22 am
by ilovemipi
7ewis,

Tune to 144.64 MHz
0000000001000010100101110 indicates you have the PiHAT software running ok.

Yes GPIO4 which is pin 7 on the model B Pi. To start with ensure the socket is as close as possible to the Pi (few inches if possible). I managed 7m witht the ariel but some people report much shorter distances. With the transmitter circuits from China (under £2 incl delivery) the range goes up to over 15m.

If you have been trying it without an aerial then it probably will not work and I guess Nexa could put the ID on each remote (Status don't give you the code as most people are not interested in the code).

Not quite sure how the self learning works on the Nexa. Do you not have to press and hold a button on the socket when you first pair it with the remote? This is how the Status sockets work. If you don't have such a pairing system I don't see how Nexa could operate more than one socket i.e. the channels need to be unique for each socket / remote control device.

Please explain the self learning process of the Nexa and I will advise further.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 11:48 am
by 7ewis
Okay, thats good; at least something is working!

Oh wow, that's quite far. I will try and get an aerial as soon as I can, but for now I actually have the Pi resting onto of the socket, so the pins are almost physically touching the Nexa, so I don't think range should really be a problem.

So should I continue to try using that number, or try and work it out with the script?

Okay, to be honest I'm not sure how it works, but I'll explain the 'process'. Literally, I just had to connect the socket to power, and it worked with the remote instantly. The remote has 6 options, 'On' and 'Off' for 3 different sockets, each button will always work with one particular switch.

This is what the 'instructions' say on the packaging:
'Self learning code system'
Simple plug'n'play installaation. Plug a socket receiver into a mains wall socket, press any button on the remote control and the self learning remote and the socket reveiver will be instantly coded to each other. Next, plug the equipment you want to remotely control into the socket receiver- it couldn't be easier.

New generation- each power socket has 3 memory-locations and can be activated individually by any Nexa remote control. The remote control supplier operates up to 3 power sockets, either individually or using 'group control'.

Secure communications- The system uses 67 million code combinations desgined to prevent interference from similar systems.

All system Nexa self-coding receivers and transmitters are fully compatible.
(Excuse mistakes, I typed it quickly)

So I think it must be hopeful, especially with the last sentence, if any remote can work with any receiver, I assume the Pi would be able to control it too?

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 12:17 pm
by 7ewis
s7mx1 wrote:Just plugged a wire to GPIO pin 4 and it paired with my status remote socket bought from ASDA. The on/off state works perfectly. Need to find out the current id of my remote.
If you have paired them, why is the ID of the remote useful? Don't you need the remote ID in order to send the commands anyway?

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 12:29 pm
by ilovemipi
7ewis wrote:
s7mx1 wrote:Just plugged a wire to GPIO pin 4 and it paired with my status remote socket bought from ASDA. The on/off state works perfectly. Need to find out the current id of my remote.
If you have paired them, why is the ID of the remote useful? Don't you need the remote ID in order to send the commands anyway?
Per my earlier emails the actual ID is not required for the Pi to control the sockets as it 'overrides' the actual ID. However when the Pi takes control in this way the remote control will no longer operate the sockets. If you only want the Pi to control the sockets then the ID is not important but if you want PI AND the remote to work together you need the factory set ID code.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 1:00 pm
by ilovemipi
7ewis,

I also looked up the self learning system in the Nexa brochure at http://nexa.sidvisning.se/faq_guide_eng/

The Nexa and Status devices are very similar with a few subtle differences. Looking at your Nexa and their website it looks like 16 devices (1 ,2, 3, 4 X I, II, III, IV) whereas the Status product just does 4 devices. It could be '4' on your Nexa device is the 'all off' / 'all on' switch.

The Status sockets lose their coding after a couple of minutes without electricity and your Nexa's might retain their coding without electricity. Until you have established the code for the Nexa for the PiHAT to control the sockets you have to 'erase' the coding which is done with the G button.

Plug in Nexa socket and within 5 seconds press 'G Off'. Now you should be able to pair the Pi with the Nexa socket. I can't tell from the photos but I think you should have a 'programming' or 'like' button on the Nexa sockets. Once you have erased the code (with G off) plug in the socket, press the prgramming / like button on the socket and send the commands from the Pi to pair them.

With the Status devices they stay in pairing mode (led flashing on the socket) 'forever' until pairing is complete. Nexa's may have a time limit for pairing to take place. If you don't have a programming / like switch on the Nexa sockets the system will only work with the factory set code.

I think the 67 million codes is not technically correct and one of my 433mhz products states 1 million codes but is more like 64,000 in reality.

It could be that your data code is 1106 but statistically it seems unlikely if there truly are million or even 64,000 combinations. I am probably wrong in this assessment as each number in the range has equal probability of being the code but it just 'feels' like the wrong code to me.

Is the code on a label or hard stamped into the device? If it is a label then it is more likely to be the code but from earlier posts in this thread I thought the Nexa owners also had to establish their codes like the Status owners. Either way it doesn't hurt to assume 1106 is the code as the Pi (PiHAT) can use any code (but the remote will not work without the actual code).

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 2:29 pm
by 7ewis
ilovemipi wrote:
7ewis wrote:
s7mx1 wrote:Just plugged a wire to GPIO pin 4 and it paired with my status remote socket bought from ASDA. The on/off state works perfectly. Need to find out the current id of my remote.
If you have paired them, why is the ID of the remote useful? Don't you need the remote ID in order to send the commands anyway?
Per my earlier emails the actual ID is not required for the Pi to control the sockets as it 'overrides' the actual ID. However when the Pi takes control in this way the remote control will no longer operate the sockets. If you only want the Pi to control the sockets then the ID is not important but if you want PI AND the remote to work together you need the factory set ID code.
Okay, I understand. In that case, I'm not too bothered about the ID unless it is compltetely necessary with my plugs.

I don't really mind if the remote works or not.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 2:57 pm
by ilovemipi
7ewis,

Do your Nexa sockets have a 'button'?

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 2:59 pm
by 7ewis
ilovemipi wrote:7ewis,
I have done some more research, and have found out how the codes are saved, but I'm still not entirely sure how to pair them together. I have found an english manual in the back of a small leaflet I found hidden in the packaging, I hope you are able to read the english pages from these pictures:
(Click to enlarge)
Image
Image
Image

So from what I can take from that, I have to pair within the first 5 seconds of plugging-unplugging-plugging it in? And that *should* allow me to completely control it with any ID/Channel?

Whilst looking for a button, I noticed on the back of the plug, there is a sticker, and a dark spot in the middle, but it just looks like it's a hole, I pierced one, and I can just see the circuit board, I'm not sure why they all have this though.

Regarding the remote, it is a sticker, but it looks quite firm. So I'm still not 100% sure if it's a unique code, but that must improve the chances! I have also been running a bash script for a few hours now trying multiple different codes, from 0 up to 40,000 so far, but I'm not sure if it could even connect if I haven't paired them?

I'm going to attempt this unplugging and replugging in thing now anway, hopefully this will solve my problems!

Thanks again!

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 3:32 pm
by redhawk
So from what I can take from that, I have to pair within the first 5 seconds of plugging-unplugging-plugging it in? And that *should* allow me to completely control it with any ID/Channel?
If I understand the instructions correctly this device has the ability to learn up to 3 different remote controls and can still remember after the power is removed.
To "clear" this memory you turn off the mains power wait for 5 seconds and turn the mains power back on (or unplug / plug as instructed).
The device should blink on and off, within the allotted 5 seconds you must press and hold the all/off button on the switch unit to clear the learnt codes.
After that you should be able to pair your switches with the Pi.

Richard S.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 3:42 pm
by ilovemipi
Your 5 seconds is equivalent to a button. Better with the Status device as you have 'forever' to pair them and a physical button.

Not really worth running the bash script until you have the basics running.
So each time you try to pair with PiHAT you have just 5 seconds before trying again by unplugging (and maybe clearing the code with the G button). If you don't pair with the remote you might not need to clear the code each time with the G button.

If the socket is not flashing (in pairing / learning mode) PiHAT will not be able to pair with it. Once it is flashing it should just be a couple of commands and you will be up and running.

You can then move on to running the bash script to establish the code to use the remote control at the same time as the Pi.
To do this you will go back to the original set up you had, clear Pi code by unplugging socket / pressing G button, pair with remote.
Plug a lamp into the socket and switch on, run the script to try every code to switch the light off.

Obviously once you have the code you will change the PiHAT command from --id=0 to --id=12345 (if code is 12345).

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 3:44 pm
by 7ewis
redhawk wrote:
I have followed the instructions now, and managed to clear all codes, and then reassign the plug to a different set on the remote. (The top On/Off buttons controlled this specific plug, I cleared it, and then set the bottom buttons to control it, and it worked). I cleared it again, and tried transmitting an 'On' signal from the Pi the same way I set up the controller, and it didn't work. (It doesn't actually flash, it makes a click sound).

I really thought that this would be the solution, but it still doesn't seem to work despite physically touching the plug and transmitting multiple different pair requests.

Does anyone actually know what brand I should be using? I thought that the PiHAT was initially designed for a Nexa plug, so I assume it should work on brand=0? Then the ID doesn't matter, I did try 1106 though too. And the channel doesn't matter either, although I tried 0, 1, 7 and 8?

Is there *anything* else I can do, or is this plug just incompatible? :(

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 3:49 pm
by 7ewis
ilovemipi wrote:
I can successfully use the pairing and deleting mode whilst using the remote, following those instructions, but when I try with the Pi, I get the plug into the 5 seconds of flashing, instantly run the code, and nothing... The remote makes the device click twice, and no matter what command I send, I cannot get the Pi to make a sound.

Just to clarify, what brand/channel should I be using? Or doesn't it matter? I have been trying as many different combinations as I can think of, without any results :(

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 4:09 pm
by ilovemipi
7ewis wrote:
I can successfully use the pairing and deleting mode whilst using the remote, following those instructions, but when I try with the Pi, I get the plug into the 5 seconds of flashing, instantly run the code, and nothing... The remote makes the device click twice, and no matter what command I send, I cannot get the Pi to make a sound.

Just to clarify, what brand/channel should I be using? Or doesn't it matter? I have been trying as many different combinations as I can think of, without any results :(
You are right that the software was originally written for the Nexa and I believe if you don't include the brand in the command it will default to zero i.e. the Nexa.

Channel number is variable with the Status sockets as follows:

Channel 0 -> ALL OFF (no ALL ON facility)
Channel 7 -> button 1 on remote
Channel 6 -> button 4 on remote
Channel 5 -> button 3 on remote
Channel 3 -> button 2 on remote

http://www.skagmo.com/page.php?p=projects/22_pihat is the orignal Nexa stuff and it states:

To use the software, do as follows on you RPi:
wget http://www.skagmo.com/content/projects/ ... t_0.1b.zip
unzip pihat_0.1b.zip
cd pihat
chmod +x pihat
Put your Nexa receiver in pairing mode
Transmit a long signal at the desired ID and channel: ./pihat --repeats=50 --id=1 --channel=0 --state=1
After a successful pairing operation, transmit eg. an off-signal: ./pihat --id=1 --channel=0 --state=0
Get to know the syntax by typing ./pihat --help.


Are you using the --repeats=50 in the command line for pairing? If you have cleared the codes then any id should work (or it does with the Status sockets). Once it is paired the Status sockets receive a single click when activated by the Pi or the remote (presumably a relay activating). I must say that most people in this thread appear to have Status variant sockets but as we have said the software was initially written for the Nexa sockets so you should be ok.

Do you not have anything you can put on GPIO4 as an aerial? My experience is any length and any wire type is better than nothing.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 5:23 pm
by 7ewis
ilovemipi wrote:
I've now made a script to loop through the channel numbers between 0-15, so I can just keep unplugging my Nexa to get it into it's learning mode, and I still cannot get it to work. I have tested every channel multiple times now. With repeats 50 and state 1, leaving out the ID and brand.

The plug doesn't currently have anything assigned to it, although I am wondering about the pairing process... it says I have to 'press the ON button', is that effectively what pihat does too?

I probably have something I can put on it, but I'm not entierly sure how to attach it, and which pin it is (is it pin 4 or 7, I have seen both. Which one is it here: Image?)

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Tue Jan 28, 2014 5:42 pm
by ilovemipi
7ewis wrote:
ilovemipi wrote:
I've now made a script to loop through the channel numbers between 0-15, so I can just keep unplugging my Nexa to get it into it's learning mode, and I still cannot get it to work. I have tested every channel multiple times now. With repeats 50 and state 1, leaving out the ID and brand.

The plug doesn't currently have anything assigned to it, although I am wondering about the pairing process... it says I have to 'press the ON button', is that effectively what pihat does too?

I probably have something I can put on it, but I'm not entierly sure how to attach it, and which pin it is (is it pin 4 or 7, I have seen both. Which one is it here: Image?)
I will answer the aerial question first and send another post on the other issues as fitting the aerial might fix your problem.
The name of the pin is GPIO4 which is pin 7 on the 26 pin header shown in red in your image. Pin 1 is top left in your diagram and marked on the board. Top right is pin 2. So pin 7 is 4 down from the top on the left side of the header. If you don't have a soldering iron and male socket handy do you have any electronic bits lying around. Many bits will have a connector and piece of wire that will fit pin 7 (GPIO4). It doesn't matter if it is say a 4 way connector that goes over neighbouring pins as long as any wires on the connector are not touching each other. If you have any computer ribbon cable you can modify a bit of that for the 'aerial'.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Wed Aug 06, 2014 6:48 am
by dirtydischo
I’ve been trying to set up some status plugs to be controlled by raspberry pi and have managed to set up txt3rob's RPI-Control on my system.

I would like to identify the remote id for my status remote (RCT-08) so that I can allow either the Raspberry Pi or the remote to control the sockets. At present I’ve just set RPI-Control up with a random remote id, which doesn’t match the remote.

I have a RTL2832U based DVB-T tuner which I’ve hooked up to SDR# to record the baseband of the signal. I’m stuck at the point of translating that into a remote id though. I’ve tried Redhawk’s status_remote_decoder but am getting a runtime error 201. I suspect that is because my sample rate isn’t 44.1kHz / 48kHz. I can’t seem to record the baseband at that sample rate, and if I try to record the audio it just looks like a mess in audacity.

Is there a way to use SDR# to record baseband wave at a suitable sample rate to use Redhawk’s programme, or some other way of retrieving the remote id? I’ve included a screenshot of one of the wav files in case that helps.

Grateful for any help with this.

Image

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Wed Aug 06, 2014 9:10 am
by redhawk
In the SDRSharp's Recording section you need to tick the "Audio" box, untick "Baseband" and set audio format to 16bit PCM.
In the Radio section set mode to AM, set the Bandwidth to at least 10kHz or more, increase the RF gain until the noise floor starts to rise and finally untick "filter audio" in the Audio section.
Once you have saved the WAV file it should have an _AF ending not _IQ this file should decode with my status decoder tool preferably with -f2 filter option.

Richard S.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Wed Aug 06, 2014 9:10 pm
by dirtydischo
Richard,

Thanks for your suggestions. I've tried to follow them to record and then run your program. I'm not getting an error now, but seem to get the odd 0 or 1 with some recordings, but nothing with most.

Do you recommend recording a single button press in a wav file or something else e.g. multiple presses of the same button, all of the buttons on the remote?

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Wed Aug 06, 2014 9:25 pm
by redhawk
Hi, you must run the status decoder with -s parameter otherwise it just prints the raw binary data.
If you still cannot get the remote ID then run with-s -f1 or -s1 -f2 parameters to apply audio filtering.

Richard S.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Wed Aug 06, 2014 10:05 pm
by redhawk
Do you recommend recording a single button press in a wav file or something else e.g. multiple presses of the same button, all of the buttons on the remote?
It doesn't matter what buttons you use the remote control always sends the same remote ID.
What is important is getting a good clear recording and that means setting up SDRSharp correctly as mentioned in my previous post.
For signal "Bandwidth" you may want to increase this from 10kHz to 15kHz (15000) it helps to improve the accuracy of the wav data.

If you're still stuck please upload an audio clip somewhere and I'll decode it myself. :)

Richard S.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Wed Aug 06, 2014 10:13 pm
by dirtydischo
Ok, I'll try again tomorrow with the increased bandwidth as I suspect that the quality of the recorded signal could be the problem.

I'm aware of using -s to get the remote id, but it's currently returning a blank.

If I fail next time, I may well take you up on the offer of decoding the signal! Thanks.

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Thu Aug 07, 2014 7:33 am
by dirtydischo
I’ve now managed to get the remote id using your code - changing the bandwidth to 15000 did the trick. Thanks!

I’ve tested using pihat from the cmd line and the remote and it works fine. When I tried adding the appropriate id to RPI-Control it didn’t work - so this is my next problem to sort!

Re: PiHAT - Rasberry Pi Home Automation Transmitter

Posted: Fri Aug 22, 2014 3:12 pm
by txt3rob
^ let me know what issues you have and I will help you out with it :)