Wuffi0815
@Wuffi0815
Best posts made by Wuffi0815
Latest posts made by Wuffi0815
-
RE: With MySensors PC cold start!
Should run as a server. If remote access fails.
Just needed a sketch that allowed me to control 3 different relays.
Or. As template -
With MySensors PC cold start!
Can someone help me or write a sketch?
I would like to start my PC using Arduino, shutdown and reset!On a normal PC you connect so only pin against the desired mode.
Pin 1 - mass short passage = PC starts
Pin 1 - Ground Long Pass Approx. 5sec = PC Shuts down
Pin 2 - Ground Short Circuit = PC Reset
A little I have already prepared. I have to search for everything and I do not know the language that way.
Thank you
#define MY_DEBUG #define MY_NODE_ID AUTO #define MY_RADIO_NRF24 #define MY_REPEATER_FEATURE #define PULSE_TIME 500UL // half a second boolean goPulse; unsigned long pulseStartTime; #include <MySensors.h> #define RELAY_PIN_A 4 #define RELAY_PIN_B 5 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define NUMBER_OF_RELAYS 2 // Total number of attached relays #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay void before() { for (int sensor=1, pin=RELAY_PIN_A; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Then set relay pins in output mode pinMode(pin, OUTPUT); } for (int sensor=1, pin=RELAY_PIN_B; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Then set relay pins in output mode pinMode(pin, OUTPUT); } } void setup() { } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Relay", "1.0"); for (int sensor=1, pin=RELAY_PIN_A; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); } for (int sensor=1, pin=RELAY_PIN_B; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); } } 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_STATUS) { // Change relay state digitalWrite(message.sensor-1+RELAY_PIN_A, message.getBool()?RELAY_ON:RELAY_OFF); goPulse = true; pulseStartTime = millis(); digitalWrite(message.sensor-1+RELAY_PIN_B, message.getBool()?RELAY_ON:RELAY_OFF); // Store state in eeprom saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } relayPulse(); } void relayPulse() { if (goPulse) { if (millis() - pulseStartTime < PULSE_TIME) { digitalWrite(RELAY_PIN_A, RELAY_OFF);// didn't know your pin } else { digitalWrite(RELAY_PIN_B, RELAY_OFF); // didn't know your pin goPulse = false; } } }
-
RE: Help Please "Rain Water Tank"
Works fine so far but the relay can not be controlled after about 30min.
Can it be that my arduino nano pro is too weak?
// Enable debug prints #define MY_DEBUG #define MY_NODE_ID 103 // Enable and select radio type attached #define MY_RADIO_NRF24 #define MY_REPEATER_FEATURE #include <SPI.h> #include <MySensors.h> #include <NewPing.h> #define CHILD_ID_V 2 #define CHILD_ID_D 3 #define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor. #define ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor. #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. #define RELAY_PIN 4 // Arduino Digital I/O pin number for first relay #define NUMBER_OF_RELAYS 1 // Total number of attached relays #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay //constant to calculate the volume of the tank #define high_water_level 230 //tank depth from the lowest point to the max water level #define distance_sensor 10 //distance in cm between the max water level and the sensor #define tank_volume 15000 //tank volume when it is fitted to the max water level unsigned long SLEEP_TIME = 36000; // Sleep time between reads (in milliseconds)3600000 = 1h NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. MyMessage volume_msg(CHILD_ID_V, V_VOLUME); MyMessage distance_msg(CHILD_ID_D, V_DISTANCE); int lastDist; bool metric = true; 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); } } void setup() { metric = getControllerConfig().isMetric; } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Rain Water Tank", "1.0"); for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); } // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_V, S_WATER); present(CHILD_ID_D, S_DISTANCE); } void loop() { int dist = metric?sonar.ping_cm():sonar.ping_in(); Serial.print("Volume "); Serial.print(tank_level("liters")); Serial.println("L"); Serial.print("Ping: "); Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range) Serial.println(metric?" cm":" in"); if (dist != lastDist) { send(distance_msg.set(dist)); lastDist = dist; } send(volume_msg.set(tank_level("liters"))); sleep(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(message.sensor-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF); // Store state in eeprom saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } } //function to measure and convert the tank volume int tank_level(String unit) { int level_liters = 0,level_percent = 0, echo_us = 0, echo_cm = 0, water_level_cm = 0; echo_us = sonar.ping_median(); //return the median time of 5measures between the ping and the echo in microseconds echo_cm = echo_us / US_ROUNDTRIP_CM; //convert the echo time to distance in cm. water_level_cm = high_water_level - (echo_cm - distance_sensor); level_liters = water_level_cm * ((tank_volume) / high_water_level); level_percent = (water_level_cm * 100) / high_water_level; if (unit == "liters") { return level_liters; } else if (unit == "percent") { return level_percent; } else { return 0; } }
-
RE: Help Please "Rain Water Tank"
Thank You Is working!
From time to time you overlook small errors with great effect. -
RE: Help Please "Rain Water Tank"
The distance is not displayed. And goes into a loop.
Sometimes I have to refresh 2-3xno Connect: !TSF:MSG:SEND,102-103-0-0,s=1,c=1,t=35,pt=2,l=2,sg=0,ft=5,st=NACK:2457
-
RE: Help Please "Rain Water Tank"
I want to know the filling level of the tank and drive a pump.
Should everything also run in fhem.
Components: Arduino; HC-SR04; 10 A 1 Channel Arduino Compatible Relay Module
-
Help Please "Rain Water Tank"
I have a problem with my sketch.
Can somebody help me?// Enable debug prints #define MY_DEBUG #define MY_NODE_ID 103 // Enable and select radio type attached #define MY_RADIO_NRF24 #define MY_REPEATER_FEATURE #include <SPI.h> #include <MySensors.h> #include <NewPing.h> #define CHILD_ID_V 0 #define CHILD_ID_D 1 #define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor. #define ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor. #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. #define RELAY_PIN 4 // Arduino Digital I/O pin number for first relay #define NUMBER_OF_RELAYS 1 // Total number of attached relays #define RELAY_ON 1 // GPIO value to write to turn on attached relay #define RELAY_OFF 0 // GPIO value to write to turn off attached relay //constant to calculate the volume of the tank #define high_water_level 230 //tank depth from the lowest point to the max water level #define distance_sensor 10 //distance in cm between the max water level and the sensor #define tank_volume 15000 //tank volume when it is fitted to the max water level unsigned long SLEEP_TIME = 3000; // Sleep time between reads (in milliseconds) NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. MyMessage volume_msg(CHILD_ID_V, V_VOLUME); MyMessage distance_msg(CHILD_ID_D, V_DISTANCE); int lastDist; bool metric = true; 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); } } void setup() { metric = getControllerConfig().isMetric; } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Rain Water Tank", "1.0"); for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); } // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_V, S_WATER); present(CHILD_ID_D, S_DISTANCE); } void loop() { int dist = metric?sonar.ping_cm():sonar.ping_in(); Serial.print("Volume "); Serial.print(tank_level("liters")); Serial.println("L"); Serial.print("Ping: "); Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range) Serial.println(metric?" cm":" in"); if (dist != lastDist) { send(distance_msg.set(dist)); lastDist = dist; } send(volume_msg.set(tank_level("liters"))); sleep(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(message.sensor-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF); // Store state in eeprom saveState(message.sensor, message.getBool()); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } } //function to measure and convert the tank volume int tank_level(String unit) { int level_liters = 0,level_percent = 0, echo_us = 0, echo_cm = 0, water_level_cm = 0; echo_us = sonar.ping_median(); //return the median time of 5measures between the ping and the echo in microseconds echo_cm = echo_us / US_ROUNDTRIP_CM; //convert the echo time to distance in cm. water_level_cm = high_water_level - (echo_cm - distance_sensor); level_liters = water_level_cm * ((tank_volume) / high_water_level); level_percent = (water_level_cm * 100) / high_water_level; if (unit == "liters") { return level_liters; } else if (unit == "percent") { return level_percent; } else { return 0; } }
-
RE: Problem with Wind Speed sensor
Hello I bought a TX23 and wanted to integrate it into FHEM.
Could anyone look over the scetch if it is correct?/** # Arduino-LaCrosse-TX23-Library LaCrosse TX23 is a wind speed and direction sensor. It uses 3 wires for communication and power: Pin1 - Brown(Black) - DATA Pin2 - Red - Vcc Pin3 - Green - N/C Pin4 - Yellow - GND DATA pin is to be connected directly to one of Arduino ports. */ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <MySensors.h> #include <SPI.h> #include <LaCrosse_TX23.h> #define CHILD_ID_WIND 1 //DATA wire connected to arduino port 4 LaCrosse_TX23 anemometer = LaCrosse_TX23(4); // standard messages MyMessage msgWSpeed(CHILD_ID_WIND, V_WIND); MyMessage msgWDirection(CHILD_ID_WIND, V_DIRECTION); void setup(){ } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Wind Sensor", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_WIND, S_WIND); } void loop() { //String dirTable[]= {"N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"}; String dirTable[]= {"0","22.5","45","67.5","90","112.5","135","157.5","180","202.5","225","247.5","270","292.5","315","337.5"}; float speed; float a = 22.5; int direction; if(anemometer.read(speed, direction)) { send(msgWDirection.set(direction*a ,1)); send(msgWSpeed.set(speed, 1)); Serial.println("Speed = " + String(speed,1) + " m/s"); Serial.println("Dir = " + dirTable[direction] + " Grad"); } else { Serial.println("Read error"); } //delay between succesive read requests must be at least 2sec, otherwise wind speed will read 0. delay(2000); }
Thank you