Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
homeeasyhacking/secrets.h
Binary file removed IMG_8272.MOV
Binary file not shown.
78 changes: 47 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,83 @@
# Arduino-Nexa



## Overview

Use Arduino, 433Mhz transmitter,receiver and Nexa remote switch to turn on and off real lamp.
Use Arduino, 433Mhz transmitter,receiver and Nexa remote switch to turn on and off real electric device

### Step 1: Material
## HW requirements

- Arduino uno board
- Arduino Nano board
+ Jumper wires
+ [433Mhz Transimitter](http://www.kjell.com/sortiment/el/elektronik/fjarrstyrning/433-mhz-sandarmodul-p88901)
+ [433Mhz receiver](http://www.kjell.com/sortiment/el/elektronik/fjarrstyrning/433-mhz-mottagarmodul-p88900)
- Standard solderless breadboard
- [Nexa remote switch](http://www.nexa.se/EYCR2300.htm)
- Lamp

### Step 2: Set up Arduino with 433Mhz transimitter and receiver
## SW requirements

- [Arduino IDE](https://www.arduino.cc/en/main/software)

## Preparations


### 1. Setup Nexa

Setup your nexa remote switch with your desired electronic, e.g. lamp based on instructions that you received when bought nexa device. Pair it it with the remote where you read the sender id

### 2. Read sender ID

In order to use the following script you will first need to get sender ID from remote controller.

#### Setup Arduino and 433 MHz receiver

Connect RF receiver data cable to Arduino D2 port.

Connect RF receiver VCC to 5V pin and GND to Arduino GND.

![alt text](https://raw.githubusercontent.com/TokyoBirdy/Arduino-Nexa/master/arduino%20set%20up.JPG)
![Arduino RF receiver diagram](https://github.com/Atihinen/Arduino-Nexa/raw/master/media/receiver_diagram.png)

#### Read the ID with Arduino

[This link](http://www.kjell.com/sortiment/el/elektronik/fjarrstyrning/433-mhz-sandarmodul-p88901#ProductDetailedInformation) has a pretty explanation about datasheet about transmitter, and [this one](http://www.kjell.com/sortiment/el/elektronik/fjarrstyrning/433-mhz-mottagarmodul-p88900#ProductDetailedInformation) for receiver. After you read through the datasheets, you should be able to understand how to connect the pins to the arduino.
Deploy rf_receiver.ino to Arduino from receiver/rf_receiver.ino

Open serial monitor to correct port and press the desired button from remote to read sender id, recipient and group.

![Serial monitor results](https://github.com/Atihinen/Arduino-Nexa/raw/master/media/receive_ino_serial_monitor.png)

You should get something like this if the connections are done correctly.

### Step 3: Use Nexa with Lamp

![alt text](https://raw.githubusercontent.com/TokyoBirdy/Arduino-Nexa/master/nexa%20set%20up%20.JPG)
### 3. Start using your arduino as remote

#### Setup Arduino and 433MHz transmitter

Connect RF transmitter data cable to Arduino D13 port.

### Step 4: Receiver test
Connect RF transmitter VCC to 5V pin and GND to Arduino GND.

Run rf_receiver.ino on Arduino, you should be able to see output. Mine looks like this
![Arduino RF transmitter diagram](https://github.com/Atihinen/Arduino-Nexa/raw/master/media/transmitter_diagram.png)

sender 15556058
no group
on
recipient 13
#### Setup the code

sender 15556058
no group
off
recipient 13
Create `secrets.h` same folder where `homeeasyhacking.ino` file is, with following content:

```
#ifndef PAYLOAD
#include "payload.h"
#endif
struct Payload payload {<sender>, <recipient>, false, <group(true|false)>}
```

### Step 5: Final step! Hack
Sender, recipient and group can be read with `rf_receiver.ino` script.

Change the data in homehackingeasy.ino according to the result we got from the above.
Define the `INPUT` type in `homeeasyacking.ino` where:
- 0 is the demo, where the transmitter will send on and off with certain interval
- 1 is for serial port. When you send 1, the transmitter will send on and when you send 0, the transmitter will send 0.

unsigned long sender = 2051610;
unsigned int recipient = 0;
bool command = true;
bool group = false;

Now run^^
Deploy the `homeeasyhacking.ino` to arduino and enjoy controlling your electronic devices.

# Tested hardware

* [Nexa MYC-3](https://www.clasohlson.com/fi/Kaukokytkinsarja-Nexa-MYC-3,-3-kpl/p/Pr366902000)

### Youtube video

[Arduino and nexa to turn on and off real lamp](https://youtu.be/ymzCeY9fIyU)
Binary file removed arduino set up.JPG
Binary file not shown.
63 changes: 54 additions & 9 deletions homeeasyhacking/homeeasyhacking.ino
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
/*
* Example program using the HomeEasy class.
*/

#include "HomeEasy.h"
#ifndef PAYLOAD
#include "payload.h"
#endif
#include "secrets.h"
//struct Payload payload;
#define INPUT 1 //0 for demo, 1 for serial
char recievedChar="";
unsigned int recievedValue=99;

HomeEasy homeEasy;

Expand All @@ -12,6 +19,11 @@ HomeEasy homeEasy;
*/
void setup()
{
// Define payload e.g. in setup
//payload.sender = -1; // read value with receiver.ino
//payload.recipient = -1; // read value with receiver.ino
//payload.command = true; // need to define in code, sets device on or off
//payload.group = false; // read value with receiver.ino
Serial.begin(9600);

homeEasy = HomeEasy();
Expand All @@ -28,15 +40,48 @@ void setup()
*/
void loop()
{
switch(INPUT){
case 0:
demo();
break;
case 1:
serial();
default:
break;
}

}

/** Function handles for different inputs **/
void demo(){
payload.command = true;
delay(3000);
unsigned long sender = 2051610;
unsigned int recipient = 0;
bool command = true;
bool group = false;
homeEasy.sendAdvancedProtocolMessage(sender, recipient, command, group);
homeEasy.sendAdvancedProtocolMessage(payload.sender, payload.recipient, payload.command, payload.group);
delay(3000);
command = false;
homeEasy.sendAdvancedProtocolMessage(sender, recipient, command, group);
payload.command = false;
homeEasy.sendAdvancedProtocolMessage(payload.sender, payload.recipient, payload.command, payload.group);
}

void serial(){
/*Reads char from serial
* 1 = starting the device
* 0 = stopping the device
*/
if (Serial.available()){
recievedChar = Serial.read();
recievedValue = atoi(recievedChar);
Serial.println(recievedValue);
//Reasons yet unknown the char 1 is converted to 1111 by atoi
if(recievedValue == 1111){
Serial.println("Starting device");
payload.command = true;
}
else if (recievedValue == 0) {
Serial.println("Stopping device");
payload.command = false;
}
homeEasy.sendAdvancedProtocolMessage(payload.sender, payload.recipient, payload.command, payload.group);
}
}


Expand Down Expand Up @@ -80,4 +125,4 @@ void printSimpleResult(unsigned int sender, unsigned int recipient, bool on)
Serial.println(on);

Serial.println();
}
}
9 changes: 9 additions & 0 deletions homeeasyhacking/payload.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#define PAYLOAD

struct Payload {
unsigned long sender; // Nexa remote sender ID, read with receiver.ino
unsigned int recipient; // Nexa remote switch value, read with receiver.ino
bool command; // true == nexa remote switch is on, false == nexa remote switch is off
bool group; // is the nexa remote switch grouped or not, read with receiver.ino
};
Binary file removed hr_RF_circuit.jpg
Binary file not shown.
Binary file added media/receive_ino_serial_monitor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/receiver_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/transmitter_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed nexa set up .JPG
Binary file not shown.