DRV8833 + ESP Easy
Moderators: grovkillen, Stuntteam, TD-er
DRV8833 + ESP Easy
Hi, any experience with ESP Easy? Want to use it to control damaged (original circuit) pet doors with ESP8266.
Thanks for any advice.
Thanks for any advice.
Re: DRV8833 + ESP Easy
It looks like a very basic H-bridge chip without any internal logic inside.
There isn't a plugin for driving the stepper motor logic.
No idea if this chip also manages the coil current, as you also may need to make sure no coil is left powered for a long time.
Driving it from rules is probably way too slow, since that would result in several tens of steps per second at most.
There isn't a plugin for driving the stepper motor logic.
No idea if this chip also manages the coil current, as you also may need to make sure no coil is left powered for a long time.
Driving it from rules is probably way too slow, since that would result in several tens of steps per second at most.
Re: DRV8833 + ESP Easy
Its not stepper, its ordinary DC motor.
Re: DRV8833 + ESP Easy
Then you could have a look at P098 PWM Motor plugin.
I do see I still need to make documentation for it.
It does support an (optional) encoder for position input and limit switches.
The available commands are:
pwmmotorhome - Run the motor in reverse till limit A switch is reached
pwmmotorend - Run the motor forward till limit B switch is reached
pwmmotorforward - Run the motor N steps forward. With N <= 0: Move till limit B switch is reached
pwmmotorreverse - Run the motor N steps in reverse
pwmmotorstop - Stop moving
pwmmotormovetopos - Run the motor in the required direction to position N
There is a pending pull request ( https://github.com/letscontrolit/ESPEasy/pull/4519 ) to add functionality to this plugin to run the motor for a set amount of time, when no encoder is present.
But running till the limit switches is already usable without encoder.
I do see I still need to make documentation for it.
It does support an (optional) encoder for position input and limit switches.
The available commands are:
pwmmotorhome - Run the motor in reverse till limit A switch is reached
pwmmotorend - Run the motor forward till limit B switch is reached
pwmmotorforward - Run the motor N steps forward. With N <= 0: Move till limit B switch is reached
pwmmotorreverse - Run the motor N steps in reverse
pwmmotorstop - Stop moving
pwmmotormovetopos - Run the motor in the required direction to position N
There is a pending pull request ( https://github.com/letscontrolit/ESPEasy/pull/4519 ) to add functionality to this plugin to run the motor for a set amount of time, when no encoder is present.
But running till the limit switches is already usable without encoder.
Re: DRV8833 + ESP Easy
Thanks!
Original circuit has no limit switches, and add them to the hardware would be too complicated. I am newcomer to the Espeasy, so I thouhgt it would be possible just to set time period or number of revolutions to define movement. It seems to be more complicated. I have old "yellow" esp8266 board ("IoT") with photo sensor, which I tested with ESP Easy, working great, powered by 5 volts (doors have 3xAA batteries), so it looked as "simple" task
Original circuit has no limit switches, and add them to the hardware would be too complicated. I am newcomer to the Espeasy, so I thouhgt it would be possible just to set time period or number of revolutions to define movement. It seems to be more complicated. I have old "yellow" esp8266 board ("IoT") with photo sensor, which I tested with ESP Easy, working great, powered by 5 volts (doors have 3xAA batteries), so it looked as "simple" task
Re: DRV8833 + ESP Easy
You can of course always handle basic GPIO operations in rules.
I think the longpulse command would be great for this.
Let's assume the GPIO pin for "up" is GPIO13, "down" is 14.
For sunrise/sunset to be correct, your ESP should be aware of the time and the GPS coordinates on the tools->Advanced page.
You can also add or subtract some time from sunrise/sunset like this: %sunrise+10m% to add 10 minutes.
Not sure how long an ESP will last on AA batteries though.
I think the longpulse command would be great for this.
Let's assume the GPIO pin for "up" is GPIO13, "down" is 14.
Code: Select all
on Clock#Time=All,%sunrise% do //will run at sunrise
longpulse,13,1,10 // GPIO 13 high for 10 seconds
endon
on Clock#Time=All,%sunset% do //will run at sunrise
longpulse,14,1,10 // GPIO 14 high for 10 seconds
endon
You can also add or subtract some time from sunrise/sunset like this: %sunrise+10m% to add 10 minutes.
Not sure how long an ESP will last on AA batteries though.
Re: DRV8833 + ESP Easy
Thanks a LOT!
I will test it. I intend to use photovoltaic panel + charger.
Thanks!
I will test it. I intend to use photovoltaic panel + charger.
Thanks!
Re: DRV8833 + ESP Easy
Hi, I, finally, tested, motor runs, but pulse/longpulse not.
Probably must open GPIO for given time only once after change of the A0 change... I am playing with timer but not quite sure I understand the principle how to set timer for one time period once after state change...
Thanks
Probably must open GPIO for given time only once after change of the A0 change... I am playing with timer but not quite sure I understand the principle how to set timer for one time period once after state change...
Thanks
Re: DRV8833 + ESP Easy
Here is something similar: https://www.youtube.com/watch?v=_omEluWFqsU
I think for ESPeasy, the procedure is the same. You can see it if you already have not.
I think for ESPeasy, the procedure is the same. You can see it if you already have not.
Re: DRV8833 + ESP Easy
Hi, thanks, I have found soulution for Tasmota, but I wanna use ESPEasy: https://github.com/arendst/Tasmota/discussions/10387
I changed rules struct, so I am approaching the end .
I changed rules struct, so I am approaching the end .
Re: DRV8833 + ESP Easy
Good to know that. Please post the update when you're done. That will help many of us.okite wrote: ↑25 Jun 2023, 15:58 Hi, thanks, I have found soulution for Tasmota, but I wanna use ESPEasy: https://github.com/arendst/Tasmota/discussions/10387
I changed rules struct, so I am approaching the end .
Re: DRV8833 + ESP Easy
"Final" WittyCloud rules; playing with OLED too. Test run on timer, real operation will use TD-er recommendation - sunset/sunrise Clock#Time (thanks!):
Code: Select all
on System#Boot do
LoopTimerSet,1,10
GPIO,12,0
GPIO,13,0
GPIO,14,0
OLEDCMD,clear
Endon
on Rules#Timer=1 do
OLEDCMD,on
//on Clock#Time=All,%sunset% do //will run at sunset
if [LightSensor#Analog]<10 and [DoorsStatus#open]=1
GPIO,14,1 //motor wakeup
GPIO,13,0
LongPulse,12,1,5 //GREEN LED
TaskValueSet 2,1,0 //doors close
GPIO,14,0 //motor sleep
Endif
//Endon
//on Clock#Time=All,%sunrise% do //will run at sunrise
if [LightSensor#Analog]>30 and [DoorsStatus#open]=0
GPIO,14,1 //motor wakeup
GPIO,12,0
LongPulse,13,1,5 //BLUE LED
TaskValueSet 2,1,1 //doors open
GPIO,14,0 //motor sleep
Endif
//Endon
Endon //timer 1
Re: DRV8833 + ESP Easy
Just keep in mind that acting on events for a specific time of day (e.g. sunrise/sunset) will only be triggered when the unit is running at that time.
So maybe you also want to check the current state/time of day when the system boots (on system#boot do...) or when the system time is set.
So maybe you also want to check the current state/time of day when the system boots (on system#boot do...) or when the system time is set.
Re: DRV8833 + ESP Easy
Thanks for advice again!
Re: DRV8833 + ESP Easy
I probably have to control open/close by photosensor according to the light level, as on sunset it is a lot of light, and hen are still somewhere out... maybe some combination with the sunset + some time added...TD-er wrote: ↑26 Jun 2023, 13:17 Just keep in mind that acting on events for a specific time of day (e.g. sunrise/sunset) will only be triggered when the unit is running at that time.
So maybe you also want to check the current state/time of day when the system boots (on system#boot do...) or when the system time is set.
I understand that it is necessary to check
- Time#Set (using NTP) is done?
- WiFi#Connected is valid?
Maybe the TaskValueSet Dummy Device can loose the value during restart/boot?
i guess that combination light sensor and sunset will prevent not closing doors during fool moon...for example.
Thanks again for any advices.
Re: DRV8833 + ESP Easy
When acting on a specific time of day, you need to make sure the time has been set.
So you can check the system variable %isntp%
This way you know you can rely on the system time.
So you can check the system variable %isntp%
This way you know you can rely on the system time.
Re: DRV8833 + ESP Easy
Thanks!
I added
Code: Select all
on Rules#Timer=1 do
if %isntp% = 0
reboot
endif
OLEDCMD,on
//on Clock#Time=All,%sunset% do //will run at sunset
if [LightSensor#Analog]<22 and [DoorsStatus#open]=1
...
Re: DRV8833 + ESP Easy
No idea how long it takes to hit this timer #1.
Do you set it at the event "WiFi#connected" ?
Do you set it at the event "WiFi#connected" ?
Re: DRV8833 + ESP Easy
I tuned the code a little:
I had some problems with wifi connectivity, so now I check wifi connection and open doors if not connected, as hen has large cage (as a "semi space" if I need to keep them out of the big open area), and its better for them to be in the cage than to be closed in the coop.
Second test is for time set, but for the time being I control doors by light level only and later I plan to "merge" it with sunrise/sunset (winter time?).
Thanks for your valuable advices!
Code: Select all
on System#Boot do
LoopTimerSet,1,10
GPIO,12,0
GPIO,13,0
//GPIO,14,0 DRV8833
OLEDCMD,clear
OLEDCMD,on
Endon //System#Boot
on Rules#Timer=1 do //top loop
if WiFi#Connected=0 and [DoorsStatus#open]=0
LongPulse,12,1,34 //open doors
TaskValueSet 2,1,1 //doors open
endif
on WiFi#Connected do //connected to wifi loop
if %isntp%=0
reboot
endif
OLEDCMD,on
//on Clock#Time=All,%sunset% do //will run at sunset
if [LightSensor#Analog]<5 and [DoorsStatus#open]=1
// GPIO,14,1 //motor wakeup for DRV8833
GPIO,12,0
LongPulse,13,1,34 //close doors
TaskValueSet 2,1,0 //doors closed
// GPIO,14,0 //mtor sleep for DRV8833
Endif
//Endon Clock#Time
//on Clock#Time=All,%sunrise% do //will run at sunrise
if [LightSensor#Analog]>60 and [DoorsStatus#open]=0
// GPIO,14,1 //motor wakeup for DRV8833
GPIO,13,0
LongPulse,12,1,34 //open doors
TaskValueSet 2,1,1 //doors open
// GPIO,14,0 //motor sleep for DRV8833
Endif
//Endon Clock#Time
Endon //wifi#connected
Endon //Rules#Timer 1
Second test is for time set, but for the time being I control doors by light level only and later I plan to "merge" it with sunrise/sunset (winter time?).
Thanks for your valuable advices!
Re: DRV8833 + ESP Easy
You had mismatches between on...do and endon
Changed it:
Changed it:
Code: Select all
on System#Boot do
LoopTimerSet,1,10
GPIO,12,0
GPIO,13,0
//GPIO,14,0 DRV8833
OLEDCMD,clear
OLEDCMD,on
Endon //System#Boot
on Rules#Timer=1 do //top loop
if WiFi#Connected=0 and [DoorsStatus#open]=0
LongPulse,12,1,34 //open doors
TaskValueSet 2,1,1 //doors open
endif
endon
on WiFi#Connected do //connected to wifi loop
if %isntp%=0
reboot
endif
OLEDCMD,on
//on Clock#Time=All,%sunset% do //will run at sunset
if [LightSensor#Analog]<5 and [DoorsStatus#open]=1
// GPIO,14,1 //motor wakeup for DRV8833
GPIO,12,0
LongPulse,13,1,34 //close doors
TaskValueSet 2,1,0 //doors closed
// GPIO,14,0 //mtor sleep for DRV8833
Endif
//Endon Clock#Time
//on Clock#Time=All,%sunrise% do //will run at sunrise
if [LightSensor#Analog]>60 and [DoorsStatus#open]=0
// GPIO,14,1 //motor wakeup for DRV8833
GPIO,13,0
LongPulse,12,1,34 //open doors
TaskValueSet 2,1,1 //doors open
// GPIO,14,0 //motor sleep for DRV8833
Endif
//Endon Clock#Time
Endon //wifi#connected
Re: DRV8833 + ESP Easy
That if statement is [s]missing a set of square brackets around [WiFi#Connected]...[/s] using the wrong variable, should be %iswifi%
/Ton (PayPal.me)
Re: DRV8833 + ESP Easy
Thanks, as I tune it, I find how many I have to learn yet
Re: DRV8833 + ESP Easy
WiFi#connected is an event.
So that should be handled in on...do...endon blocks
The system variables can be found on the system variables page (button on the Tools page)
Variables are written like %bla%
Task values should be accessed like [taskname#taskvaluename]
And since new task values also generate an event, you get the slightly confusing notation where you need to match the event (thus without []) and you can access the task value with using []
It isn't that complex, but you need to be aware of these little details.
Just keep in mind this very simple idea:
When parsing the rules, everything enclosed in either [] or %% will be replaced by whatever it can be replaced before executing the rules.
Thus the value of task foo with value bar can be used like this:
[foo#bar]
And the rules parser will replace this with the current value of that task value.
So that should be handled in on...do...endon blocks
The system variables can be found on the system variables page (button on the Tools page)
Variables are written like %bla%
Task values should be accessed like [taskname#taskvaluename]
And since new task values also generate an event, you get the slightly confusing notation where you need to match the event (thus without []) and you can access the task value with using []
It isn't that complex, but you need to be aware of these little details.
Just keep in mind this very simple idea:
When parsing the rules, everything enclosed in either [] or %% will be replaced by whatever it can be replaced before executing the rules.
Thus the value of task foo with value bar can be used like this:
[foo#bar]
And the rules parser will replace this with the current value of that task value.
Re: DRV8833 + ESP Easy
Repaired...
Thanks for all advices!
Code: Select all
on System#Boot do
LoopTimerSet,1,10
GPIO,12,0
GPIO,13,0
//GPIO,14,0 DRV8833
OLEDCMD,clear
OLEDCMD,on
Endon //System#Boot
on Rules#Timer=1 do //top loop
OLEDCMD,on
If %iswifi% !=0 And %isntp%=0 // connected but got no time, then reboot to get time
reboot
Endif
If %iswifi%=0 and [DoorsStatus#open]=0 //not connected, thus open the door, if not at night
if [LightSensor#Analog]>60
LongPulse,12,1,34 //open doors
TaskValueSet 2,1,1 //doors open
Endif
Endif
//on Clock#Time=All,%sunset% do //will run at sunset
if [LightSensor#Analog]<5 and [DoorsStatus#open]=1
// GPIO,14,1 //motor wakeup for DRV8833
GPIO,12,0
LongPulse,13,1,33 //close doors
TaskValueSet 2,1,0 //doors closed
// GPIO,14,0 //motor sleep for DRV8833
Endif
//Endon Clock#Time
//on Clock#Time=All,%sunrise% do //will run at sunrise
if [LightSensor#Analog]>60 and [DoorsStatus#open]=0
// GPIO,14,1 //motor wakeup for DRV8833
GPIO,13,0
LongPulse,12,1,36 //open doors
TaskValueSet 2,1,1 //doors open
// GPIO,14,0 //motor sleep for DRV8833
//Endon Clock#Time
Endif
Endon //Rules#Timer 1
Thanks for all advices!
Who is online
Users browsing this forum: No registered users and 0 guests