Skip to content

My Project

Show off and share your great projects here! We love pictures!
961 Topics 13.4k Posts
  • Help on Micro:bit sensors IDEA

    2
    0 Votes
    2 Posts
    538 Views
    alowhumA
    Is it possible? Probably. but if you're new to electronics, this sounds like a very daunting task! MySensors is very good at getting sensor data into a database wirelessly. A database/system like Domoticz, for example, will let you create graphs from your data. Challenges to think about: the 3D map will be very distorted. you'll need to make software to do all this. Why not explore photogrammetry instead? There are great apps for that. My recommendation would be to just start with making a basic sensor (perhaps something already on the Micro:bit, like the motion sensor or the magnetic sensor), and get that data into Domoticz. That will spark new ideas, ideas that you will be able to more easily make. For example, you can get some data from place A and use it to actuate a motor/turn something on in place B. One of the first things I ever did was to create a disco lamp that turns on when the temperature reaches 26 degrees celcius. When it gets summer, it's time to party!
  • RFID-RC522 and sending text via serialgateway

    3
    0 Votes
    3 Posts
    621 Views
    O
    I get no output from the card I try to read. When I comment out all lines connected with mysensors library it works There are no errors The sketch checks cards id and returns name of the card owner, if it is known, if not "unknown person" is printed on serial. I wanted to send names detected to domoticz, so based on them it would be possible to create an event 0;255;3;0;9;0 MCO:BGN:INIT GW,CP=R-NGA---,REL=255,VER=2.3.1 0;255;3;0;14;Gateway startup complete. 0;255;0;0;17;2.3.1 0;255;3;0;11;USER 0;255;3;0;12;1.1 0;20;0;0;36; 0;255;3;0;9;9 MCO:BGN:STP 0;255;3;0;9;68 MCO:REG:NOT NEEDED 0;255;3;0;9;71 MCO:BGN:INIT OK,TSP=NA```
  • Strange Situation

    16
    0 Votes
    16 Posts
    1k Views
    zboblamontZ
    @crankycoder Ok on the heater, but what I was getting at was if it is mains borne interference, appliances elsewhere might also trigger the phenomenon but you hadn't noticed as you were not in THAT room.... Sounds like you have some rogue amateur wiring there, for kitchens and bathrooms a ground wire is mandatory for safety I always understood, on a metal ballast case it provides RF shielding. Perhaps you could shield the board for your Light Module if the caps don't sort it out?
  • Where do i start?

    8
    0 Votes
    8 Posts
    1k Views
    rejoe2R
    @reindier Please add some more info on your setup. In general, an ESP8266-based node is only intented to be a gateway (also other hardware con be chosen). Possibilities about using more than one gateway depend on the controller software you intend to use. Some support it, but could have additional restrictions. In general, I'd never use a multiple NodeMCU-setup with sensors directly attached to this MCU type the "MySensors"-way but instead use standard (especially MQTT) options for them (outside MySensors). So what means "arduino" on your setup? Just the Arduino IDE for programming the ESP8266's? If it's really ATMega328 MCU's, I'd go for other transport layers than regular WiFi (eg. use RFM69 transceivers).
  • New Sense Bender GW no USB response

    gw usb
    1
    0 Votes
    1 Posts
    567 Views
    No one has replied
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    17 Views
    No one has replied
  • Portable RFM69 Signal Scanner

    10
    1
    6 Votes
    10 Posts
    9k Views
    gohanG
    Yes, that was Rev 9, but the sketch would work with anything you have
  • DHT11 and Ethernet Gateway with enc28j60

    9
    0 Votes
    9 Posts
    1k Views
    mfalkviddM
    @giangired yes, a counter or using millis() (which technically is a counter) is the right solution. Relay nodes can’t sleep, because nodes can not receive incoming commands when sleeping.
  • BBQ Probes for the Perfect Steak

    6
    0 Votes
    6 Posts
    1k Views
    alowhumA
    What you should look at is the Adafruit_MAX31855 library Then buy a K-type sensor device online. https://github.com/adafruit/Adafruit-MAX31855-library You can also use the cheaper Max6675. Watch the voltage it uses. You'll have so search a bit, but you can also buy meat-probe style K-type sensors at Aliexpress. This code may be of use: /** * * 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. * ******************************* * * DESCRIPTION * * PID smoker, in progress * */ #include <AutoPID.h> //#include <PID_v1.h> //#define PIN_INPUT 0 //#define RELAY_PIN 6 //auto-pid settings and gains #define OUTPUT_MIN 0 #define OUTPUT_MAX 3500 // this should not exceed the ASECOND value below. #define KP 6 #define KI .1 #define KD 10 //Define Variables we'll be connecting to double setPoint, Output; // autopid double smokerSetpoint = 90; double meatSetpoint = 70; double temperatureA = 0; // Holds the temperature of the first MAX sensor. double temperatureB = 0; // Holds the temperature of the second MAX sensor. double temperatureC = 0; // Holds the temperature of the second MAX sensor. //Define the aggressive and conservative PID Tuning Parameters //double Kp=2, Ki=5, Kd=1; // the original middle of the road settings. //double aggKp=4, aggKi=0.2, aggKd=1; // the original aggressive settings. //double aggKp=2, aggKi=2, aggKd=1; //double consKp=1, consKi=0.05, consKd=0.25; /* * P: the bigger the number the harder the controller pushes. * I: the SMALLER the number (except for 0, which turns it off,) the more quickly the controller reacts to load changes, but the greater the risk of oscillations. * D: the bigger the number the more the controller dampens oscillations (to the point where performance can be hindered) * * learn more: http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/ * * 1. Get the Proportional working first. A fast and easy trick is to increase the proportional gain until oscillations start (the critical or ultimate gain) then cut the gain in half. * */ //PID myPID(&temperatureA, &Output, &smokerSetpoint, aggKp, aggKi, aggKd, DIRECT); AutoPID myPID(&temperatureB, &smokerSetpoint, &Output, OUTPUT_MIN, OUTPUT_MAX, KP, KI, KD); #define ACTIVATIONTEMPERATURERANGE 10 // at what temperature delta below or above the target temperature should the PID take over the heating proces? So if the target is 100, then this would be between 70 and 130 degrees. #define HASOLEDSCREEN // Remove this line if you are not using an OLED screen on the node. #define DONTCHECKCONNECTION // Uncomment this line if you do not care if the node loses connection with the controller. #ifdef HASOLEDSCREEN #define OLED_I2C_ADDRESS 0x3C //#include <SPI.h> #include <SSD1306Ascii.h> // simple drivers for the screen. #include <SSD1306AsciiAvrI2c.h> SSD1306AsciiAvrI2c oled; #endif // if you uncomment this, you can get test and debug updates about everything the sensor is doing by using the serial monitor tool. //#define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 // A 2.4Ghz transmitter and receiver, often used with MySensors. //#define MY_RADIO_RFM69 // 433Mhz transmitter and reveiver. //#define MY_RADIO_NRF5_ESB // NRF5 devices //#define MY_RADIO_RFM95 //#define MY_RF24_PA_LEVEL RF24_PA_MIN #define MY_RF24_PA_LEVEL RF24_PA_LOW // This sets a low-power mode for the radio. Useful if you use the version with the bigger antenna, but don't want to power that from a separate power source. It can also fix problems with fake Chinese versions of the radio. //#define MY_RF24_PA_LEVEL RF24_PA_HIGH //#define MY_RF24_PA_LEVEL RF24_PA_MAX // Advanced settings #define MY_TRANSPORT_WAIT_READY_MS 8000 // try connecting for a few seconds. Otherwise just continue. #define MY_SPLASH_SCREEN_DISABLED // saves a little memory. //#define MY_DISABLE_RAM_ROUTING_TABLE_FEATURE // saves a little memory. //#define MY_NODE_ID 100 //#define MY_PARENT_NODE_ID 0 //#define MY_PARENT_NODE_IS_STATIC //#define MY_RF24_CHANNEL 100 // this helps to get a better reception in Europe. The default channel that MySensors uses (76) overlaps with European wifi band 13 :-( // Easy to use security, yay! //#define MY_SIGNING_SIMPLE_PASSWD "putyourpasswordhere" //#define MY_SIGNING_SOFT_RANDOMSEED_PIN A7 // setting a pin to pickup noise makes encryption more secure. // Choose if you want this sensor to also be a repeater. //#define MY_REPEATER_FEATURE // Just remove the two slashes at the beginning of this line to also enable this sensor to act as a repeater for other sensors. If this node is on battery power, you probably shouldn't enable this. // LIBRARIES (in the Arduino IDE go to Sketch -> Include Library -> Manage Libraries to add these if you don't have them installed yet.) #include <MySensors.h> #include "Adafruit_MAX31855.h" // VARIABLES YOU CAN CHANGE #define RELAY_ON 0 // GPIO value to write to turn on attached relay. Some relays are reversed. #define RELAY_OFF 1 // GPIO value to write to turn off attached relay Some relays are reversed. #define HEATER_RELAY_PIN 14 // Arduino Digital I/O pin number for heater relay. 14 = A0, 19 = A5 (A6 and A7 are input only) #define MAXDOA 3 // Pins for the two K-type sensors. #define MAXCSA 4 // Pins for the two K-type sensors. #define MAXCLKA 5 // Pins for the two K-type sensors. #define MAXDOB 6 // Pins for the two K-type sensors. #define MAXCSB 7 // Pins for the two K-type sensors. #define MAXCLKB 8 // Pins for the two K-type sensors. #define ASECOND 4000 // How long does a second take? (default is 1000 milliseconds) #define SAFEGUARD_TEMP 160 // Maximum temperature (currently in celcius) that may be detected before the relay is shutdown. #define RETURNTONORMAL_TEMP 100 // After a safeguard shutdown, at what cooled down temperature (currently in celcius) should the system go back to normal state? #define MAXIMUMCONNECTIONLOSSCOUNT 6 // How many safetycheck will we allow the connected to be down? (6 = 60 seconds) #define MAXIMUMTEMPERATURESENSORERRORS 100 // How many faulty measurements to accept per 10 second period. A faulty sensor will give one error per second. #define SECURITYCHECKINTERVAL 15 // How many seconds before a new security check is performed //VARIABLES YOU PROBABLY SHOULDN'T CHANGE #define TEXT_CHILD_ID 1 // for MySensors. Within a node each sensor/actuator should have its own ID number. #define THERMOSTAT_CHILD_ID 2 #define TEMP_A_CHILD_ID 3 #define TEMP_B_CHILD_ID 4 #define TEMP_C_CHILD_ID 5 // Internal temperature sensor #define POWER_CHILD_ID 6 // The PID's current power output level, as a percentage. #define MEATTARGET_CHILD_ID 7 byte powerPercentage = 0; // The PID's current power output level (relative to the output_max), recalculated as a percentage. boolean meatTemperatureReached = false; // Changes to true when the meat has reached the desired temperature. //boolean runEverySecondThings = true; // this moves the things that are done every second to beyond the part of the second where the device is heating. // initialize the Thermocouple Adafruit_MAX31855 thermocouple(MAXCLKA, MAXCSA, MAXDOA); // This is the enclosure thermometer. This temperature is used to safety checks. Adafruit_MAX31855 thermocoupleb(MAXCLKB, MAXCSB, MAXDOB); // This is the mean temperature. // Security variables boolean runSafetyCheck = true; boolean safetyShutdown = true; // Set to true if something is wrong with the system. This then turns off the relay. boolean targetTooHot = false; // A safety feature. If the device somehow gets really hot, disable the heater. byte connectionLossCounter = 0; // How often did a request to the controller not result in any response? byte tempSensorErrorCount = 0; // How often did the temperature sensor give an error? // Mysensors settings MyMessage statusMsg(TEXT_CHILD_ID,V_TEXT); // Sets up the message format that we'll be sending to the MySensors gateway later. The first part is the ID of the specific sensor module on this node. The second part tells the gateway what kind of data to expect. MyMessage thermostatMsg(THERMOSTAT_CHILD_ID, V_HVAC_SETPOINT_HEAT); MyMessage temperatureMsg(TEMP_A_CHILD_ID, V_TEMP); MyMessage powerMsg(POWER_CHILD_ID, V_PERCENTAGE); // the current powerlevel of the heater, as a percentage. void before() { pinMode(HEATER_RELAY_PIN, OUTPUT); digitalWrite(HEATER_RELAY_PIN, RELAY_OFF); } void setup() { Serial.begin(115200); // for serial debugging. delay(500); Serial.println(F("starting smoker")); // autopid extra options myPID.setTimeStep(ASECOND); myPID.setBangBang(ACTIVATIONTEMPERATURERANGE); // if temperature is more than X degrees below or above setpoint, OUTPUT will be set to min or max respectively. // myPID.setTimeStep(WindowSize); // set autoPID update interval. Currently once every loop. // myPID.setOutputRange(0,maxOutputTime); // what range should the output be between? Maximum size can be the entire loop time. (perhaps this could make the cripledelay superfluous? Just set this to 60% of the window size?) // myPID.SetOutputLimits(0, WindowSize); // tell the PID to range between 0 and the full window size #ifdef HASOLEDSCREEN oled.begin(&Adafruit128x64, OLED_I2C_ADDRESS); oled.setFont(Adafruit5x7); //oled.set2X(); // big letters oled.ssd1306WriteCmd(SSD1306_DISPLAYON); //oled.setScroll(true); oled.setCursor(0,0); oled.print(F("Smoker 1.6")); delay(1000); #endif if(isTransportReady()){ Serial.println(F("Connected to gateway!")); #ifdef HASOLEDSCREEN oled.setCursor(90,0); oled.print(F("W")); #endif send(statusMsg.setSensor(TEXT_CHILD_ID).set( F("Smoker starting") )); //send(thermostatMsg.setSensor(THERMOSTAT_CHILD_ID).set(smokerSetpoint,2)); // should that 2 be a one? Only one decimal? Hmm send(powerMsg.set(powerPercentage)); //send(thermostatMsg.setSensor(MEATTARGET_CHILD_ID).set(meatSetpoint,2)); request(THERMOSTAT_CHILD_ID,V_HVAC_SETPOINT_HEAT); request(MEATTARGET_CHILD_ID,V_HVAC_SETPOINT_HEAT); }else{ Serial.println(F("! NO CONNECTION")); } } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("PID Smoker", "1.6"); present(TEXT_CHILD_ID, S_INFO,"status"); present(THERMOSTAT_CHILD_ID, S_HEATER, "SmokerSetpoint"); present(TEMP_A_CHILD_ID, S_TEMP, "Temperature A"); present(TEMP_B_CHILD_ID, S_TEMP, "Temperature B"); present(TEMP_C_CHILD_ID, S_TEMP, "Temperature internal"); present(POWER_CHILD_ID, S_DIMMER, "Powerlevel"); present(MEATTARGET_CHILD_ID, S_HEATER, "Meat target temperature"); } void loop() { // the clock static unsigned long lastClockTick = 0; // When was the last second of the clock. static byte secondCounter = 0; // How many seconds have passed // // A. // CONTINUOUSLY // call the PID function, check if the heating element should be on or off. // if (safetyShutdown == true) { myPID.stop(); digitalWrite(HEATER_RELAY_PIN, RELAY_OFF); } else { myPID.run(); //autopid, call every loop, updates automatically at certain time interval //if (ASECOND - (millis() - lastClockTick) < Output{ if ((millis() - lastClockTick) < Output){ digitalWrite(HEATER_RELAY_PIN, RELAY_ON); Serial.print(F("|")); }else{ digitalWrite(HEATER_RELAY_PIN, RELAY_OFF); Serial.print(F("_")); } delay(100); /* if(temperatureB > smokerSetpoint){ digitalWrite(HEATER_RELAY_PIN, RELAY_ON); }else{ digitalWrite(HEATER_RELAY_PIN, RELAY_OFF); } */ } // // B. // EVERY SECOND // check temperature, calculate new PID value, update display. // if(millis() - lastClockTick >= ASECOND) { lastClockTick = millis(); secondCounter++; //runEverySecondThings = true; Serial.println(); if(secondCounter > SECURITYCHECKINTERVAL){ secondCounter = 0; runSafetyCheck = true; } Serial.print(F("#"));Serial.println(secondCounter); //} //if(runEverySecondThings == true && millis() - lastClockTick >= OUTPUT_MAX + 10){ // this moves all the calculations for getting temperature and pdating the screen to the part of the second loop after the heating is finished. // this moves all the calculations for getting temperature and pdating the screen to the part of the second loop after the heating is finished. // output the value form the PID algorithm. Serial.println(); Serial.print(F("output: ")); Serial.println(Output); powerPercentage = map(Output, 0, OUTPUT_MAX, 0, 100); Serial.print(F("power percentage: ")); Serial.println(powerPercentage); // getting latest temperature data double temperatureAreading = 0;//thermocouple.readCelsius(); double temperatureBreading = thermocoupleb.readCelsius(); temperatureC = thermocouple.readInternal(); Serial.print(F("A: "));Serial.println(temperatureA); Serial.print(F("B: "));Serial.println(temperatureB); Serial.print(F("Int: "));Serial.println(temperatureC); // Check if the temperature values are realistic, or that they indicate a sensor problem. if (isnan(temperatureAreading) || temperatureAreading == 0) { tempSensorErrorCount++; } else { temperatureA = temperatureAreading; // avoiding NaN } if (isnan(temperatureBreading) || temperatureBreading == 0) { tempSensorErrorCount++; } else { temperatureB = temperatureBreading; // This makes sure the PID algorithms is only fed with real temperatures. } if (isnan(temperatureC) || temperatureC == 0) { tempSensorErrorCount++; } // every second update the display #ifdef HASOLEDSCREEN if(safetyShutdown == false){ //oled.set2X(); oled.setCursor(0,0); if(myPID.atSetPoint(ACTIVATIONTEMPERATURERANGE)){ oled.print(F("PID:")); }else{ oled.print(F("PRE:")); } oled.print(powerPercentage); oled.print(F("% ")); //}else{ // if(temperatureB < smokerSetpoint){ // oled.print(F("HEAT: ")); oled.print(powerPercentage); oled.print(F("% ")); // }else{ // oled.print(F("COOLING")); // } //} // show temperature sensor values oled.set2X(); oled.setCursor(0,2); oled.print(F("Pot: ")); oled.print(temperatureB); oled.println(F(" ")); oled.setCursor(0,5); oled.print(F("Meat:")); oled.print(temperatureA); oled.println(F(" ")); // show setpoint target temperatures oled.set1X(); oled.setCursor(60,4); oled.print(F("-> ")); oled.print(smokerSetpoint); oled.setCursor(60,7); oled.print(F("-> ")); oled.print(meatSetpoint); // show wireless connection icon (if there is a connection) oled.setCursor(90,0); if(connectionLossCounter > 1){ // If the connection is bad, hide the wireless icon. oled.print(F(" ")); } //show second counter oled.setCursor(100,0); oled.print(secondCounter); oled.print(F(" ")); } #endif // some debug options. //double pulseLength = myPID.getPulseValue(); //Serial.print(F("pulse value: ")); Serial.println(pulseLength); double integraal = myPID.getIntegral(); Serial.print(F("integraal: ")); Serial.println(integraal); //runEverySecondThings = false; } // end of the part that runs every second // // C. // EVERY TEN SECONDS // safety check, communicate with server, is the meat hot? // if(runSafetyCheck == true){ // the second part moves this work to beyond the heating part of the cycle. This way it shouldn't influence the heating length, and this the PID calculations. Serial.println(F("")); Serial.println(F("STARTING SAFETY CHECK ETC")); runSafetyCheck = false; // A. // CHECKING - Every 10 seconds we do a safety check. // is the server up? connectionLossCounter++; if ( connectionLossCounter > 250 ) { connectionLossCounter = 251; } // get latest setpoint values. (might not be required, some controllers send this when the values update.) //request(THERMOSTAT_CHILD_ID,V_HVAC_SETPOINT_HEAT); // every 10 seconds, request the latest smokerSetpoint data. Also used to check if the wireless connection if still alive. In theory domoticz should now pro-actively send the new data to the node, so then this code is just useful to check the connection. //request(MEATTARGET_CHILD_ID,V_HVAC_SETPOINT_HEAT); // check connection if(connectionLossCounter > MAXIMUMCONNECTIONLOSSCOUNT){ // connected lost for X amount of safety checks. Serial.println(F("! LOST CONNECTION TO SERVER")); #ifdef HASOLEDSCREEN oled.setScroll(true); oled.println(F("NO CONNECTION")); #endif } // heater not too hot? if(temperatureA > SAFEGUARD_TEMP || temperatureB > SAFEGUARD_TEMP){ targetTooHot = true; Serial.println(F("! TOO HOT")); #ifdef HASOLEDSCREEN oled.setScroll(true); oled.println(F("TOO HOT")); #endif } // Not too many errors with the temperature sensor(s)? Serial.print(F("tempSensorErrorCount: ")); Serial.println(tempSensorErrorCount); if(tempSensorErrorCount > MAXIMUMTEMPERATURESENSORERRORS){ Serial.println(F("TEMPERATURE SENSOR ERROR")); #ifdef HASOLEDSCREEN oled.setScroll(true); oled.println(F("SENSOR ERROR")); #endif } // B. // HEALING - Some functions might return, and then the system could return to normal. // It has cooled down enough if(safetyShutdown == true && targetTooHot == true && temperatureB > RETURNTONORMAL_TEMP){ // For safety, the "return to normal" temperature is lower than the maximum room temperature. This avoids flip-flopping. Serial.println(F("too hot, cooling down")); #ifdef HASOLEDSCREEN oled.println(F("COOLING DOWN!")); #endif }else if(targetTooHot == true && temperatureB <= RETURNTONORMAL_TEMP){ targetTooHot = false; } // C. // DECIDE IF OPERATION IS SAFE #ifdef DONTCHECKCONNECTION connectionLossCounter = 0; // pretend there is no connection error, even if there is. #endif if(tempSensorErrorCount > MAXIMUMTEMPERATURESENSORERRORS || connectionLossCounter > MAXIMUMCONNECTIONLOSSCOUNT || targetTooHot == true){ // Decision: something is wrong, so SHUTDOWN the relay. Serial.println(F("! ERROR DETECTED")); if(safetyShutdown == false){ // first time that the error is detected send(statusMsg.setSensor(TEXT_CHILD_ID).set( F("ERROR") )); } safetyShutdown = true; Serial.println(F("CURRENTLY IN SAFETY SHUTDOWN MODE")); #ifdef HASOLEDSCREEN oled.setScroll(true); oled.println(F("SAFETY SHUTDOWN!")); #endif }else{ // Decision: everything looks OK. Serial.println(F("EVERYTHING LOOKS OK")); if(safetyShutdown == true){ send(statusMsg.setSensor(TEXT_CHILD_ID).set( F("SMOKER OK") )); Serial.println(F("heater is ok again")); #ifdef HASOLEDSCREEN oled.setScroll(false); // the scrollmode causes flickering of the screen. For normal operation, the display function only redraws parts of the screen. #endif } safetyShutdown = false; } tempSensorErrorCount = 0; // reset for next round of counting. // send the temperature data to the controller if(!isnan(temperatureB)){ Serial.println(F("sending temp B to controller")); send(temperatureMsg.setSensor(TEMP_B_CHILD_ID).set(temperatureB, 1)); } if(!isnan(temperatureA)){ Serial.println(F("sending temp A to controller")); send(temperatureMsg.setSensor(TEMP_A_CHILD_ID).set(temperatureA, 1)); } if(!isnan(temperatureC)){ Serial.println(F("sending temp C to controller")); send(temperatureMsg.setSensor(TEMP_C_CHILD_ID).set(temperatureC, 1)); } } // end of the part that runs every 10 seconds } // end of main loop void receive(const MyMessage &message){ Serial.println(F("+++receiving message+++")); connectionLossCounter = 0; // reset the counter, indicating we have recently connected to the controller. #ifdef HASOLEDSCREEN // show wireless connection icon oled.set1X(); oled.setCursor(90,0); oled.print(F("W")); #endif /* if (message.type == V_TEXT && message.sensor == THERMOSTAT_CHILD_ID) { Serial.print(F("Received text data: ")); Serial.println(message.data); // Not doing anything with this. }*/ if (message.type == V_HVAC_SETPOINT_HEAT) { if(message.sensor == THERMOSTAT_CHILD_ID){ smokerSetpoint = atof(message.data); Serial.print(F("smokerSetpoint: ")); Serial.println(smokerSetpoint); send(thermostatMsg.setSensor(THERMOSTAT_CHILD_ID).set(smokerSetpoint,2)); // this fixes a bug in domoticz where the display in domoticz doesn't itself update the new setpoint. } if(message.sensor == MEATTARGET_CHILD_ID){ meatSetpoint = atof(message.data); Serial.print(F("meatSetpoint: ")); Serial.println(meatSetpoint); send(thermostatMsg.setSensor(MEATTARGET_CHILD_ID).set(meatSetpoint,2)); // this fixes a bug in domoticz where the display in domoticz doesn't itself update the new setpoint. } } }
  • RS485 Gatway with relay and DS18B20 sensors

    3
    0 Votes
    3 Posts
    963 Views
    butalukB
    Thank you for your support! It now works without losing some switching commands. I have adapted the Gateway software according to your suggestions. And in the fhem, I defined the devices as follows: define MYSENSOR_10 MYSENSORS_DEVICE 10 setuuid MYSENSOR_10 5c61b043-f33f-3ee4-4a0b-da4876cebf4faa94 attr MYSENSOR_10 IODev meinMSG attr MYSENSOR_10 mapReading_id4 4 id attr MYSENSOR_10 mapReading_id5 5 id attr MYSENSOR_10 mapReading_id6 6 id attr MYSENSOR_10 mapReading_id7 7 id attr MYSENSOR_10 mapReading_power 0 power attr MYSENSOR_10 mapReading_power1 1 power attr MYSENSOR_10 mapReading_power2 2 power attr MYSENSOR_10 mapReading_power3 3 power attr MYSENSOR_10 mapReading_status 0 status attr MYSENSOR_10 mapReading_status1 1 status attr MYSENSOR_10 mapReading_status2 2 status attr MYSENSOR_10 mapReading_status3 3 status attr MYSENSOR_10 mapReading_temperature4 4 temperature attr MYSENSOR_10 mapReading_temperature5 5 temperature attr MYSENSOR_10 mapReading_temperature6 6 temperature attr MYSENSOR_10 mapReading_temperature7 7 temperature attr MYSENSOR_10 mode node attr MYSENSOR_10 requestAck 1 attr MYSENSOR_10 room Heizung_OG attr MYSENSOR_10 setReading_power 1 attr MYSENSOR_10 setReading_power1 1 attr MYSENSOR_10 setReading_power2 1 attr MYSENSOR_10 setReading_power3 1 attr MYSENSOR_10 setReading_status off,on attr MYSENSOR_10 setReading_status1 off,on attr MYSENSOR_10 setReading_status2 off,on attr MYSENSOR_10 setReading_status3 off,on To control the relays individually, I defined a "readingsProxy" for each relay: define Relais1 readingsProxy MYSENSOR_10:status attr Relais1 devStateIcon on:sani_heating_level_100@red:off off:sani_heating_level_0@#18B8ED:on attr Relais1 group Heizungskreise, attr Relais1 room Heizung_OG attr Relais1 setFn {($CMD eq "on")?"status on":"status off"} attr Relais1 setList on off Thank you!
  • 'Mysensor' a smoke detector with sound detection

    9
    0 Votes
    9 Posts
    2k Views
    ileneken3I
    @tmaster Actually, the KY-038 works exactly what I want (except for the power consumption). I also have ones that are connect to mains power, and the false alarms are rare. Also, I have the Arduino programmed to sleep some time after detecting a sound and sending a message. In the case of a real alarm, it will keep sending regularly, which would make it obvious. The "batteries just end in a few months" is what I'm asking about - avoiding the .4ma used by the LM393. I'm hoping I can replace it with the LMV393, but I'm not sure if it will work. Regarding the "you think you are safe", Mysensors has heartbeats, and battery percentage reporting to deal with all that.
  • UV skin type sensor

    2
    1 Votes
    2 Posts
    713 Views
    YveauxY
    @teecee1337 hi, and welcome to the forum! As the proof of the pudding is in the reading I would order some sensors and just give it a try. The sparkfun sensors seem easy to get started. They communicate through i2c and come with an Arduino library so it should be easy to get some readings out.
  • A sensor to detect breathing

    6
    0 Votes
    6 Posts
    1k Views
    bjacobseB
    @artag Yes I agree, the anemometer should also have a very short responsetime, so it's possible to sense breathing
  • 6 Votes
    113 Posts
    61k Views
    alx6thsA
    Ok, it works. Looks like the problem was caused by windows sensors that were not connected but initialized, so they were missing. I removed them in the MAX software and then everything was displayed correctly. Thank you for this great project! :+1:
  • coin-cell (CR2032) powered temperature sensor

    39
    3 Votes
    39 Posts
    23k Views
    E
    Hello fleinze, What about this project? Your sensors still working? I'm trying to build the same but I have some problem to change the efuse value: "I changed the efuse value to 0x07 (BOD off)" I' dont know how to edit the boards.txt file and how to install it in the arduino pro mini. Could you explain the procedure step by step or link me a good complete tutorial ? Thank you very much
  • My very first mysensors node!

    3
    1
    2 Votes
    3 Posts
    1k Views
    M
    I have problem now with Home Assistant and this node. It works perfectly reading temperature, humidity and the door status. But with the light switch if HA goes to a state where light status is "on" but brightness is "0" it doesn't respond until I manually set the brightness to "100". I tried this with mysensors library version 2.3.1 and 2.2.0 but the behaviour is the same. My gateway version is 2.1.0 Here is the code for the node. There is nothing special on HA end. I'm running hass.io latest version 0.84.6 and lovelace GUI. Sorry for the comments in the code, they are part english and part finnish :) Just this issue to solve and one package from China and I'll get the power supplys and nodes ready. Then pretty soon I'll have 10 mysensors nodes running! I already started with some Sonoff's in the middle froor, four now installed and one waiting for a suitable application. /* * NODE ID: 2 * Tämä on alasisäeteisen node jossa on: * - DHT22 -> lämpö ja kosteus * - Releohjaus sisäeteisen valoille (kytkin+rele) * - Ovitunnistin (hall-anturi) * Kytkennät: * - 5=DHT22 * - 4=Releohjaus * - 3=Yläkerran valokytkin * - 6=Alakerran valokytkin * - 2=Ovitunnistin */ // Enable debug prints //#define MY_DEBUG // Noden ID (oltava kaikissa eri!!) #define MY_NODE_ID 2 // Enable and select radio type attached #define MY_RADIO_RF24 //#define MY_RADIO_RFM69 #define MY_REPEATER_FEATURE #include <SPI.h> #include <MySensors.h> #include <Bounce2.h> #include <DHT.h> #include <SimpleTimer.h> #define DOOR_PIN 2 // Ovikytkin #define BUTTON_PIN 3 // Yläkerran valokytkin #define BUTTON_PIN_2 6 // Alakerran valokytkin #define RELAY_PIN 4 // Rele (valo) #define DHT_DATA_PIN 5 // Lämpötila-anturi DHT22 #define CHILD_ID_LIGHT 1 #define CHILD_ID_HUM 2 #define CHILD_ID_TEMP 3 #define CHILD_ID_DOOR 4 #define LIGHT_OFF 0 #define LIGHT_ON 1 #define RELAY_ON 0 #define RELAY_OFF 1 #define DOOR_CLOSED 0 #define DOOR_OPEN 1 #define SENSOR_TEMP_OFFSET 0 // DHT22 lämpötilan offsetti #define SN "kellari_sisaeteinen" #define SV "1.2" // Force sending an update of the temperature after n sensor reads, so a controller showing the // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that // the value didn't change since; // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms] static const uint8_t FORCE_UPDATE_N_READS = 10; float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; int16_t last_state = LIGHT_OFF; int16_t last_dim = 0; // Yläkerran valokytkimen luku Bounce debouncer = Bounce(); // Alakerran valokytkimen luku Bounce debouncer_2 = Bounce(); // Ovikytkimen luku Bounce ovidebouncer = Bounce(); // Lämpötila-anturin oliot DHT dht; SimpleTimer timer; MyMessage light_msg( CHILD_ID_LIGHT, V_STATUS ); MyMessage dimmer_msg( CHILD_ID_LIGHT, V_PERCENTAGE ); MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgOvi(CHILD_ID_DOOR, V_TRIPPED); void setup() { dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); update_light(); //Serial.println( "Node ready to receive messages..." ); // Setup the buttons pinMode(BUTTON_PIN,INPUT); pinMode(BUTTON_PIN_2,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); digitalWrite(BUTTON_PIN_2,HIGH); // Make sure relays are off when starting up digitalWrite(RELAY_PIN, RELAY_OFF); // Then set relay pins in output mode pinMode(RELAY_PIN, OUTPUT); // Yläkerran valokytkin debouncer.attach(BUTTON_PIN, INPUT_PULLUP); debouncer.interval(25); // Alakerran valokytkin debouncer_2.attach(BUTTON_PIN_2, INPUT_PULLUP); debouncer_2.interval(25); // Ovikytkin ovidebouncer.attach(DOOR_PIN, INPUT_PULLUP); ovidebouncer.interval(25); // Timer lämpötila-anturin lukemista varten (millisekunteja) eli luetaan 1min välein timer.setInterval(60000, lampotilaLuku); } void loop() { //In MySensors2.x, first message must come from within loop() static bool first_message_sent = false; if ( first_message_sent == false ) { //Serial.println( "Sending initial state..." ); send_dimmer_message(); send_status_message(); lampotilaLuku(); send(msgOvi.set(DOOR_CLOSED)); first_message_sent = true; } debouncer.update(); // Update the Bounce instance (yläkerran valokytkin) // Laskevan reunan tunnistus (yläkerran valokytkin) if ( debouncer.fell() ) { //Serial.println( "Laskeva reuna" ); nappiPainettu(); // Valon ohjaus } // Nousevan reunan tunnistus (yläkerran valokytkin) if ( debouncer.rose() ) { //Serial.println( "Nouseva reuna" ); nappiPainettu(); // Valon ohjaus } debouncer_2.update(); // Update the Bounce instance (alakerran valokytkin) // Laskevan reunan tunnistus (alakerran valokytkin) if ( debouncer_2.fell() ) { //Serial.println( "Laskeva reuna" ); nappiPainettu(); // Valon ohjaus } // Nousevan reunan tunnistus (alakerran valokytkin) if ( debouncer_2.rose() ) { //Serial.println( "Nouseva reuna" ); nappiPainettu(); // Valon ohjaus } // Ovitunnistimen luku if (ovidebouncer.update()) { // Get the update value. int value = ovidebouncer.read(); // Send in the new value. //Serial.println( "Oven status muuttui" ); send(msgOvi.set(value==HIGH ? 1 : 0)); } // Lämpötila-anturin timer pyörii.. timer.run(); } void presentation() { // Send the sketch version information to the gateway sendSketchInfo( SN, SV ); present( CHILD_ID_LIGHT, S_DIMMER ); present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_DOOR, S_DOOR); metric = true; // Lämpötila-anturi } // Vastaanotetaan HA:lta komentoja void receive(const MyMessage &message) { //When receiving a V_STATUS command, switch the light between OFF //and the last received dimmer value // Tämä on ON/OFF viesti HA:lta if ( message.type == V_STATUS ) { //Serial.println( "V_STATUS command received..." ); int lstate = message.getInt(); if (( lstate < 0 ) || ( lstate > 1 )) { //Serial.println( "V_STATUS data invalid (should be 0/1)" ); return; } last_state = lstate; //If last dimmer state is zero, set dimmer to 100 if (( last_state == LIGHT_ON ) && ( last_dim == 0 )) { last_dim=100; } //Update constroller status send_status_message(); } // Tämä on himmennys viesti HA:lta else if ( message.type == V_PERCENTAGE ) { //Serial.println( "V_PERCENTAGE command received..." ); int dim_value = constrain( message.getInt(), 0, 100 ); if ( dim_value == 0 ) { last_state = LIGHT_OFF; //Update constroller with dimmer value & status send_dimmer_message(); send_status_message(); } else { last_state = LIGHT_ON; last_dim = dim_value; //Update constroller with dimmer value send_dimmer_message(); } } else { //Serial.println( "Invalid command received..." ); return; } //Here you set the actual light state/level update_light(); } // Releen ohjaus statuksen perusteella void update_light() { if ( last_state == LIGHT_OFF ) { //Serial.println( "Light state: OFF" ); digitalWrite(RELAY_PIN, RELAY_OFF); } else { //Serial.print( "Light state: ON, Level: " ); //Serial.println( last_dim ); digitalWrite(RELAY_PIN, RELAY_ON); } } // Lähetetään HA:lle dimmer arvo void send_dimmer_message() { send( dimmer_msg.set( last_dim ) ); } // Lähetetään HA:lle valon status (ON/OFF) void send_status_message() { if ( last_state == LIGHT_OFF ) { send( light_msg.set( (int16_t)0) ); } else { send( light_msg.set( (int16_t)1) ); } } // Luetaan DHT22 arvot void lampotilaLuku() { // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { //Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG //Serial.print("T: "); //Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { //Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG //Serial.print("H: "); //Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } } // Napin painon jälkeen valon ohjaus ja statuksen päivitys void nappiPainettu() { if (last_state == LIGHT_ON) { //Serial.println( "Valo OFF napista" ); last_state = LIGHT_OFF; last_dim=0; update_light(); // Releen toggle } else { //Serial.println( "Valo ON napista" ); last_state = LIGHT_ON; last_dim=100; update_light(); // Releen toggle } //Serial.println( "Lahetetaan HA:lle uusi status" ); send_status_message(); // Lähetä HA:lle uusi status (ON/OFF) send_dimmer_message(); // Lähetä HA:lle uusi dim arvo (0/100) } Here are parts concerning from configuration.yaml file: # Mysensors serial gateway config mysensors: gateways: - device: '/dev/ttyACM0' baud_rate: 115200 persistence_file: '/config/mysensors.json' optimistic: false persistence: true version: 2.0
  • ESP32 based IoT gateway/control hub with TFT, touch, RFM69 and more..

    23
    7 Votes
    23 Posts
    6k Views
    M
    @nca78 said in ESP32 based IoT gateway/control hub with TFT, touch, RFM69 and more..: Bodmer TFT eSPI Bodmer TFT eSPI is just a normal SPI driver, well maybe optimized a bit. The key to speed (IMHO) is to use double frame buffer and DMA for the SPI, that leaves the CPU free to process the next frame while the hardware does the SPI transfer. I am not aware of such TFT library for Arduino.
  • Sensor required to detect PVC insulated COPPER wire

    14
    1
    0 Votes
    14 Posts
    2k Views
    K
    @hard-shovel But mesh is on other direction too - parallel with movement and sure not still at the same position and pure parallel. So digital signal can be generated longer time than you expected. [image: 1546467669008-img_20190102_231437.jpg]
  • 2 Votes
    4 Posts
    2k Views
    Nca78N
    @user2684 I forgot to tell you to buy one with a cable. They use a connector with 1.25mm spacing and it is not possible to connect anything else. You can make the cable breadboard friendly by soldering the ends to a 2.54mm header. [image: 1546224745347-img_20181231_095020-2-resized.jpg]
  • Reporting an independent float switch and relay

    7
    0 Votes
    7 Posts
    968 Views
    S
    Success. stole some code from a post a while ago: No concept of how efficient this is, but hey... 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-2018 Sensnology AB Full contributor list: https://github.com/mysensors/MySensors/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 Version 1.0 - Henrik Ekblad DESCRIPTION Example sketch showing how to control physical relays. This example will remember relay state after power failure. http://www.mysensors.org/build/relay */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_RF24 //#define MY_RADIO_NRF5_ESB //#define MY_RADIO_RFM69 //#define MY_RADIO_RFM95 // Enable repeater functionality for this node //#define MY_REPEATER_FEATURE #include <MyConfig.h> #include <MySensors.h> #include <SPI.h> #define RELAY_PIN 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define FLOAT_SWITCH_PIN 3 //FLOAT SWITCH PIN #define LED_GRN_PIN 7 #define LED_RED_PIN 8 #define MY_TRANSPORT_WAIT_READY_MS (3000) #define CHILD_ID 4 #define RELAY_ON 1 #define RELAY_OFF 0 boolean lastSensorState; unsigned long lastUpdate; MyMessage msg(CHILD_ID, V_STATUS); void setup() { pinMode(RELAY_PIN, OUTPUT); pinMode(FLOAT_SWITCH_PIN, INPUT); // Define LED pinMode(LED_GRN_PIN, OUTPUT); pinMode(LED_RED_PIN, OUTPUT); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Rollermat", "3.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_BINARY); } void loop() { // LOW corresponds to the float switch being at its highest point (i.e. rollermat is clogged) if(digitalRead(FLOAT_SWITCH_PIN) == LOW) { digitalWrite(RELAY_PIN, RELAY_ON); //turn on the motor digitalWrite(LED_GRN_PIN, LOW); //turns on the Green LED digitalWrite(LED_RED_PIN, HIGH); //turns off the Red LED } //otherwise the float switch is HIGH // HIGH corresponds to the float switch being at its lowest point (i.e. rollermat is clean and water is flowing) else { digitalWrite(RELAY_PIN, RELAY_OFF); //turns off the pump digitalWrite(LED_GRN_PIN, HIGH); //turns off the Green LED digitalWrite(LED_RED_PIN, LOW); //turns on the Red LED } boolean sensorState = digitalRead(FLOAT_SWITCH_PIN); if (sensorState != lastSensorState) { #ifdef DEBUG digitalWrite(FLOAT_SWITCH_PIN,sensorState? HIGH : LOW); Serial.println(sensorState? "Motor On" : "Motor Off"); #endif send(msg.set(sensorState?"1":"0")); // Update gateway on change of state lastSensorState = sensorState; } }

32

Online

11.7k

Users

11.2k

Topics

113.1k

Posts