Skip to content

My Project

Show off and share your great projects here! We love pictures!
961 Topics 13.4k Posts
  • Using a sensor to sense the presence of copper wire.

    44
    0 Votes
    44 Posts
    6k Views
    ?
    Thanks to all that have given input. I'm going to give in and simply use the momentary to open the cylinder (normally closed). It's just too easy. And going automated is not worth the added expense, as this single cylinder prototype will be duplicated to almost (100) cylinders....each completely independent from one another. Thank you!!!
  • Garage Door + Other Sensors

    8
    0 Votes
    8 Posts
    2k Views
    TamarackGhostT
    @thucar @gohan Thank you both. Everything is working as designed now. For now, I am just going to stick with the code below. I will put the interrupts in on the next version. /** * 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 * Combo sketch built from original motion sensor sketch combined with code from the Relay actuator sketch * 2x Motion Sensors to be used as garage doors status usualy with reed switches * 2x Relays to control garage doors * NOTE! this sketch automaticaly turns the relays back off after a door control has been sent to it * How long the relays are on is defined vith the variable "RELAY_ONTIME" the default is 300 milliseconds * http://www.mysensors.org/build/relay */ /* arduino Pro mini 5V 16MHz ???? */ #define MY_RADIO_NRF24 #define MY_DEBUG // Enables debug messages in the serial log // Set MY_NODE_ID to something unique in your sensor network (1-254) // or set to AUTO if you want gw to assign a MY_NODE_ID for you. #define MY_NODE_ID AUTO #define SN "DualGarageDoor" #define SV "1.5" //#define MY_RF24_CE_PIN 9 // Radio specific settings for RF24 //#define MY_RF24_CS_PIN 10 // Radio specific settings for RF24 (you'll find similar config for RFM69) //#define MY_RF24_PA_LEVEL RF24_PA_MAX #include <MyConfig.h> #include <MySensors.h> #include <SPI.h> // Enable repeater functionality for this node #define MY_REPEATER_FEATURE #define DIGITAL_INPUT_SENSOR 3 // The digital input for PIR. #define DIGITAL_INPUT_SENSORA 4 // The digital input for Door 1 #define DIGITAL_INPUT_SENSORB 5 // The digital input for Door 2 #define LIGHT_SENSOR_ANALOG_PIN 0 //light sensor //#define INTERRUPT DIGITAL_INPUT_SENSORA-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define CHILD_ID_PIR 40 // Id of the sensor child #define CHILD_ID_RELAY 30 //Id of relay #define CHILD_ID_DOORA 21 // Id of the sensor child #define CHILD_ID_DOORB 20 // Id of the sensor child #define CHILD_ID_LIGHT 10 //light sensor #define RELAY_PIN 6 // Arduino Digital I/O pin number for first relay #define NUMBER_OF_RELAYS 1 // Total number of attached relays //define what is on and off for the relay #define RELAY_ON 1 #define RELAY_OFF 0 //define what is on and off for the reed switches #define DOOR_CLOSED 0 #define DOOR_OPEN 1 int RELAY_ONTIME = 1000; //delay before turning relay back off int lastLightLevel; //light sensor boolean oldValueA = 0; boolean oldValueB = 0; boolean trippedA = 0; boolean trippedB = 0; uint32_t SLEEP_TIME = 10000; // Sleep time between reads (in milliseconds) MyMessage msg1(CHILD_ID_DOORA, V_LOCK_STATUS); MyMessage msg2(CHILD_ID_DOORB, V_LOCK_STATUS); MyMessage msg4(CHILD_ID_LIGHT, V_LIGHT_LEVEL); //light sensor MyMessage msg3(CHILD_ID_PIR, V_TRIPPED); //PIR void before() { for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Then set relay pins in output mode pinMode(pin, OUTPUT); // Set relay to last known state (using eeprom storage) digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF); } } void setup() { pinMode(DIGITAL_INPUT_SENSORA, INPUT); // sets the motion sensor digital pin as input pinMode(DIGITAL_INPUT_SENSORB, INPUT); // sets the motion sensor digital pin as input // Activate internal pull-up digitalWrite(DIGITAL_INPUT_SENSORA, HIGH); digitalWrite(DIGITAL_INPUT_SENSORB, HIGH); digitalWrite(RELAY_PIN, RELAY_OFF); pinMode(RELAY_PIN, OUTPUT); pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the Sketch Version Information to the Gateway Serial.println("Presentation"); sendSketchInfo(SN, SV); for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { present(sensor, S_BINARY); } { trippedA = digitalRead(DIGITAL_INPUT_SENSORA); trippedB = digitalRead(DIGITAL_INPUT_SENSORB); //Serial.print("Door A status: "); //Serial.println(trippedA); //Serial.print("Door B status: "); //Serial.println(trippedB); send(msg1.set(trippedA ? DOOR_CLOSED : DOOR_OPEN)); send(msg2.set(trippedB ? DOOR_CLOSED : DOOR_OPEN)); oldValueA = trippedA; oldValueB = trippedB; } { // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_DOORA, S_LOCK); present(CHILD_ID_DOORB, S_LOCK); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); present(CHILD_ID_PIR, S_MOTION); } } void loop() { { // Read digital reed switch value trippedA = digitalRead(DIGITAL_INPUT_SENSORA); trippedB = digitalRead(DIGITAL_INPUT_SENSORB); // Send value only if changed if(trippedA != oldValueA) { //Serial.print("Door A status: "); //Serial.println(trippedA); send(msg1.set(trippedA ? DOOR_CLOSED : DOOR_OPEN)); //gw.sendVariable(CHILD_ID_DOORA, V_LOCK_STATUS, trippedA?DOOR_CLOSED:DOOR_OPEN); // Send value change to gw delay(1000); oldValueA = trippedA; } // Send value only if changed if(trippedB != oldValueB) { //Serial.print("Door B status: "); //Serial.println(trippedB); send(msg2.set(trippedB ? DOOR_CLOSED : DOOR_OPEN)); //gw.sendVariable(CHILD_ID_DOORB, V_LOCK_STATUS, trippedB?DOOR_CLOSED:DOOR_OPEN); // Send value change to gw delay(1000); oldValueB = trippedB; } } { int16_t lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; //Serial.println(lightLevel); if (abs(lightLevel - lastLightLevel)>20) { send(msg4.set(lightLevel)); lastLightLevel = lightLevel; } } { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); send(msg3.set(tripped?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. wait(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); } } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_STATUS) { // Change relay state digitalWrite(RELAY_PIN, RELAY_ON); wait(RELAY_ONTIME); digitalWrite(RELAY_PIN, RELAY_OFF); wait(2000); } }
  • MYSENSORS sur SHRIMP

    11
    0 Votes
    11 Posts
    2k Views
    Daniel RUIZ9D
    Thank you for your help I passed the 2.2 satable version I am now launching on the ethernet gateway.
  • Errors when compiling the program Atmega16

    2
    0 Votes
    2 Posts
    541 Views
    tbowmoT
    There is no official support for AVR chips smaller than the atmega328. So it might be hard to find someone that can help with your specific issue with atmega 164/324
  • Temperature and Humidity with SI7021 on Slim 2AA Battery Node 1Mhz

    1
    9
    2 Votes
    1 Posts
    2k Views
    No one has replied
  • Review of first PCB design - Single Switch Node with Hylink AC/DC

    3
    1
    0 Votes
    3 Posts
    1k Views
    C
    @sundberg84 Thank you so much for the advice, I knew that it would come down to small things here and there, and it's so much easier to tinker around in eagle than try to order a board, find the errors and fix/reorder over and over, so I appreciate it very much! Time to get back in and make some changes :)
  • Water leak sensor

    6
    2
    2 Votes
    6 Posts
    3k Views
    F
    @helvetian Thanks. I am using Domoticz as Controller. After you first start-up of node you will get a Light device, change this device to Dimmer, then in Setup-Hardware-MySensorsSetup, select Node then select Child for SleepTime and disable Ack.
  • Solar cell support with non-rechargeable batteries

    30
    1
    0 Votes
    30 Posts
    4k Views
    G
    As this thread turns into my personal highlights of silly mistakes: Another word of caution for anybody who wants raw battery values sent: sendBatteryLevel only uses 8-bit: i.e. value from 0-255. Don't try to send your raw 10-bit sensed input from e.g. A0 directly with it. bool sendBatteryLevel(const uint8_t level, const bool ack = false); Make sure you divide by 4 or use something like: int sensorValue = analogRead(ANALOGUE_SENSE_PIN) >> 2; sendBatteryLevel(sensorValue);
  • My Home Automation Journey

    2
    1 Votes
    2 Posts
    1k Views
    L
    Sounds nice! I wish you the best of luck with your project(s) and keep us updated! I might do some project report like this too soon, so I will follow yours ;)
  • 0 Votes
    5 Posts
    1k Views
    Nca78N
    @sirguy-cheblin said in BlackBox: binary, lightweight communication protocol handler source code generator.: @gohan do you use MQTT? well. forget it. With BlackBox you can build your own, fit to only your project needs. What's the advantage of leaving an interoperable protocol like MQTT for your own protocol ? And how is it relevant in a MySensors environment ?
  • Help Please "Rain Water Tank"

    13
    0 Votes
    13 Posts
    3k Views
    skywatchS
    So what is giving 5v to this?
  • gdomotics

    4
    2
    4 Votes
    4 Posts
    1k Views
    A
    @hek pictures and library post link added
  • Where to find a rainfall sensor

    2
    0 Votes
    2 Posts
    876 Views
    zboblamontZ
    @pierrot10 Look for tipping bucket on this site... The search facility is invaluable... ;)
  • My First MySensors Project

    1
    10
    8 Votes
    1 Posts
    2k Views
    No one has replied
  • My 2 new nodes : one hacked enclosure and one 3d printed

    8
    9 Votes
    8 Posts
    2k Views
    L
    thanks :blush:
  • RV security project

    2
    0 Votes
    2 Posts
    770 Views
    gohanG
    I think you don't really need mysensors for that and I believe pir sensor is not going to work well behind a glass.
  • Trigger when mouse trap caught a mouse

    10
    2
    0 Votes
    10 Posts
    3k Views
    bjacobseB
    @sundberg84 Hey good idea, but I would like the electronic to be away form the mouse/rat, so I don't get pee/faces on as it contains diseases...
  • RFID Garage door opener

    47
    10 Votes
    47 Posts
    38k Views
    gohanG
    Are you looking for an rfid system or just a radio remote control?
  • Synchronising Light switch

    light switch
    10
    1
    2 Votes
    10 Posts
    6k Views
    pepsonP
    Hi Can you help me convert this skecth for MySensors 2.2.0 because it was released. I upload to my Arduino MIni Pro this sketch but in Gateway Domoticz not show child to switch relay. Only show repeater child on ID 255. And also if you can please share me ready skecth for 2x releay. /* Relay with button sketch modified to work with no uplink to gateway and try to maintain sync to controller */ #define MY_DEBUG // Enable debug prints to serial monitor #define MY_RADIO_RFM69 #define MY_IS_RFM69HW #define RFM69_868MH #define MY_RFM69_NEW_DRIVER //#define MY_NODE_ID 203 // Node id defaults to AUTO (tries to fetch id from controller) #define MY_TRANSPORT_WAIT_READY_MS 5000 //set how long to wait for transport ready in milliseconds #define MY_REPEATER_FEATURE // Enabled repeater feature for this node #include <MySensors.h> #include <Bounce2.h> #define RELAY_PIN 5 // Arduino Digital I/O pin number for relay #define BUTTON_PIN 3 // Arduino Digital I/O pin number for button #define CHILD_ID 1 // Id of the sensor child #define RELAY_ON 1 #define RELAY_OFF 0 Bounce debouncer = Bounce(); int oldValue = 0; bool uplinkAvailable = true; bool state = false; bool requestState; bool firstStart = true; unsigned long uplinkCheckTime ; // holder for uplink checks unsigned long uplinkCheckPeriod = 30*1000; // time between checks for uplink in milliseconds unsigned long returnWait = 1000; // how long to wait for return from controller in milliseconds.. adjust as needed unsigned long oldTime = 0; unsigned long newTime = 0; MyMessage msg(CHILD_ID, V_STATUS); void setup(){ pinMode(BUTTON_PIN, INPUT_PULLUP); // Setup the button pin, Activate internal pull-up debouncer.attach(BUTTON_PIN); // After setting up the button, setup debouncer debouncer.interval(5); pinMode(RELAY_PIN, OUTPUT); // set relay pin in output mode digitalWrite(RELAY_PIN, RELAY_OFF); // Make sure relay is off when starting up } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("1xRelay & Button", "2.2.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_BINARY); } void loop(){ if (firstStart) { // this code is only run once at startup Serial.println("First run started"); requestTime(); // get time from controller wait (returnWait); // delay to allow time to return if (oldTime == 0){ // check to see if there was a return from the time request Serial.println("uplink not available"); uplinkAvailable = false; // no uplink established uplinkCheckTime = millis(); } else{ Serial.println("uplink available"); request( CHILD_ID, V_STATUS); // get status of switch on controller wait (returnWait); //wait needed to allow request to return from controller Serial.print("controller state --- "); Serial.println(requestState); if (requestState != state) { // check that controller is corectly showing the current relay state send(msg.set(state), false); // notify controller of current state } } firstStart = false; // set firstStart flag false to prevent code from running again } debouncer.update(); int value = debouncer.read(); // Get the update value if (value != oldValue && value == 0) { // check for new button push state = !state; // Toggle the state digitalWrite(RELAY_PIN, state ? RELAY_ON : RELAY_OFF); // switch the relay to the new state requestTime(); wait (returnWait); // delay to allow time to return if (oldTime != newTime){ // if times are different then uplink is available send(msg.set(state), false); oldTime = newTime; } else{ // if times are the same no uplink is available Serial.println("uplink not available"); uplinkAvailable = false; // no uplink available, set flag false uplinkCheckTime = millis(); // start the timer from now } } oldValue = value; if (!uplinkAvailable && (millis() - uplinkCheckTime > uplinkCheckPeriod) ) { // test to see if function should be called uplinkCheck(); // call uplink checking function } } /*-------------------start of functions--------------------------*/ void receive(const MyMessage &message) { if (message.type == V_STATUS) { // check to see if incoming message is for a switch switch (message.getCommand()) { // message.getCommand will give us the command type of the incomming message case C_SET: //message is a set command from controller to update relay state state = message.getBool(); // get the new state digitalWrite(RELAY_PIN, state ? RELAY_ON : RELAY_OFF); // switch relay to new state uplinkAvailable = true; // uplink established /*---- Write some debug info----*/ Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); break; case C_REQ: // message is a returning request from controller requestState = message.getBool(); // update requestState with returning state break; } } } void uplinkCheck() { requestTime(); wait (returnWait); // wait for time return.. this may need to be varied for your system if (oldTime != newTime){ Serial.println("uplink re-established"); request( CHILD_ID, V_STATUS); wait (returnWait); //wait needed to allow request to return from controller if (requestState != state) { // check that controller is corectly showing the current relay state send(msg.set(state), false); // notify controller of current state no ack uplinkAvailable = true; // uplink established oldTime = newTime; } } uplinkCheckTime = millis(); // reset the checktime Serial.println("uplinkchecktime reset"); } void receiveTime(unsigned long time) { if (firstStart){ oldTime = time; newTime = time; } else{ newTime = time; } Serial.print("time received---- " ); Serial.println(time); }
  • IP Gateway based on ncat + socat + USB

    5
    1 Votes
    5 Posts
    1k Views
    thazlettT
    I actually didn't know that raspberry pi gateway was a thing! nice, i'll have to try that. I have been using a USB one since 1.5. I guess what i'm doing here is just more generic. I have it running on an orange pi one right now and it's fine. I plan to move it to a r-pi zero w when I have some time. Perhaps put it all in a project box and place it strategically in the house. To explain a little bit about what I did: A problem with socat I had was it seemed to garble the serial data between connected clients, making it useless with more than 1 client(I don't think that's a socat issue though, I think that's because more than one process is trying to access the tty device at once). Ncat fixes that by just repeating anything pushed into it to all connected clients. So it's ttyUSB0/1 <> socat <> ncat <> One of more clients. Hopefully it's useful for people.

29

Online

11.7k

Users

11.2k

Topics

113.1k

Posts