Oh no I'm wrong cog rail it is!
Posts made by Matt
-
RE: Send 2x relay states to Home Assistant to make them visible?
-
RE: Send 2x relay states to Home Assistant to make them visible?
@eiten haha yep we went up the vernacular I think it's called still clearly remember the beautiful views and ice caves
-
RE: Send 2x relay states to Home Assistant to make them visible?
Very generous of you matey.
I have a solar charge controller so no worries with overcharging or draining at night.
I learned eventually to bring the battery inside through winter it lasts a lot longer now!
I've been to Switzerland Jungfrau and Bern on a contiki tour around 2004 long time ago now still have a wee knife I bought.
Have kids wife and mortgage now so sadly my travelling days are behind me, at least for another eight years or so lol -
RE: Send 2x relay states to Home Assistant to make them visible?
Ah no sorry should have said Im usuing pro-mini and FTDI breakout board to program over USB.
Sitting on sundbergs board with vreg added etc. Just running your code now...
All works, picks up on first presentation thankyou! Have you got a paypal I can buy you a beer or coffee? -
RE: Send 2x relay states to Home Assistant to make them visible?
@eiten Hi I figured that out, radio was sort of working when device powered by serial usb programmer, enough for me to think was okay. HOWEVER was only ~1.7v so now I have SLA plugged in hardly any NACKs
Yes I have a SLA that normally charges via solar panel.
Controlled is a PI3 running mysgw development, is now conntected to linuxbox via ethernet.
So I tried your code again there is still weird stuff but I have registered both switches, one temp and one bat so perfect!
However, and this is annoying as this site is not letting me upload pics anymore but some characters are now messed up, same as in the serial ouput round arduino IDEW as before, and also device name in HA is now "{�������~��S��b������Mn�� 54" haha
Firmware also is "Firmware: ����{�������~��S��b������" within HA.
So all child sensors are there,
Bit odd eh!
Im gonna give the PC to my son so he can get his gametime in now and wife is away with the laptop but will be back a bit later tonightMatt
-
RE: Send 2x relay states to Home Assistant to make them visible?
Wow Edi you put a lot of work into that, appreciated man!
So your code seems to do some weird things see below from the serial output.
Heres a bit of it below this seems to be a repeating loop once I activated the two switches from Domoticz. These switches were registered from my own code yesterday I guess the sensor and child IDs are the same.
Prior to this loop there is a long run of these !MCO:PRO:RC=1 which the log parser identifies as "Recursive call detected in _process(), call level=1". These go on for many pages.
So yeah something a bit broken there Im sorry.
Nothing registered on HA =(
Have also had a go with my original code with your three suggested additions.
Is running good, domoticz has seen temp/bat/switches.
But still nothing on HA.
I have tried deleting MyS integration from HA, restarting HA, reloading MyS integration and still does not come up.
Do you think it could be because I have Domoticz listneing to the same mygw on the PI as HA? Would they compete for info or share? Beyond my level of understanding.
Perhaps I should implement a MyS serial gateway on a spare PI and connect to the HA linux box via ethernet rather than wifi and see how that goes....?Many thanks,
Matt -
RE: Send 2x relay states to Home Assistant to make them visible?
Eiten I am much obliged. Sorry for my code Ive been trying this and trying that and sort of lost track of what I done and changed.
You make it look so simple haha I just couldnt work out how to write the MyMessage and send bits thankyou so much.
Need to retire for the evening as up at 5am for work but will be back on to try it all out tomorrow, am looking forward to your next post.
Matt -
Send 2x relay states to Home Assistant to make them visible?
Hi all
Been fiddling around all day. Trying to migrate from domoticz to HA.
I have an irrigation controller with two relays plus temp and bat children as well.
I cant get the relays to come up in HA although can see/use them on domoticz.
Have mys running on a pi ethernetted to a linux box with HA running as a VM. It can see my other sensors okay.
Code is rough sorry see below and TBH Im not sure which revision Im up to Ive got several .inos around but I think this is the best one. A coder I aint.
Apparently I need to "Send at least one initial value per V_TYPE. In version 2.x of MySensors, this has to be done in the loop function. See below for an example in 2.0 of how to make sure the initial value has been received by the controller" as per HA.
Is this true, does it have to be done in the main loop?
Could someone show me how to do this for BOTH relays please? They should always start in the off state...
Many many thanks in advance.
Matt/** * 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 * 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_NRF24 //#define MY_RADIO_RFM69 // Enable repeater functionality for this node #define MY_REPEATER_FEATURE #include <SPI.h> #include <MySensors.h> #include <DallasTemperature.h> #include <OneWire.h> #define RELAY_1 4 // 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 #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No #define MY_RF24_PA_LEVEL RF24_PA_HIGH #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 1 #define CHILD_ID_BAT 9 #define CHILD_ID_TEMP 1 #define CHILD_ID_RELAY1 2 #define CHILD_ID_RELAY2 3 unsigned long SLEEP_TIME = 600000; // Sleep time between reads (in milliseconds) OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; // Initialize temperature message MyMessage msg(CHILD_ID_TEMP, V_TEMP); MyMessage msgBat(CHILD_ID_BAT, V_VOLTAGE); //#define VBAT_PER_BITS 0.013971 #define VMIN 11 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 14.5 // Vmax = (2xAA bat)=3.0V (892v) int batteryPcnt = 0; // Calc value for battery % int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point void before() { for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) { // Then set relay pins in output mode pinMode(pin, OUTPUT); // Turn off all pins digitalWrite(pin, LOW); } } void setup() { analogReference(INTERNAL); // Startup up the OneWire library sensors.begin(); // requestTemperatures() will not block current thread sensors.setWaitForConversion(false); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Relay+Temp", "1.0"); //for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_RELAY1, S_BINARY); present(CHILD_ID_RELAY2, S_BINARY); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_BAT, S_MULTIMETER); } // Fetch the number of attached temperature sensors //numSensors = sensors.getDeviceCount(); // Present all sensors to controller //for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // present(i, S_TEMP);} //} void loop() { // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // query conversion time and sleep until conversion completed int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution()); // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater) wait(conversionTime); // Read temperatures and send them to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error #if COMPARE_TEMP == 1 if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) { #else if (temperature != -127.00 && temperature != 85.00) { #endif // Send in the new temperature send(msg.setSensor(i).set(temperature,1)); Serial.print("SensorValue"); Serial.print(temperature); // Save new temperatures for next compare lastTemperature[i]=temperature; } } int sensorValue = analogRead(BATTERY_SENSE_PIN); float Vbat = sensorValue * 0.0139644; int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.); sendBatteryLevel(batteryPcnt); send(msgBat.set(Vbat, 2)); /*Serial.print("VBat"); Serial.print(Vbat); Serial.print("SensorValue"); Serial.print(sensorValue);*/ wait(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_LIGHT) { // Change relay state digitalWrite(message.sensor-1+RELAY_1, 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()); } }
-
RE: NewbiePCB sensors dying of old age
Hi sundberg84.
Yeah you're probably right it's something to do with the boost converter eh. I'm still dead keen on battery power hence the slimnodes. Although I'll be putting 8 and 28 pun ic sockets on the pcb so I can swap out either the 328p or nrf if needed. Haven't gone down the rfm route.
I do have a single 833mhz transmitter to talk to my wall sockets has run continuously for 7 years off USB. -
RE: Water level sensor (inches) to integrate into hardware
Dunno, depends a bit on context. You could use a strain gauge underneath the cup to measure weight. Or an ultrasonic distance sensor pointing down bouncing off the water? Youd have to seal everying in silicone or epoxy due to moisture I suppose.
-
NewbiePCB sensors dying of old age
Been a while lol Im still here though, running sundbergs PCBs around the house.
Seems the battery powered ones are dying. I used cheap chinese clones for everything. Interestingly, the ones I have running off wall sockets or USB power just keep going and going, no probs at all.
One wont get ACK or reach the controller. One I cant even talk to through the Ardunio IDE, another two wont accept uploads of new code, just sits there 'uploading' forever. another one is just dead dead, I got 3V from new batteries but nothing, nada, zip. Even my two nano's that were just sitting in a drawer for years seem to have expired. If I had a reflow oven I might give that a go as nothing to lose. I wonder if its a lead free solder thing. I have tried redoing the joints on a couple with a new tip on my hakko but made no difference. I cant really pull off/replace the NRF or pro mini as it will bugger the traces.
<shrug> lol just looked back in my emails and I ordered sundbergs PCBs in 2016 so seven years, cant expect miracles eh.
What Im gonna do now is m26872's slim nodes. I have the 328Ps and heaps of NRFs just waiting on the PCBs. As you get 10 that will mean 30(!) boards. I only ned around six but great to have spares. Programming bootloaders will be a new experience, now that my nanos have died I have also ordered an UNO to use as ISP. I think Ill just go for an 8Mhz bootloader as Im worried about issues with timing over onewire, I will be using mostly DS18B20s. Its cool that these chips have internal oscillators as well as vref so minimal components.
Sort of excited again, MySensors remains a hugely valuable app for me, thankyou Hek et al. -
RE: Domotiocz + Rain gauge
@sundberg84
Thankyou very much for your reply.
It seems strange that domoticz would only accept 1mm pulses I wonder if this has changed... In any case it should be easy to save the 'lost' volume and add it to the next bucket in code...
The internal pullup is switched on in code so reed switch pin won't be floating. Will have a fiddle round with your code today.
Will also try to calibrate by gauge today will be easy to see max tipping speed and can adjust wait times accordingly...
Thanks again,
Matt -
RE: Domotiocz + Rain gauge
@sundberg84 sorry I know this is an old thread but hoping you can remember how you wrote this code.I have changed it to suit MYS 2.1 as below. I have also added battery level as a separate child ID so I can watch performance over time. Aside from these simple changes the code is all yours from the start of this post. It is built on v8 of your board, controller/GW is latest domoticz beta running on a PI2 using NRFs.
I have a couple of questions though. I am curious as to why bucketSize needs to be 1, 0.5, 0.25, 0.2 or 0.1 as per your comments and I suspect that when I calibrate my gauge it wont be any of these.
I am testing at the moment without the gauge. When I earth D3 it actually reports as TWO bucket tips and the volume goes up by 0.5 twice. I dont think this is a bounce issue due to the many wait(1000) functions in your code. Would you know why this is? I have tried changing CHANGE to FALLING in the sleep function. I have a simple reed switch gague.
Which leads to my third question. Are all the wait times necessary? Could they be much less? I wonder if I will miss bucket tips because of these during heavy rain...
Many many thanks,
Matt// Enable debug prints to serial monitor #define MY_DEBUG #define MY_RADIO_NRF24 #define MY_RF24_PA_LEVEL RF24_PA_LOW #define MY_RF24_DATARATE RF24_250KBPS #include <MySensors.h> // Running this in Domoticz stable version 2.5 will not work - upgrade to beta. #define DIGITAL_INPUT_SENSOR 3 // The reed switch you attached. (Only 2 and 3 generates interrupt!) #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define CHILD_ID 1 // Id of the sensor child #define CHILD_ID_BAT 2 // Id of BAT #define SKETCH_NAME "Rain Gauge" // Change to a fancy name you like #define SKETCH_VERSION "1.1" // Your version unsigned long SLEEP_TIME = 18*60000; // Sleep time (in milliseconds). //unsigned long SLEEP_TIME = 20000; // use this instead for debug float hwRainVolume = 0; // Current rainvolume calculated in hardware. int hwPulseCounter = 0; // Pulsecount recieved from GW float fullCounter = 0; // Counts when to send counter float bucketSize = 0.5; // Bucketsize mm, needs to be 1, 0.5, 0.25, 0.2 or 0.1 boolean pcReceived = false; // If we have recieved the pulscount from GW or not boolean reedState; // Current state the reedswitch is in boolean oldReedState; // Old state (last state) of the reedswitch unsigned long lastSend =0; // Time we last tried to fetch counter. MyMessage volumeMsg(CHILD_ID,V_RAIN); MyMessage lastCounterMsg(CHILD_ID,V_VAR1); MyMessage msgBat(CHILD_ID_BAT, V_VOLTAGE); //========================= // BATTERY VOLTAGE DIVIDER SETUP // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 #define VBAT_PER_BITS 0.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.0 // Vmax = (2xAA bat)=3.0V (892v) int batteryPcnt = 0; // Calc value for battery % int batLoop = 0; // Loop to help calc average int batArray[3]; // Array to store value for average calc. int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point //========================= void presentation() { // Send the Sketch Version Information to the Gateway sendSketchInfo(SKETCH_NAME, SKETCH_VERSION); // Register this device as Rain sensor (will not show in Domoticz until first value arrives) present(CHILD_ID, S_RAIN); present(CHILD_ID_BAT, S_MULTIMETER); } void setup() { // use the 1.1 V internal reference analogReference(INTERNAL); // For battery sensing pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP); // sets the reed sensor digital pin as input reedState = digitalRead(DIGITAL_INPUT_SENSOR); // Read what state the reedswitch is in oldReedState = reedState; // Set startup position for reedswitch Serial.println("Startup completed"); delay(500); // Allow time for radio if power used as reset } void loop() { unsigned long currentTime = millis(); //See if we have the counter/pulse from Domoticz - and ask for it if we dont. if (!pcReceived && (currentTime - lastSend > 5000)) { request(CHILD_ID, V_VAR1); lastSend=currentTime; return; } if (!pcReceived) { return; } //Read if the bucket tipped over reedState = digitalRead(DIGITAL_INPUT_SENSOR); boolean tipped = oldReedState != reedState; //BUCKET TIPS! if (tipped==true) { Serial.println("The bucket has tipped over..."); oldReedState = reedState; hwRainVolume = hwRainVolume + bucketSize; send(volumeMsg.set((float)hwRainVolume,1)); wait(1000); fullCounter = fullCounter + bucketSize; //Count so we send the counter for every 1mm if(fullCounter >= 1){ hwPulseCounter++; send(lastCounterMsg.set(hwPulseCounter)); wait(1000); fullCounter = 0; } } if (tipped==false) { //No bucket tipped over last sleep-period, check battery then... batM(); } lastSend=currentTime; sleep(INTERRUPT, FALLING, SLEEP_TIME); //The interupt can be CHANGE or FALLING depending on how you wired the hardware. } //Read if we have a incoming message. void receive(const MyMessage &msg) { if (msg.type==V_VAR1) { hwPulseCounter = msg.getULong(); hwRainVolume = hwPulseCounter; pcReceived = true; Serial.print("Received last pulse count from gw: "); Serial.println(hwPulseCounter); } } void batM(){ //The battery calculations delay(500); // Battery monitoring reading int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(500); // Calculate the battery in % float Vbat = sensorValue * VBAT_PER_BITS; int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); // Add it to array so we get an average of 3 (3x20min) batArray[batLoop] = batteryPcnt; if (batLoop > 1) { batteryPcnt = (batArray[0] + batArray[1] + batArray[2]); batteryPcnt = batteryPcnt / 3; if (batteryPcnt > 100) { batteryPcnt=100; } Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %"); sendBatteryLevel(batteryPcnt); send(msgBat.set(Vbat, 4)); batLoop = 0; //Sends 1 per hour as a heartbeat. send(volumeMsg.set((float)hwRainVolume,1)); send(lastCounterMsg.set(hwPulseCounter)); } else { batLoop++; } }```
-
RE: 💬 Building a Raspberry Pi Gateway
@mfalkvidd Thankyou. Stable for now. Not sure if they are even genuine modules so... Can reach outside to my glasshouse even on low power setting.
If it starts playing up again I'll add verbose logging and have another look. -
RE: 💬 Building a Raspberry Pi Gateway
@mfalkvidd OK have attached the logfiles below.
No clues that I can see. At 1502 the NRF goes quiet. I have tried a different pi2, different NRF (PA/LNA) and am currently running the NRF off of 5V from the PI through one of those $1.00 regulator adapter things with built in caps and such. Have also tried different PSUs including a 2A one.
Only thing I can think left to try is reducing the power output in case the high output of the radio module is inducing transients in the cables...
Am kinda stumped here. I have an arduino NRF gateway that I will try via USB if low power does not work. I have tried setting up MYSGW as LAN and USB via ./configure but the same thing happens each time.
One thought just came to me, I AM using the pin15 IRQ option on the NRF now that is still experimental?
So next time will try without IRQ and low power...Any help/suggestions greatly appreciated.
FYI I have had domoticz running on a lubuntu netbook with USB arduino NRF gateway that has been rock solid. Am trying the get a workable PI solution though, for myself and my father in law but not workable as yet sadly...At 15:02:34 you can see the last incoming node message after that the only MYSGW activity is the PING thing... which seems to happen every 10S or so. This goes on for an hour after that with no more incomings. I have ~12 sensors around the place including a power meter one which reports every minute.
15:02:29 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613 Aug 5 15:02:33 raspberrypi mysgw: TSF:MSG:READ,23-23-0,s=1,c=1,t=0,pt=7,l=5,sg=0:18.0 Aug 5 15:02:33 raspberrypi mysgw: TSF:MSG:READ,23-23-0,s=0,c=1,t=1,pt=7,l=5,sg=0:21.0 Aug 5 15:02:34 raspberrypi mysgw: TSF:MSG:READ,23-23-0,s=255,c=3,t=0,pt=1,l=1,sg=0:68 Aug 5 15:02:34 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613 Aug 5 15:02:36 raspberrypi mysgw: Client 0: 0;0;3;0;18;PING Aug 5 15:02:37 raspberrypi mysgw: TSF:MSG:READ,41-7-0,s=0,c=1,t=0,pt=7,l=5,sg=0:11.6 Aug 5 15:02:41 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613 Aug 5 15:02:46 raspberrypi mysgw: Client 0: 0;0;3;0;18;PING Aug 5 15:02:50 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613 Aug 5 15:02:56 raspberrypi mysgw: Client 0: 0;0;3;0;18;PING Aug 5 15:02:57 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613 Aug 5 15:03:06 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613 Aug 5 15:03:06 raspberrypi mysgw: Client 0: 0;0;3;0;18;PING Aug 5 15:03:13 raspberrypi dhcpcd[734]: wlan0: Router Advertisement from fe80::260:64ff:fed7:f613 Aug 5 15:03:16 raspberrypi mysgw: Client 0: 0;0;3;0;18;PING
Also FWIW to log from domoticz below. Ignore FANFLAG thats just a blockly flag I use...
2017-08-05 15:01:18.936 (GW) General/Voltage (FanIntakeV) 2017-08-05 15:02:04.935 (GW) General/kWh (Meter) 2017-08-05 15:02:33.940 (GW) Temp + Humidity (Mitch2) 2017-08-05 15:02:33.945 (GW) Temp + Humidity (Mitch2) 2017-08-05 15:02:37.941 (GW) Temp (MBR Fan) 2017-08-05 15:50:02.678 Set UserVariable FanFlag = 1 2017-08-05 15:51:02.693 Set UserVariable FanFlag = 1 2017-08-05 15:52:02.703 Set UserVariable FanFlag = 1 2017-08-05 15:53:02.710 Set UserVariable FanFlag = 1 2017-08-05 15:54:00.037 Set UserVariable FanFlag = 1
Thanks,
Matt -
RE: 💬 Building a Raspberry Pi Gateway
@mfalkvidd OK thanks for your reply.
Have set up the -d parameter in mysgw.servie and am waiting for it to fall over again.
If I catch it I will post syslog.
Thanks,
Matt -
RE: 💬 Building a Raspberry Pi Gateway
Hi guys couple of questions, apologies if they have been covered elsewhere.
I am running latest dev branches of domoticz and MYS on a pi2.
At random times it seems the NRF24L01+ LNA/PA goes down, or MYS goes down and domotics stops receiving signals from all of the nodes at the same time. I have the interrupt feature enabled.
I have set the option under domoticz/hardware/data timeout to restart if no data received in five minutes but I dont think this is an ideal solution, and have yet to find out if this domoticz feature actually works in my scenario.
Any idea what causes this? I found an old thread over on the domoticz/mysensors forum but no answers there. I am using a new sd card class 10.
What I want to do is try out the different MYS builds on domoticz ie MQTT and SERIAL as well as ethernet which I am currently running. However I'm not sure how to stop the current MYS service and completely clean up the current build to start from scratch... I have tried just re entering the ./configure commands then 'make' but this does not seem to work.
Many thanks,
Matt -
RE: Compile error for Pro Mini 5,5v 168
@mfalkvidd woohoo! Time to resurrect some old nodes
Thanks for this... -
RE: 💬 Easy/Newbie PCB for MySensors
Had further problems with intermittent sends. Sometimes on initial presentation it only sends the sketch name and not version number. Also sends are infrequent up to six hours apart. When it does send it often only sends one child_id when there are three to send.
Previously I thought this was most likely an issue with a noisy boost converter. However I just tried replacing the 4.7uf cap on the radio with a 47uf one. Problem solved!
Matt -
RE: 💬 Easy/Newbie PCB for MySensors
@Matt said:
@ferro ooh hey, didn't know that... Will have a go. Thanks!
Nup, didn't work. Must have killed them somehow by removing the regulator. Have a third one running just fine, minus the LED.... Oh well.
-
RE: 💬 Easy/Newbie PCB for MySensors
@ferro ooh hey, didn't know that... Will have a go. Thanks!
-
Chicken house door controller (beta)
Hi guys. I have just finished a chickenhouse and am in the throes of automating the door. It will be controlled by domoticz and I plan to open 1/2 hour after sunrise and close 1/2 hour after sunset. The door will be driven by an electric antenna from the car wreckers, 12V battery and solar panel/controller.
There are two reed switches to tell position of the door plus a button to manually open/close or reset a jam (for increased WAF).
I have included in the sketch a bit to jiggle the door if it gets stuck, and turn off the actuator and send an alert to domoticz if the jam cannot be freed.
I have yet to try it out as am waiting on the usual final component I only realised I would need once I started building (buck converter).
Anyway code is below. mfalkvidd has kindly looked at it for me already. I believe it should work but am open to critiquing on any part of my coding including conventions.
Thanks,
Matt/** * 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 * Chicken door controller */ // Enable debug prints to serial monitor #define MY_DEBUG #define MY_RADIO_NRF24 #include <MySensors.h> #include <Bounce2.h> #define MOTORSW 3 // Motor activation pin #define MOTORPWR 4 // Motor power lead pin #define REED_OPEN 5 // Reed switch pin, pulled low when door is open #define REED_CLOSED 6 // Reed switch pin, pulled low when door is closed #define MANUALSW 7 // Momentary switch to control door bool DoorState; // 0 closed, 1 open bool PrevState; // Used to check for stated change byte jammed=0; unsigned long timer; // Counter to check door closes in time ie isn't jammed. Bounce debouncer = Bounce(); MyMessage msg(2,V_TRIPPED); void setup() { pinMode(MOTORSW, OUTPUT); pinMode(MOTORPWR, OUTPUT); pinMode(REED_OPEN, INPUT_PULLUP); // Using internal pullup. When read switch is closed, will pull this pin to ground. pinMode(REED_CLOSED, INPUT_PULLUP); // Ditto pinMode(MANUALSW, INPUT_PULLUP); // Turn on pullup for switch, will be pulled low when pushed DoorState = loadState(1); PrevState = DoorState; debouncer.attach(MANUALSW); debouncer.interval(50); } void presentation() { sendSketchInfo("ChickenDoor", "1.0"); // Send the sketch version information to the gateway and Controller present(1, S_BINARY); // Register door actuator to Gateway present(2, S_DOOR); // This will go on if door is jammed } void loop() { debouncer.update(); int value = debouncer.read(); if (value == LOW) { DoorState = !DoorState; jammed==0; // Reset the jam send(msg.set(LOW)); } if ((DoorState != PrevState) && (jammed < 2)) { //Something has changed and door isn't jammed switch(DoorState) { case 0: // Close Door timer = millis(); while( digitalRead(REED_CLOSED)==HIGH) { //Drive actuator until door closes then stop digitalWrite(MOTORPWR, HIGH); //Turn on the actuator wait(50); // Actuator wakes up digitalWrite(MOTORSW, HIGH); //Close the door if (millis() - timer > 5000) { //door is jammed jammed++; jiggle(); //open and close again break; } } digitalWrite(MOTORSW, LOW); //Door is closed, turn off actuator switch digitalWrite(MOTORPWR, LOW); //Door is closed, turn off actuator PrevState = DoorState; jammed=0; break; case 1: // Open Door timer = millis(); while( digitalRead(REED_OPEN)==HIGH) { //Drive actuator until door opens then stop digitalWrite(MOTORPWR, HIGH); //Turn on the actuator wait(50); // Actuator wakes up digitalWrite(MOTORSW, HIGH); //Wake up the actuator wait(100); digitalWrite(MOTORSW, LOW); //Close the door if (millis() - timer > 5000) { //door is jammed jammed++; jiggle(); break; } } digitalWrite(MOTORSW, LOW); //Door is closed, turn off actuator switch digitalWrite(MOTORPWR, LOW); //Door is closed, turn off actuator PrevState = DoorState; jammed=0; break; } } else if (jammed >= 2) { send(msg.set(HIGH)); } } void receive(const MyMessage &message) { if (message.type==V_STATUS) { // We only expect one type of message from controller. But we better check anyway. DoorState = message.getBool(); saveState(1, message.getBool()); // Store state in eeprom Serial.print("Incoming change for sensor:"); // Write some debug info Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } } void jiggle() //J j j jiggle it a bit (4 times) { for(int x = 0; x < 4 ; x++) { digitalWrite(MOTORPWR, HIGH); digitalWrite(MOTORSW, HIGH); wait(500); digitalWrite(MOTORSW, LOW); } digitalWrite(MOTORPWR, LOW); digitalWrite(MOTORSW, LOW); }
-
RE: Please check my mysensors code.
@mfalkvidd
Thanks heaps, enjoy your trip -
RE: Please check my mysensors code.
@mfalkvidd have finished my code, it all compiles but I haven't had a chance to test it yet, am still waiting for a step down converter to arrive as it will all be powered by a 12v car battery/solar charge controller/panel which can go up to 14.4V. The actuator is an electric antenna from the wreckers yard.
There are two reed switches on the door to detect open or closed position. I have added some code to try to unjam the door if it takes longer than 5 seconds to open or close. There is a manual button (debounced) to open or close the door, as well as reset the jam.
If you have time (HAH! Who does three days out from Christmas) I would well appreciate a critical eye on my code.
In particular I'm not sure if the lines in void receive are correct Im not too worried about errors elsewhere, can likely work them out myself, but the mysensors bits I am not too sure about.DoorState = message.getBool(); saveState(1, message.getBool());
as well as the lines that flag to the gateway/controller the door is jammed (last bit of void loop in the else if bit.
send(msg.set(HIGH));
Entire sketch below. Apologies if its hard to read, I am newish to C and prior to that only wrote in basic 30+ years ago....
Many many thanks,
Matt/** * 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 * 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 #define MY_RADIO_NRF24 #include <MySensors.h> #include <Bounce2.h> #define MOTORSW 3 // Motor activation pin #define MOTORPWR 4 // Motor power lead pin #define REED_OPEN 5 // Reed switch pin, pulled low when door is open #define REED_CLOSED 6 // Reed switch pin, pulled low when door is closed #define MANUALSW 7 // Momentary switch to control door bool DoorState; // 0 closed, 1 open bool PrevState; // Used to check for stated change byte jammed=0; unsigned long timer; // Counter to check door closes in time ie isn't jammed. Bounce debouncer = Bounce(); MyMessage msg(2,V_TRIPPED); void setup() { pinMode(MOTORSW, OUTPUT); pinMode(MOTORPWR, OUTPUT); pinMode(REED_OPEN, INPUT_PULLUP); // Using internal pullup. When read switch is closed, will pull this pin to ground. pinMode(REED_CLOSED, INPUT_PULLUP); // Ditto pinMode(MANUALSW, INPUT_PULLUP); // Turn on pullup for switch, will be pulled low when pushed DoorState = loadState(1); PrevState = DoorState; debouncer.attach(MANUALSW); debouncer.interval(50); } void presentation() { sendSketchInfo("ChickenDoor", "1.0"); // Send the sketch version information to the gateway and Controller present(1, S_BINARY); // Register door actuator to Gateway present(2, S_DOOR); // This will go on if door is jammed } void loop() { debouncer.update(); int value = debouncer.read(); if (value == LOW) { DoorState = !DoorState; jammed==0; // Reset the jam send(msg.set(LOW)); } if ((DoorState != PrevState) && (jammed < 2)) { //Something has changed and door isn't jammed switch(DoorState) { case 0: // Close Door timer = millis(); while( digitalRead(REED_CLOSED)==HIGH) { //Drive actuator until door closes then stop digitalWrite(MOTORPWR, HIGH); //Turn on the actuator wait(50); // Actuator wakes up digitalWrite(MOTORSW, HIGH); //Close the door if (millis() - timer > 5000) { //door is jammed jammed++; jiggle(); //open and close again break; } } digitalWrite(MOTORSW, LOW); //Door is closed, turn off actuator switch digitalWrite(MOTORPWR, LOW); //Door is closed, turn off actuator PrevState = DoorState; jammed=0; break; case 1: // Open Door timer = millis(); while( digitalRead(REED_OPEN)==HIGH) { //Drive actuator until door opens then stop digitalWrite(MOTORPWR, HIGH); //Turn on the actuator wait(50); // Actuator wakes up digitalWrite(MOTORSW, HIGH); //Wake up the actuator wait(100); digitalWrite(MOTORSW, LOW); //Close the door if (millis() - timer > 5000) { //door is jammed jammed++; jiggle(); break; } } digitalWrite(MOTORSW, LOW); //Door is closed, turn off actuator switch digitalWrite(MOTORPWR, LOW); //Door is closed, turn off actuator PrevState = DoorState; jammed=0; break; } } else if (jammed >= 2) { send(msg.set(HIGH)); } } void receive(const MyMessage &message) { if (message.type==V_STATUS) { // We only expect one type of message from controller. But we better check anyway. DoorState = message.getBool(); saveState(1, message.getBool()); // Store state in eeprom Serial.print("Incoming change for sensor:"); // Write some debug info Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } } void jiggle() //J j j jiggle it a bit (4 times) { for(int x = 0; x < 4 ; x++) { digitalWrite(MOTORPWR, HIGH); digitalWrite(MOTORSW, HIGH); wait(500); digitalWrite(MOTORSW, LOW); } digitalWrite(MOTORPWR, LOW); digitalWrite(MOTORSW, LOW); PrevState = !DoorState // Reset PrevState to have another go at opening or closing the door. }
-
RE: Please check my mysensors code.
@mfalkvidd
Cheers, thanks for the tips. Learn something every day. -
RE: Please check my mysensors code.
Sorted it out. Should have read
bool DOORSTATE = (message.sensor, message.getBool()?1:0);
or as it turns out, even better would be
bool DOORSTATE = message.getBool();
Didn't realise I had to re-declare the variable within void receive as I had already done it in setup.
Off to work in a minute, but Im hoping void receive passes the value back to void main....
Thanks anyway,
Matt -
RE: Please check my mysensors code.
@mfalkvidd
Hiya thanks for your reply. Am in bed now so don't have the sketch to hand. In any case its just getting started, nothing in main void yet. Yep I have DOORSTATE defined as boolean in the setup...
I just want to set it to true or false based on what the GW sends.... -
RE: 💬 Easy/Newbie PCB for MySensors
@sundberg84
Yeah it is a bit. As I said, may yet be a bad batch, too busy with other things right now to test a third one.
Mind you, just found this and as I suspected, there appears to be no point in removing the regulator if we are powering directly via vcc. -
RE: 💬 Easy/Newbie PCB for MySensors
@sundberg84
Thanks for your reply. Given I've done six or seven to date without issue I am somewhat skeptical that I have borked two in a row. I use a fine tip hakko iron, solder sucker, wick + a tiny wee flathead screwdriver for the butchery.
Maybe its time I invested in a magnifying glass heh.
Is it necessary to remove the vreg as I would think its not doing anything anyway as we are powering via VCC rather than raw? -
Please check my mysensors code.
Hi guys, sorry newbie problem here.
I am building an automated chickenhouse door using FETs and a electric antenna as the linear actuator.
Opening and closing the door is not as simple as switching a pin high or low, it will involve reed switches and two separate output pins to control the motor.
I wish to save the message.getBool() value to a separate bool variable (DOORSTATE).
I have triedDOORSTATE = (message.sensor, message.getBool()?1:0);
within void receive
and various permutations of it but keep getting the compile error
expected unqualified-id before '=' token
Im sure its something simple but havent figured it out as yet...Thanks,
Matt -
RE: 💬 Easy/Newbie PCB for MySensors
Hey I recently got a batch of ten pro 3.3v pro minis from ebay, I removed vreg + LED on two of them and they no longer work... Well, I cant upload. I have done this low power mod heaps of times, the boards are different from ones Ive seen before, has anyone here had this problem? Or am I just a problem magnet? Have yet to solder programming headers on a non modified board to see if its a bad batch... Maybe main power is routed through the vreg or LED regardless or something? I dont have the eyesight or mag abilities to play around...
-
RE: 💬 Easy/Newbie PCB for MySensors
@sundberg84 cheers, no problem on my boards, multimeter confirms this...
-
RE: 💬 Easy/Newbie PCB for MySensors
@sundberg84 said:
- Bug with G on CAP now on the right side.
Wait, what?
Missed this. I am using v8 boards. Cant seem to figure out how to search individual threads and 247 posts is a bit much to go through tonight. Will get the DMM out and try to figure it out, but what cap is labelled wrong?
Thanks,
Matt - Bug with G on CAP now on the right side.
-
RE: Cant compile 2.01 for atmega168
@Yveaux hey thanks, no idea on how to do that lol but will have a google around....
-
RE: 💬 Easy/Newbie PCB for MySensors
@AWI hey thanks! I especially like this
Although.... Something tells me L should be in series on Vout, sureley if it was between BAT and 3.3 voltage weird things would happen....
Might be time to finally try to figure out how to use that cheap old scope in my garage...
Also, as it happens, am just getting in to RC stuff (well for my son, but you know...) -
RE: Cant compile 2.01 for atmega168
@tbowmo thanks for your reply, yep I am aware of that, however I do have a couple of 168 modules running MYS 1.6.x. that I was hoping to upgrade.
Simply disabling my_debug was enough to get it small enough to stick on the 168 using v1.6.
Im guessing its non-trivial to get 2.0.x to compile for the 168 nowadays, seems to be throwing a lot of non-size related errors in the compiler.... -
RE: 💬 Easy/Newbie PCB for MySensors
@sundberg84 thanks, that is how I have soldered the 0.1uF cap but it hasnt improved things.
I was hoping @alexsh1 would be happy to chip in here and show me how to solder the 220uf cap and 3.3uH choke? -
RE: 💬 Easy/Newbie PCB for MySensors
@alexsh1 I know its a bit historical but could you post a pic or explain how you connect the lc-filter to the boost converter? Having issues here, 0.1uf cap didnt help...
Thanks.... -
RE: 💬 Easy/Newbie PCB for MySensors
Have been doing some investigation of the boost converters, just with my DMM, which doesnt have frequency function.
However it can measure ac ripple. On the working boosters there is a ripple amplitude of around 0.02V. On the flaky ones its anything from 0.03 to 0.05V. So this makes it easy for me to test to converters before comitting them with solder. -
Cant compile 2.01 for atmega168
I did have mys 1.6 running on these nodes with debug disabled, just tried to update to 2.0 and it wont compile..
I think there are firmware settings somewhere in the core for the 328 only in v2.0?
Something to do with MyHwATMega328.h ? Sorry if this is covered elsewhere...
Compile errors below...In file included from C:\Users\Admin\AppData\Local\Temp\arduino_build_748184\sketch\TempHumBatgood2.ino.cpp:1:0:
C:\Users\Admin\Documents\Arduino\libraries\MySensors/drivers/RF24/RF24.cpp: In function 'void RF24_csn(bool)':
C:\Users\Admin\Documents\Arduino\libraries\MySensors/drivers/AVR/DigitalWriteFast/digitalWriteFast.h:88:154: error: '__digitalPinToPortReg' was not declared in this scope
#define digitalWriteFast(__pin, __value) do { if (__builtin_constant_p(__pin) && __builtin_constant_p(__value)) { bitWrite(*__digitalPinToPortReg(__pin), __digitalPinToBit(__pin), (__value)); } else { digitalWrite((__pin), (__value)); } } while (0)
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:112:30: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\Admin\Documents\Arduino\libraries\MySensors/drivers/AVR/DigitalWriteFast/digitalWriteFast.h:88:117: note: in expansion of macro 'bitWrite'
#define digitalWriteFast(__pin, __value) do { if (__builtin_constant_p(__pin) && __builtin_constant_p(__value)) { bitWrite(*__digitalPinToPortReg(__pin), __digitalPinToBit(__pin), (__value)); } else { digitalWrite((__pin), (__value)); } } while (0)
^
C:\Users\Admin\Documents\Arduino\libraries\MySensors/core/MyHwATMega328.h:60:40: note: in expansion of macro 'digitalWriteFast'
#define hwDigitalWrite(__pin, __value) digitalWriteFast(__pin, __value)
^
C:\Users\Admin\Documents\Arduino\libraries\MySensors/drivers/RF24/RF24.cpp:39:5: note: in expansion of macro 'hwDigitalWrite'
hwDigitalWrite(MY_RF24_CS_PIN, level); ^
C:\Users\Admin\Documents\Arduino\libraries\MySensors/drivers/AVR/DigitalWriteFast/digitalWriteFast.h:88:180: error: '__digitalPinToBit' was not declared in this scope
#define digitalWriteFast(__pin, __value) do { if (__builtin_constant_p(__pin) && __builtin_constant_p(__value)) { bitWrite(*__digitalPinToPortReg(__pin), __digitalPinToBit(__pin), (__value)); } else { digitalWrite((__pin), (__value)); } } while (0)
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:112:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^
C:\Users\Admin\Documents\Arduino\libraries\MySensors/drivers/AVR/DigitalWriteFast/digitalWriteFast.h:88:117: note: in expansion of macro 'bitWrite'
#define digitalWriteFast(__pin, __value) do { if (__builtin_constant_p(__pin) && __builtin_constant_p(__value)) { bitWrite(*__digitalPinToPortReg(__pin), __digitalPinToBit(__pin), (__value)); } else { digitalWrite((__pin), (__value)); } } while (0)
-
RE: 💬 Easy/Newbie PCB for MySensors
@sundberg84 Hiya yep found it, starts with your post 30th June 2016.
To be honest its a bit over my head, inductors. ferrite beads etc. A picture of what to solder where would help.
I did try to 0.1uf cap across OUT and GND but the things still only work for a minute then go silent.
I will desolder existing booster then add a jumper from vin to vout to see how stable they are with a good solid battery supply.
If they are reliable I will order some more boosters, but it seems a bit hit and miss as to reliability...
Unless someone can post a pic or explain (for dummies) how to filter the booster effectively?
I should pull out my scope, which involves tidying my workbench, not a task I undertake lightly....Thanks,
Matt -
RE: 💬 Easy/Newbie PCB for MySensors
Hiya Sundberg
I think Im having boost converter noise issues from a dodgy ebay batch.
I have soldered up 11 of your boards to date and two are real flaky.
Aside from swapping out the boost converter is there a way to reduce the noise? 0.1UF cap across the radio power/gnd pins? Or across the GND and output pins of the booster itself?
They are kind of expensive so dont want to bin them if I can bodge up a fix...
Thanks,
Matt -
RE: 433mhz transmitter
Hi Ton
First of all I got a bunch (five) of these
Im glad I got five because four of the transmitters did not work.
If you have the effergy plugs these codes will work otherwise you need to sniff them out as per this
instructable. Note I am using pin 4 for the transmitter, not 12 (the line mySwitch.enableTransmit(4); in code)
The NRF24L01 is wired up as per the instructions on this site.
Hope it all makes sense. -
RE: double/triple receiving of data?
@mfalkvidd ah yep Im using NRF24L01+...
Wonder why ACK is getting lost...Maybe I need to foil the GW LNA/PA.... Just scared of shorts... -
double/triple receiving of data?
As below. Any idea why? I have a repeater but with the star topology this shouldnt happen?
-
BMP280 SPI Adafruit
Hi guys.
I got this working just now. I couldnt get the BMP to run over I2C, or on marekd's sketch posted here , even after changing it to SPI.
So I pinched the bulk of his great sketch and tweaked to to run on the adafruit libraries over SPI. Prediction even works now, neato! All the crazy prediction coding is his, no credit for me./*************************************************************************** This is a library for the BMP280 humidity, temperature & pressure sensor Designed specifically to work with the Adafruit BMEP280 Breakout ----> http://www.adafruit.com/products/2651 These sensors use I2C or SPI to communicate, 2 or 4 pins are required to interface. Adafruit invests time and resources providing this open source code, please support Adafruit andopen-source hardware by purchasing products from Adafruit! Written by Limor Fried & Kevin Townsend for Adafruit Industries. BSD license, all text above must be included in any redistribution ***************************************************************************/ // Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 #include <MySensors.h> #include <SPI.h> #include <Adafruit_Sensor.h> #include <Adafruit_BMP280.h> #define BMP_SCK 5 #define BMP_MISO 8 #define BMP_MOSI 6 #define BMP_CS 7 Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK); #define CHILD_ID_TEMP 1 #define CHILD_ID_PRESS 2 const char *weather[] = { "stable", "sunny", "cloudy", "unstable", "thunderstorm", "unknown" }; enum FORECAST { STABLE = 0, // "Stable Weather Pattern" SUNNY = 1, // "Slowly rising Good Weather", "Clear/Sunny " CLOUDY = 2, // "Slowly falling L-Pressure ", "Cloudy/Rain " UNSTABLE = 3, // "Quickly rising H-Press", "Not Stable" THUNDERSTORM = 4, // "Quickly falling L-Press", "Thunderstorm" UNKNOWN = 5 // "Unknown (More Time needed) }; // for forecast float lastPressure = -1; float lastTemp = -1; int lastForecast = -1; const int LAST_SAMPLES_COUNT = 5; float lastPressureSamples[LAST_SAMPLES_COUNT]; // this CONVERSION_FACTOR is used to convert from Pa to kPa in forecast algorithm // get kPa/h be dividing hPa by 10 #define CONVERSION_FACTOR (1.0/10.0) int minuteCount = 0; bool firstRound = true; // average value is used in forecast algorithm. float pressureAvg; // average after 2 hours is used as reference value for the next iteration. float pressureAvg2; float dP_dt; unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) // MyMessage to controler MyMessage msgT1(CHILD_ID_TEMP, V_TEMP); MyMessage msgP1(CHILD_ID_PRESS, V_PRESSURE); MyMessage msgF1(CHILD_ID_PRESS, V_FORECAST); const unsigned long tUpdate = 60000; // update interval //unsigned long t0; void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("BMP280", "1.1"); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_PRESS, S_BARO); } void setup() { Serial.begin(9600); Serial.println(F("BMP280 test")); if (!bme.begin()) { Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); while (1); } ServerUpdate(); } void loop() { /*int temp = bme.readTemperature(); long pressure = bme.readPressure(); send(msgT1.set(temp)); send(msgP1.set(pressure/100));*/ sleep(SLEEP_TIME); ServerUpdate(); } void ServerUpdate() // used to read sensor data and send it to controler { double T, P; T = bme.readTemperature(); P = bme.readPressure(); int forecast = sample(P); if (P != 0) { send(msgT1.set(T, 1)); send(msgP1.set(P/100, 1)); send(msgF1.set(weather[forecast])); } } float getLastPressureSamplesAverage() { float lastPressureSamplesAverage = 0; for (int i = 0; i < LAST_SAMPLES_COUNT; i++) { lastPressureSamplesAverage += lastPressureSamples[i]; } lastPressureSamplesAverage /= LAST_SAMPLES_COUNT; return lastPressureSamplesAverage; } int sample(float pressure) { // Calculate the average of the last n minutes. int index = minuteCount % LAST_SAMPLES_COUNT; lastPressureSamples[index] = pressure; minuteCount++; if (minuteCount > 185) { minuteCount = 6; } if (minuteCount == 5) { pressureAvg = getLastPressureSamplesAverage(); } else if (minuteCount == 35) { float lastPressureAvg = getLastPressureSamplesAverage(); float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR; if (firstRound) // first time initial 3 hour { dP_dt = change * 2; // note this is for t = 0.5hour } else { dP_dt = change / 1.5; // divide by 1.5 as this is the difference in time from 0 value. } } else if (minuteCount == 65) { float lastPressureAvg = getLastPressureSamplesAverage(); float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR; if (firstRound) //first time initial 3 hour { dP_dt = change; //note this is for t = 1 hour } else { dP_dt = change / 2; //divide by 2 as this is the difference in time from 0 value } } else if (minuteCount == 95) { float lastPressureAvg = getLastPressureSamplesAverage(); float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR; if (firstRound) // first time initial 3 hour { dP_dt = change / 1.5; // note this is for t = 1.5 hour } else { dP_dt = change / 2.5; // divide by 2.5 as this is the difference in time from 0 value } } else if (minuteCount == 125) { float lastPressureAvg = getLastPressureSamplesAverage(); pressureAvg2 = lastPressureAvg; // store for later use. float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR; if (firstRound) // first time initial 3 hour { dP_dt = change / 2; // note this is for t = 2 hour } else { dP_dt = change / 3; // divide by 3 as this is the difference in time from 0 value } } else if (minuteCount == 155) { float lastPressureAvg = getLastPressureSamplesAverage(); float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR; if (firstRound) // first time initial 3 hour { dP_dt = change / 2.5; // note this is for t = 2.5 hour } else { dP_dt = change / 3.5; // divide by 3.5 as this is the difference in time from 0 value } } else if (minuteCount == 185) { float lastPressureAvg = getLastPressureSamplesAverage(); float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR; if (firstRound) // first time initial 3 hour { dP_dt = change / 3; // note this is for t = 3 hour } else { dP_dt = change / 4; // divide by 4 as this is the difference in time from 0 value } pressureAvg = pressureAvg2; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past. firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop. } int forecast = UNKNOWN; if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval. { forecast = UNKNOWN; } else if (dP_dt < (-0.25)) { forecast = THUNDERSTORM; } else if (dP_dt > 0.25) { forecast = UNSTABLE; } else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05))) { forecast = CLOUDY; } else if ((dP_dt > 0.05) && (dP_dt < 0.25)) { forecast = SUNNY; } else if ((dP_dt > (-0.05)) && (dP_dt < 0.05)) { forecast = STABLE; } else { forecast = UNKNOWN; } // uncomment when debugging //Serial.print(F("Forecast at minute ")); //Serial.print(minuteCount); //Serial.print(F(" dP/dt = ")); //Serial.print(dP_dt); //Serial.print(F("kPa/h --> ")); //Serial.println(weather[forecast]); return forecast; }
-
RE: 💬 AC-DC double solid state relay module
Aproxx you roxx. It works! Not sure what to do with it yet, but likely it will end up in a wall sometime soon on light duties. Thanks for sharing such a great design
Hmm just pulled some switches, they are mostly SPDT jobbies on multiple switches, no idea how to hood this bad-boy up =( -
RE: 433mhz transmitter
Thanks Boots. One thing I noticed was that three out of five of the receivers I bought did not work. If fact one heated up real quick. So buy a few cos QC in China is pants.
-
433mhz transmitter
Its kinda kludgy (of course- I made it!) but it works. As usual full of bits pinched from elsewhere....
I am using this to control 4 effergy wall outlets. I already have mains switching ability but it's made by me and I am nervous about fire, so I figured this was a good compromise.
I have some cheap 433 transmitters and receivers. Used the RCSwitch library to capture the codes. I have only got one switch functional at the moment but to add the rest is trivial. My coding Im sure is crap but it works.
I have soldered a wee wire to the transmitter 12CM long and have no issues with range. I like the 'repeat command x times' function in the RCSwitch library, kinda makes not having feedback a non issue.// 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 1290271 #define CODE_1Off 1290263 #define CODE_2On 1290267 #define CODE_2Off 1290259 #define CODE_3On 1290269 #define CODE_3Off 1290261 #define CODE_4On 1290270 #define CODE_4Off 1290262 RCSwitch mySwitch = RCSwitch(); void setup() { mySwitch.enableTransmit(4); mySwitch.setRepeatTransmit(15); } 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, 24); // 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, 24); delay(50); } } if (incomingOutlet==2) { if (incomingLightState==1) { // Turn on socket 2 Serial.println("Turn on Socket 2"); mySwitch.send(CODE_2On, 24); delay(50); } if (incomingLightState==0) { // Turn off socket 2 Serial.println("Turn off Socket 2"); mySwitch.send(CODE_2Off, 24); delay(50); } } if (incomingOutlet==3) { if (incomingLightState==1) { // Turn on socket 3 Serial.println("Turn on Socket 3"); mySwitch.send(CODE_3On, 24); delay(50); } if (incomingLightState==0) { // Turn off socket 3 Serial.println("Turn off Socket 3"); mySwitch.send(CODE_3Off, 24); delay(50); } } if (incomingOutlet==4) { if (incomingLightState==1) { // Turn on socket 4 Serial.println("Turn on Socket 4"); mySwitch.send(CODE_4On, 24); delay(50); } if (incomingLightState==0) { // Turn off socket 4 Serial.println("Turn off Socket 4"); mySwitch.send(CODE_4Off, 24); delay(50); } } } delay(50); }
-
RE: 💬 AC-DC double solid state relay module
Hi Approx
Thanks for the effort here. I have all the bits except for the PCBs which were shipped a week ago so not far off. -
RE: Which flux cleaner do you like the best?
Hmmm I think I have flux cored solder. Have never used flux as a separate entity or flux cleaner for that matter. Suspect its time to educate myself.
-
RE: Your workshop :)
@Samuel235 yeah the Dolmar leaks, I think its a design feature. Problem is I live with three drunken monkeys who are entropy impersonated, as such I cant keep anything inside if I want to find it again.
-
RE: Your workshop :)
@Yveaux Thanks I luuurve my 660 although it still scares the begeezus out of me. 7HP in your hands is quite a buzz.
Just got a second hand weather station Im gonna fiddle around with when the mood takes me. And when I get a 433MHZ receiver. -
RE: Help please ! total noob here !!
I tried openhab and MQTT via an ethernet gateway when I first got started, and quickly got lost with all the bindings and suchlike. I switched to domoticz via serial gateway, which kind of 'just works' and haven't looked back. Keep at it, you will get there.
-
RE: Introduction & Controller question
@KrisJacobs
Hi Kris.
I settled on domoticz pretty quickly. No complaints as yet. Am running it on a (free to me) HP mini with Ubuntu, but the pi documentation appears pretty thorough. -
RE: NRF24L01+PA+LNA wiring question
@parachutesj
Couple of things - get yourself a cheap multimeter. Indispensable and pretty important piece of kit when you are doing this kind of stuff, will save you frying stuff and help with trouble shooting.
The PA+LNA version needs around 120 milli amps at peak power (from memory) some of the duinos cant supply this.
And use the caps as suggested in the wiring guide for the NRF modules on this site.
Cheers,
Matt -
RE: LM393 as pulse powermeter sensor, swap out 'photodiode'
OK so rather than wait for shipping from China I went to my local Jaycar and got one of these LDRs. If the link gets broken its a cadmium sulphine LDR with a rise time of 50ms and decay of 40ms.
Works like a charm. Because its flat I can tape it directly to the LED in my power meter, covering the whole thing with black tape to ensure no ambient light problems. Two pinholes in the tape and the LDR leads go right through no probs. I have some thin wires going to the LM393 unit (so minimal weight on the LDR/Tape itself) and I guess the comparator in there is good enough to pick up the change in resistance on the LED pulses.
So if you wind up with one of these units I recommend swapping the photodiode with a high spec LDR and soldering some leads from the module to the LDR to facilitate accurate fixing to the meters LED. I used two bits off an old length of ribbon cable (IDE HDD type stuff). -
RE: LM393 as pulse powermeter sensor, swap out 'photodiode'
I wondered that, but didnt seem to work with polarity reversed either.
Thats the article I found earlier that gave me the idea
Im thinking these might be a goer....
Thanks again... -
RE: LM393 as pulse powermeter sensor, swap out 'photodiode'
Hi Sam, just back in from the garage.
The red LED idea didnt work, wired up to the correct polarity it actually lit up, so there is current going through that end of the module. Thought Id try it the other way around, no joy there either. Sigh.
Thanks for your ideas and links, the current module as it is is way to fiddly for me. Will order one of those photo transistors and see how I go. One month shipping time to NZ though so will be a while before I get back to you.Cheers,
Matt -
LM393 as pulse powermeter sensor, swap out 'photodiode'
So I got one of these set up a while ago, but always had to fiddle around with it to get it lined up JUST SO with the light on my smartmeter. Over time, it would slip and require realignment, and I found it needed to be horizontal from the meter to have any hope of picking up the signal. I could go into details but to cut it short I accidentally ripped off the 'photodiode' tonight from this unit at a point where it is now junk.
This got me thinking. I don't think its a photodiode at all, rather just an LED, which can be used to detect light. Of what color I have no idea. Photodiodes look different. After doing some research I believe an LDR replacement would be too slow for this application. I also discovered that for best results for an LED light detector you need one with a wavelength at or just above the wavelength of the light you are trying to detect. So the light on my meter is red, and I happen to have a few small red clear resin LEDs in my bits box. An IR one might work too, am sure Ive got a few old remotes kicking around....
Thoughts? -
RE: 💬 Easy/Newbie PCB for MySensors
@sundberg84
Ah crikey I think Im being thick, I just put a jumper across BAT connectors after tracing the lines and reading the manual, am now getting 2.8 at the NRF. Sorry for being a numpty. Still not picking up on my gateway, time to go to bed but will get the serial monitor running tomorrow....
Thanks for the quick reply. -
RE: 💬 Easy/Newbie PCB for MySensors
Hi Sundberg.
First of all thanks for what you have done here, and hi from New Zealand.
I have a problem though, sorry to be a hassle.
I assembled my first board tonight and I dont get 3.3v across the NRF. It starts at 0.07V then falls down to 0 on my cheap meter. Same on the MYSX1.4 connector at 3.3 and gnd. Am getting 3.3 on the mini as well as VCC and GND on the MYSX area so the regulator is working. May be a short? Or a bad solder? Although they look good to me.... If so what solder joints should I redo? Any other ideas?
Also, Ive traced back the VCC from the NRF and I cant see where it connects to a power source, either the battery in or the boost converter?
Thanks,
Matt -
RE: Energymeterpulsesensor locks up. <SOLVED>
<SOLVED>
OK so my presumption/suspicion was right, does need to be sending an active signal for the node to transmit any data.
Seems to be working well now, just have to find a spot in my long house where the gateway will reliably talk to the polytunnel AND the meter reader.
And for any others struggling with this, especially getting the sensor LM393 to work, I found it needs to be pointed directly at the LED in my meter, not side on. To achieve this I drilled a small hole in the top of a jam jar lid and epoxied the board to it, then taped the lid to the meter. Seems to be working a treat now. YAY! Thanks MS team, you have a great product. Next step is temp sensors for the kids bedrooms and a relay on their heaters (winter is coming to the deep south of NZ)
Cheers,
Matt -
Energymeterpulsesensor locks up. <SOLVED>
Hi guys Im about at my wits end after a day and a half of trying to sort this issue, would appreciate some input.
Arduino IDE is 1.6.5
MYS version is 1.5.4
Have latest version of domoticz running on ubuntu on an HP mini.
Node sketch is v 1.0 unmodified except for a 20000 millis send frequency down from 100K I think, running on a pro mini.
All radio connections to the pro mini are soldered.
Gateway is working fine with my polytunnel node and has done for many months.
RF24L01+ PA LNA with 'adapter board' also have wee ceramic cap soldered across VCC and GND on the back of the adapter and big cap stuffed into the header sockets although I think these come on the adapter board too? Extra caps cant hurt? Didnt solve the problem anyway.
PSU is 5V 1A wall wart with direct feed to the RF adapter (has built in 3.3v reg, you know the one). Its all inside a plastic box wrapped in tinfoil aside from the aerial. Earths are all common. PA_LEVEL is set to HIGH. I might have had some transmission and interference issues to start with but have pretty much ruled them out now. I have swapped out the radio, the pro mini, the PSU and the adapter so hardware is not at fault.
I have set up a serial monitor on the PC MINI (ubuntu/domotics machine), and believe in linux you can have two apps accessing the same serial port, seems to work for me.
With domoticz not running the node happily IDs itself and pings away every 20 seconds as it should on the (gateway) serial monitor. As soon as I start domoticz however the gateway sends out the last known meter reading and the node goes quiet. If I reset the node it sends out its 'hello guys' lines then goes quiet again
The only thing I can think of is that I have yet to successfully tape the light sensor to the flashing LED in the meter box, as it needs to be pointing right at it with the board horizontal to reliably pick up and I need to make up a plastic thing to keep it in the right spot. So there is no signal coming from the light sensor. I cant read the code very well, could this be my problem?
Have attached GW log below, copied off the linux box serial monitor. The last line is when I start domoticz and it sends out the last known meter reading (dont know where this came from, I didnt enter it anywhere).
Many thanks,
Matt Little0;0;3;0;9;gateway started, id=0, parent=0, distance=0
0;0;3;0;14;Gateway startup complete.
0;0;3;0;9;read: 2-2-0 s=255,c=3,t=11,pt=0,l=12,sg=0:Energy Meter
2;255;3;0;11;Energy Meter
0;0;3;0;9;read: 2-2-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
2;255;3;0;12;1.0
0;0;3;0;9;read: 2-2-0 s=1,c=0,t=13,pt=0,l=0,sg=0:
2;1;0;0;13;
0;0;3;0;9;read: 2-2-0 s=1,c=2,t=24,pt=0,l=0,sg=0:
2;1;2;0;24;
0;0;3;0;9;read: 2-2-0 s=1,c=2,t=24,pt=0,l=0,sg=0:
2;1;2;0;24;
0;0;3;0;9;read: 2-2-0 s=1,c=2,t=24,pt=0,l=0,sg=0:
2;1;2;0;24;
0;0;3;0;9;read: 2-2-0 s=1,c=2,t=24,pt=0,l=0,sg=0:
2;1;2;0;24;
0;0;3;0;9;read: 2-2-0 s=1,c=2,t=24,pt=0,l=0,sg=0:
2;1;2;0;24;
0;0;3;0;9;read: 2-2-0 s=1,c=2,t=24,pt=0,l=0,sg=0:
2;1;2;0;24;
0;0;3;0;9;read: 2-2-0 s=1,c=2,t=24,pt=0,l=0,sg=0:
2;1;2;0;24;
0;24;
00;9;read: 1ad: 2-2-0 s=0;0;3;0;9;send: 0-0-2-2 s=1,c=2,t=24,pt=0,l=5,sg=0,st=ok:10677 -
RE: Hello there. Soil moisture sensor idea.
Edit: How about this one? It's still over budget but not too expensive:
http://www.aliexpress.com/item/Protection-type-temperature-and-humidity-sensor-temperature-and-humidity-sensor-built-in-sht10/1650578403.html?spm=2114.031010208.3.76.Kuscd1&ws_ab_test=201407_2,201444_5,201409_3This one seems to be just what Im trying to achieve I think? Inside the DHT is a capacitive moisture sensor, and I think this turnkey one does it the same way, so I gotta be barking up the right tree. Or maybe right paddock, wrong tree. Neverdie I think you are right I have been reading 95-93% since I started the experiment three nights back and there has always been condensation inside the plastic container. The weight of the tin can/soil is going down. I guess when the soil gets 100% dry I will notice it, but will be too late for my plants by then. Will give it a few more days though, its cold here and you wont get much evaporation from a tin can full of dirt with a plastic cup occluding 50% of the opening. I will try again with a can made out of wire mesh or similar, covered in cloth. Just a wee impermeable disk above the sensor. I dont have the facilities to make a sintered steel waterproof vapour permeable enclosure.
From what I have read gypsum sensors are dirt cheap, but dont last and tend to skew when you fertilise, which I plan to do. Also they use up four pins each and require a number of passives. Or am I just being lazy here? To be honest I am lazy and want to find a 1 pin cheap solution and am still hoping the DHT will work if I get the enclosure right. Will also have to do some reading on dew point, thanks for that
My blimmin solenoid valve hasn't arrived yet, ordered it on monday =( Ex washing machine.
Have a good weekend.
Matt -
RE: Hello there. Soil moisture sensor idea.
@AWI Sorry are you saying that the dht won't tolerate being in a high moisture environment for long, even if it is in (buried) air? Thanks again.
-
RE: Hello there. Soil moisture sensor idea.
To add, if I can establish a useful correlation, I will splash out and buy dht22s.
-
RE: Hello there. Soil moisture sensor idea.
Thanks for the that, I do get what you mean. But I don't think you get what I am doing. I have a small plastic container, open only at the bottom so water cannot get in. There is some holey type cloth covering this opening. Inside the container is the dht, cable is sealed where it comes out the top. So the dht is not in soil or water, it is in air only. I am hoping that this airs humidity and therefore my readings will have a direct relationship with the surrounding soils moisture levels....
-
Heated garden beds.
All monitored and controlled by MS.
Goes something like this. Glycol solution pumped through a solar collector then under my raised beds. Solar panel is charging the battery that powers the pump. Turns out pumping fluid through pipes is kind of complicated, but I got there. Have all the hardware and the beds plumbed up, just need a bit more time to put it all together. -
RE: Hello there. Soil moisture sensor idea.
Huh, seems to be going again. Must be my dodgy soldering or something. We are down 11 grams and 3% humidity in 24 hours. I am hoping that the humidity of the trapped air in the wee inverted plastic jar is directly related to the moisture content of the surrounding soil.
-
RE: Hello there. Soil moisture sensor idea.
Yep, did see that thread and am aware of the options in there. Basically I am looking at spending around $5/sensor, want something reliable and easy to implement. Was after thoughts on the DHT really and keen to know if anyone else has tried this. Cheers.
-
Hello there. Soil moisture sensor idea.
Hi guys, thought Id better jump in and say gidday as have been lurking/researching for a wee while now.
Big thanks to you developers first of all, talented, helpful, generous folk that you are.
I am an avid reader of HAD, where I first heard about mysensors. Have been using mediaportal since 0.3c (I think).
I am undertaking my first attempt at automating anything, and am planning to 'hook up' my tunnelhouse.
So far I have an ethernet gateway and a single temp sensor. Took my a while and a couple of delete/reinstalls but got it working. I really like domoticz, gave up on openHab as I coudnt work out the graphing/permanence stuff. Just spotted mycontroller tonight and am keen to try this also.
I would like to have soil moisture sensors but they are either expensive, tie up too many pins, or tend to drift/corrode from what I have read. So I thought to myself why not dry a DHT11 under the soul in a wee inverted dome, with some cloth over the mouth to keep the bugs/soil out? Would be cheap, reliable, also measure soil temp (another goal) and use one pin/sensor. Couldnt find any other discussions on this idea on the net, clever me! Or my google-fu is crap.
So I set up a wee experiment after reading a bit with a pre weighed tin of soil with my sensor in it. Started out okay but the DHT11 just crapped itself after sitting at 97% for the last 24 hours or so. In its defence Ive had/negelcted it for five years and flambeed it a bit last night (heatshrink/lighter).
So yeah, thought Id ask here if I am being thick somewhere before buying another one/trying again.
After my tunnel house and garden are fully wired the kids bedrooms/heat distribution system is next.
Cheers,
Matt