Page 1 of 1

PLUGIN development - Skeleton to use as master?

Posted: 24 Aug 2016, 17:29
by tozett
hi,

can you provide a (commented) Master-Sketch for Plugins?

i am far from beeing a developer, but wanted to try to get my max7219 led-matrix running under ESP-easy.
i tried a sketch besides espeasy with an adafruit lib for the may7219 and it works succesful.
Now i looked up the sketches in the playground, hoping to find an (function) empty master-sketch to put my codefragments in and test it.

maybe a dev can provide something like this?

i would be glad and could try a plugin myself.... :oops:

as i looked through the playground, i wanted to prevent deleting something out of the working examples,
as they all seem indivually 'specific' in some ways... 8-)

Re: PLUGIN development - Skeleton to use as master?

Posted: 14 Nov 2016, 15:26
by bertrand
That is a great idea !!! Instead of modifying one that wasn't meant to be used like that.

Re: PLUGIN development - Skeleton to use as master?

Posted: 14 Nov 2016, 20:10
by tozett
thanks for +1
:D

Re: PLUGIN development - Skeleton to use as master?

Posted: 21 Nov 2016, 21:39
by musti
+1, would be helpful

Re: PLUGIN development - Skeleton to use as master?

Posted: 22 Nov 2016, 03:03
by r_255
+1

Re: PLUGIN development - Skeleton to use as master?

Posted: 22 Nov 2016, 09:26
by pbertra
I'd really like it too: I would develop an US-100 sensor plugin

Re: PLUGIN development - Skeleton to use as master?

Posted: 22 Nov 2016, 15:22
by gerardovf
Yes, please! I need a plugin to control my blinds. I read two buttons (to rise/lower the blind locally). I then operate one of two relays to move the blind motor accordingly. I have created rules so that only one relay is activated at a time (I can send commands either locally or using MQTT).
I then use a HC-SR04 ultrasonic sensor to get feedback with the current blind position.
I have found that the HC-SR04 is missing many measurements when using rules, so right now I am forced to use two ElectroDragons to test the concept properly until I get a dedicated blind plugin.

Here are the rules:
On BTN_UP#SWITCH=1 do
if [BTN_DWN#SWITCH]=1
GPIO,13,0
else
if [RLY_DWN#SWITCH]=1
GPIO,13,0
else
GPIO,12,1
timerSet,1,20 //Set Timer 1 for the next event in 20 seconds
endif
endif
endon
On BTN_UP#SWITCH=0 do
GPIO,13,0
GPIO,12,0
endon
On BTN_DWN#SWITCH=1 do
if [BTN_UP#SWITCH]=1
GPIO,12,0
else
if [RLY_UP#SWITCH]=1
GPIO,12,0
else
GPIO,13,1
timerSet,1,20 //Set Timer 1 for the next event in 20 seconds
endif
endif
endon
On BTN_DWN#SWITCH=0 do
GPIO,13,0
GPIO,12,0
endon
On Rules#Timer=1 do //When Timer1 expires, do
GPIO,13,0
GPIO,12,0
endon
On STOP#SWITCH=1 do
GPIO,13,0
GPIO,12,0
endon

Re: PLUGIN development - Skeleton to use as master?

Posted: 29 Nov 2016, 22:27
by jgrad
gerardovf wrote:Yes, please! I need a plugin to control my blinds. I read two buttons (to rise/lower the blind locally). I then operate one of two relays to move the blind motor accordingly. I have created rules so that only one relay is activated at a time (I can send commands either locally or using MQTT).
I then use a HC-SR04 ultrasonic sensor to get feedback with the current blind position.
I have found that the HC-SR04 is missing many measurements when using rules, so right now I am forced to use two ElectroDragons to test the concept properly until I get a dedicated blind plugin.

Here are the rules:
On BTN_UP#SWITCH=1 do
if [BTN_DWN#SWITCH]=1
GPIO,13,0
else
if [RLY_DWN#SWITCH]=1
GPIO,13,0
else
GPIO,12,1
timerSet,1,20 //Set Timer 1 for the next event in 20 seconds
endif
endif
endon
On BTN_UP#SWITCH=0 do
GPIO,13,0
GPIO,12,0
endon
On BTN_DWN#SWITCH=1 do
if [BTN_UP#SWITCH]=1
GPIO,12,0
else
if [RLY_UP#SWITCH]=1
GPIO,12,0
else
GPIO,13,1
timerSet,1,20 //Set Timer 1 for the next event in 20 seconds
endif
endif
endon
On BTN_DWN#SWITCH=0 do
GPIO,13,0
GPIO,12,0
endon
On Rules#Timer=1 do //When Timer1 expires, do
GPIO,13,0
GPIO,12,0
endon
On STOP#SWITCH=1 do
GPIO,13,0
GPIO,12,0
endon
gerardovf - why do you need ultrasonic sensor for controlling blinds? Normally driver/motor for blinds/shutters have adjustable end switches.
And be careful with electrodragon devices - I use them as controllers for blinds as well and one of them become burnt because of inappropriate design - complete current for load goes through 10ohm resistor which is on PCB. This design problem is already solved by new versions of electrodragon devices.
ED_burnt.jpg
ED_burnt.jpg (159.43 KiB) Viewed 9469 times

Re: PLUGIN development - Skeleton to use as master?

Posted: 18 Jan 2017, 23:08
by gerardovf
Hi jgrad!
The reason to use an element to get the distance is:
- Get feedback to see if the command was executed. I use it too to get the position of my garage door as a double check (I use also a reed switch to get the closed position).
- Use distance as a goal. E.g. I can tell the blind to go up/down to a certain position.
I first tried to use rules just to execute the blind logic (with no measure value involved) but they were slow and sometimes both relays were activated at the same time.

This is how I have implemented it. I modified device _013 (now _129) and the measurements are executed 10 times per second. I use 5 readings to calculate the median value (I had erratic values from time to time). The new 'blind' device (_130) uses 4 GPIOs to read up/down buttons and to control up/down relays; it is also able to get the readings from device _129 to decide when to stop.

I am not able to attach the two plugin files (_P130_BLINDCTRL.ino and _P130_BLINDCTRL.ino) here. I even tried to rename them to .txt with no success.