I did a project to automate my folding blinds and used MySensors in combination with Pimatic.
The blinds are driven by a servo motor and controlled by a end microswitch and a Hall sensor. And it has the posibility to open and close by a local touch sensor switch.
I used a DIY folding blind set and modified it with two gears and mounted the servo on it and the switches.
EmielA
@EmielA
Best posts made by EmielA
-
Automated folding blinds
Latest posts made by EmielA
-
HM-10 BLE node SoftSerial issues
Hello,
I build a Mysensor 1.4 version node with a Arduino Nano and the NRF24. And made this connect with a HM-10 BLE module (bluetooth low energy module), and connected it on pin 4 Rx and 5 Tx and controlled it by asynch rs232 serial AT commands. on a SoftSerial bases. The goal of my project is to detect BLE beacons. measure their distances to the sensor and sent the distance and the MAC adress of the beacon to the gateway.
When I tried to compile I got interrupt vector errors. After searching the web I found that I had to adjust the PinChangeInt.h and uncomment the #define NO_PORTB_PINCHANGES and also for port c and d. Then the compile went well.
But I noticed then strange behaviour. When I sent AT commands and wait for a response on the SoftSerial port it misses sometimes characters. Its not reliable anymore. The scanning and detection stops after several minutes.
How can I use SoftSerial and the 1.4 Mysensors together reliable? -
RE: Mysensorized Roomba
Eoreh,
I used different pieces of code from different projects.and combined them to one sketch. I used some from this project : link text
And the sketch from the MySensors Relay Actuator. I switch the Node/Relay on for about 10 seconds and then off. In the 10 seconds the IR sends the CLEAN command. With a LDR I detect if the Roomba dock led is on or off. So I detect if the Roomba is on its dock. Here under the code I hope it helps you.// Example sketch showing how to control physical relays. // This example will remember relay state even after power failure. #include <MySensor.h> #include <SPI.h> #include <IRremote.h> #include <DHT.h> #include <Bounce2.h> #define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #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 #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_DOCK 5 #define HUMIDITY_SENSOR_DIGITAL_PIN 4 // Temperatuur sensor and Humidity op pin 4 input #define DOCK_SENSOR_PIN 5 // Light sensor on pin 5 input unsigned long WAIT_TIME = 15000; // Wait time between reads (in milliseconds) IRsend irsend; // hardwired to pin 3; use a transistor to drive the IR LED for maximal range MySensor gw; Bounce debouncer = Bounce(); DHT dht; int oldValue=-1; //light sensor float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); // Change to V_LIGHT if you use S_LIGHT in presentation below MyMessage msgDock(CHILD_ID_DOCK,V_TRIPPED); void setup() { // Initialize library and add callback for incoming messages gw.begin(incomingMessage, AUTO, true); // Setup the DOCK_SENSOR to input pinMode(DOCK_SENSOR_PIN,INPUT); // After setting up the button, setup debouncer debouncer.attach(DOCK_SENSOR_PIN); debouncer.interval(5); dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Temp Humidity and Roomba IR", "1.0"); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); gw.present(CHILD_ID_DOCK, S_DOOR); metric = gw.getConfig().isMetric; // Fetch relay status for (int sensor=2, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) gw.present(sensor, V_LIGHT); // Then set relay pins in output mode pinMode(pin, OUTPUT); // Set relay to last known state (using eeprom storage) digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF); } } void loop() { // Alway process incoming messages whenever possible { delay(dht.getMinimumSamplingPeriod()); float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("H: "); Serial.println(humidity); } debouncer.update(); // Get the update value int value = debouncer.read(); if (value != oldValue) { // Send in the new value gw.send(msgDock.set(value==HIGH ? 1 : 0)); oldValue = value; } gw.wait(WAIT_TIME); //sleep a bit } } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type==V_LIGHT) { // Change relay state // digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); roomba_send(136); // Send "Clean" // Store state in eeprom gw.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()); } } void roomba_send(int code) { Serial.print("Sending Roomba code "); Serial.print(code); int length = 8; unsigned int raw[length*2]; unsigned int one_pulse = 3000; unsigned int one_break = 1000; unsigned int zero_pulse = one_break; unsigned int zero_break = one_pulse; int arrayposition = 0; // Serial.println(""); for (int counter = length-1; counter >= 0; --counter) { if(code & (1<<counter)) { // Serial.print("1"); raw[arrayposition] = one_pulse; raw[arrayposition+1] = one_break; } else { // Serial.print("0"); raw[arrayposition] = zero_pulse; raw[arrayposition+1] = zero_break; } arrayposition = arrayposition + 2; } for (int i = 0; i < 3; i++) { irsend.sendRaw(raw, 15, 38); delay(50); } Serial.println(""); Serial.print("Raw timings:"); for (int z=0; z<length*2; z++) { Serial.print(" "); Serial.print(raw[z]); } Serial.print("\n\n"); }
-
RE: Mysensorized Roomba
Hello Eoreh,
I have a older Roomba and had the same idea to control it by my sensors. I only did a other approach.
I did not mondify the Roomba with a serial interface and a MySensors node on the Roomba. But I did put a MySensors node on the docking station. And control the clean/spot/max command by imitation of the IR commands with a IR Led on the MySensors Node. And I also detect with my nod if the Roomba is in his dock charging or not. With this dock notification I measure the amount of time the Roomba is on its way before it returns to its dock charging (which is also a indication of the quality of the Roomba battery, short time away is a bad battery). I also measure the room temperature and humidity with the same node.
If you want to know the code let me know I show you.
With this approach you don't need to put anything on top of the Roomba which wil get broken off (is my experience) when its e.g. working under the bench.
See the pictures in the link of this setup: -
Automated folding blinds
I did a project to automate my folding blinds and used MySensors in combination with Pimatic.
The blinds are driven by a servo motor and controlled by a end microswitch and a Hall sensor. And it has the posibility to open and close by a local touch sensor switch.
I used a DIY folding blind set and modified it with two gears and mounted the servo on it and the switches.
-
RE: Mysensor-ing a Roomba vacuum cleaner.
Hey all,
I made a Roomba IR scheduler for my Roomba 500. I used Mysensors icm with Pimatic. On a defined time or condition in Pimatic I sent for about 10 seconds the IR command to the Roomba. Which will start the robot to clean and leave the dock. With a LDR on the dock LED I can measere the amount of time the robot is cleaning. The same Mysensors node does also measure the room temperature and humidity of the living room where my Roomba dock is.Emiel