@TheoL A couple of things to note:
I hooked up the 433Mhz transmitter to pin 4.
The device didn't show up under the MySensor section of the Hardware tab. However all 4 plugs appeared in the Devices list. Strange but it works.
Posts made by kchest
-
RE: 433mhz transmitter
-
RE: 433mhz transmitter
@Matt I used your code as a basis to control some 433Mhz outlets from Aldi (in Germany). The system is their "Easy Home" brand, made by Globaltronics. The model designation is GT-9000. It needed a few tweeks from your code. In case anyone else has, or will get, this package, here is the code (pay attention to the "void setup" section):
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 // Enable repeater functionality for this node // #define MY_REPEATER_FEATURE #include <SPI.h> #include <MySensors.h> #include <RCSwitch.h> #define NUMBER_OF_PLUGS 4 // Total number of attached plugs #define CODE_1On "110001010000001101110000" #define CODE_1Off "110011011100000100010000" #define CODE_2On "110001010000001101110100" #define CODE_2Off "110011011100000100010100" #define CODE_3On "110001010000001101111100" #define CODE_3Off "110011011100000100011100" #define CODE_4On "110001010000001101110010" #define CODE_4Off "110011011100000100010010" RCSwitch mySwitch = RCSwitch(); void setup() { mySwitch.enableTransmit(4); mySwitch.setRepeatTransmit(3); mySwitch.setPulseLength(510); mySwitch.setProtocol(5); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("433mhz switch", "1.0"); for (int sensor=1 ; sensor<=NUMBER_OF_PLUGS;sensor++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_LIGHT); } } void loop() { } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_LIGHT) { int incomingLightState = message.getBool(); int incomingOutlet = message.sensor; Serial.print("Outlet #: "); Serial.println(message.sensor); Serial.print("Command: "); Serial.println(message.getBool()); if (incomingOutlet==1) { if (incomingLightState==1) { // Turn on socket 1 Serial.println("Turn on Socket 1"); mySwitch.send(CODE_1On); // These codes are unique to each outlet delay(50); } if (incomingLightState==0) { // Turn off socket 1 Serial.println("Turn off Socket 1"); mySwitch.send(CODE_1Off); delay(50); } } if (incomingOutlet==2) { if (incomingLightState==1) { // Turn on socket 2 Serial.println("Turn on Socket 2"); mySwitch.send(CODE_2On); delay(50); } if (incomingLightState==0) { // Turn off socket 2 Serial.println("Turn off Socket 2"); mySwitch.send(CODE_2Off); delay(50); } } if (incomingOutlet==3) { if (incomingLightState==1) { // Turn on socket 3 Serial.println("Turn on Socket 3"); mySwitch.send(CODE_3On); delay(50); } if (incomingLightState==0) { // Turn off socket 3 Serial.println("Turn off Socket 3"); mySwitch.send(CODE_3Off); delay(50); } } if (incomingOutlet==4) { if (incomingLightState==1) { // Turn on socket 4 Serial.println("Turn on Socket 4"); mySwitch.send(CODE_4On); delay(50); } if (incomingLightState==0) { // Turn off socket 4 Serial.println("Turn off Socket 4"); mySwitch.send(CODE_4Off); delay(50); } } } delay(50); }```
-
Multisensor PIR and Lux
I was finally able to combine the two example sketches (BH1750 Lux sensor and the HC-SR501. I thought I would share it in case it might help out another newbie like me
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY *Light/Motion sensor using sketches from idefix and Henrik Ekblad * * DESCRIPTION * Arduino BH1750FVI Light sensor * communicate using I2C Protocol * this library enable 2 slave device addresses * Main address 0x23 * secondary address 0x5C * connect the sensor as follows : * * VCC >>> 5V * Gnd >>> Gnd * ADDR >>> NC or GND * SCL >>> A5 * SDA >>> A4 * http://www.mysensors.org/build/light * Motion Sensor example using HC-SR501 * http://www.mysensors.org/build/motion */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensors.h> #include <BH1750.h> #include <Wire.h> #define CHILD_ID_LIGHT 0 #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID_Motion 1 // Id of the sensor child unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) BH1750 lightSensor; // V_LIGHT_LEVEL should only be used for uncalibrated light level 0-100%. // If your controller supports the new V_LEVEL variable, use this instead for // transmitting LUX light level. MyMessage msgLight(CHILD_ID_LIGHT, V_LEVEL); // Initialize motion message: MyMessage msgMotion(CHILD_ID_Motion, V_TRIPPED); uint16_t lastlux; void setup() { lightSensor.begin(); pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Lux/Motion Sensor", "1.0"); // Register all sensors to gateway (they will be created as child devices) present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); present(CHILD_ID_Motion, S_MOTION); } void loop() { uint16_t lux = lightSensor.readLightLevel();// Get Lux value Serial.println(lux); if (lux != lastlux) { send(msgLight.set(lux)); lastlux = lux; } // Read digital motion value boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); send(msgMotion.set(tripped?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); }