[Release] HubDuino v1.1.9 - Hubitat to Arduino / ESP8266 / ESP32 / ThingShield Integration (ST_Anything)

I love Dan's Hubduino project.. But is some one can add dc motor function.. Like showed in this video (with sketch example)

This motor driver uses 2 inputs per motor, one for one direction and one for the other direction. So, you would just need to set up two switches in Hubduino, one for one direction and one for the other direction.

Yes. I need option to automatic stop after N seconds...

That is the timedRelay device. That will turn a GPIO pin on for so many milliseconds (just multiply your seconds by 1000) and then turn the GPIO off.

Sounds awesome... I want to try... So what should make first? Install child-relay-switch.groovy? And write ST_Anything_Relays_Buttons_ESP8266 sketch? Correct? Or i missed something? And how to add timedrelay? Or it already included in arduino sketch?

First thing you want to do is walk through the readme on github.

That will walk you through installing all of the drivers necessary to run Hubduino. The sketch you will use will depend on what board you are going to use to control the L298N driver. An ESP8266 like a NodeMCU or Wemos D1 Mini? That will decide which example sketch you should start with. But there are instructions on how to set up the sketch on GitHub.

Will use Wemos D1 Mini... Any recommendations?

I would start with the ST_Anything_Relays_ESP8266 sketch since that is an example of 3 timed relay devices. :slight_smile: Details on how to build the device "constructor" which defines in the sketch how the device works can be found in each device's capability files (.h and .cpp) at the very top. There is a breakdown of what the different values in the device definition mean and do.

So I am using hubduino for my servo motor blinds and also for my illuminance devices using the anlog input... No wI am looking at controlling a DC motor with a l298N controller and wemos mini (esp8266).

I am thinking I look into using a webserver on the esp8266 and triggering the forward, backwards or stop commands with http posts to the esp8266.

However I am wondering if any of these sketched in hubduino could be using for pwm.. or perhaps I could just use the relay example to control the digital outs at high or low..

In my sketch I want the following and know how ot do this in arduino ide, however a little too much of anivice ot make major changes to hubduino sketches as I don't yet understand exactly how they work.

I want a statement of

"
if a limit switch(digital input) is open and a digital output is instructed to go high,
then turn that digital output on,

else turn the digital output off (this occurs if limit switch is reached or the instruction to stop the motor is received)
"
another one for the reverse command
"
if another limit switch is open(digital input) and another digital output is high
then turn the digital output on to reverse the motor
else make digital output low so the motor stops going in reverse
"

DO you think the webserver is the way to go for this, or is there a sketch for hubduino that would work for this, and be checking for the limit switches frequently to stop the motor on limit switches being reached.

I'm sorry, I'm not understanding what you have asked here. Where does the limit switch come in? That is not from the L298N. Is that going to be a contact sensor or something? I think the problem here is that you are not being specific so it is very hard to understand. Rather than day Digital Input and Digital Output and Other digital output, let's use actual pins from the D1 mini, so D0-D8. Also, where is this limit switch coming from? There are no digital outputs from the L298N. It's a DC motor that can run forever in one direction. Also when you say digital input "open" do you mean "low"?

What type of device are you trying to control with your motor? Maybe if you give some more general information it would help understand what you want to happen.

Sorry I see your point. Here goes trying to explain it better.

I am making a device that opens and closes the internal louver's in one of my doors. This is using a dc motor driven/powered from a L298N and controlled by a wemos d1 mini. The motor drives a threaded rod which in turn moves a carrier that has magnets in it and the blinds close or open. Affectively it is a dc motor turned into a linear actuator. I am going to put switches in to limit the length the actuator opens (anti clockwise of the motor) and another that limits the length the actuator closes (clockwise of the motor).

I hope to control digital pins D1 and D2 as outputs to turn the motor in the right direction. I will also have two limit switches connected to D3 and D4 (closed will make them high, and open will make them low). I know d1 and D2 are good digital pins to use, however will look into the other two digital pins so treat D3 and D4 used for illustrative purposes only.

If D1 is HIGH and D2 is LOW and D3 is open/low, it will drive the motor anti clockwise (extend). When the limit switch on D3 is closed/high this won't be true and the motor will stop and can't run anti clockwise again with D3 closed.

Then for retract it will be the same principal except the states of D1 and D2 will be swapped, and the limit switch will be on D4.

Initially I will only use the digitals as high or low which will drive the motor flat out. The motor is geared down to 50rpm and the threaded rod is M3 which gears it down even further so I think flat out is fine... However I may consider using pwm to change the speed if I find it too fast...

The code needs to respond quickly to the limit switches (D3 and D4) closing/high.

So do all this in arduino ide and use Blynk to change the state of D1 and D2 is familiar for me...

To use http post requests to the wemos is new to me (Web server) or to use Hubduino is even more challenging for me to learn.

The goal is to have use a virtual switch in hubitat to trigger the blinds opened or closed. So Blynk is not so useful here, however hubduino worked well for my servo controlled blinds and my illuminance setup with the photo resistor (using Analog input sketch) but they were easily modified. My gut feeling is I could easily modify the relay sketch and just include if statements in the main loop... But this is where I have got too and realised I have a bit to learn

1 Like

I started with the relay sketch so the timed relays part got me a little confused = lots to learn... however I have opened up the relay_buttons sketch and this seems promising.

So i have the PIN_RELAY1 and PIN_RELAY2 as the digital outputs to command the L298N, and use push buttons somehow..

Do you think I am on the right track or making it hard for myself? I am happy to spend more time learning, however its not obvious to me yet so good to check I am spending time on the best option....

As I mentioned, I am somewhat familiar with writing the code for the if statements I mentioned above (somewhat basic), however connecting it to outside world is where my experience lacks... a lot of the code in hubduino looses me at the moment.

1 Like

All,

Just a heads-up regarding a new HubDuino example for bed occupancy/presence. Seemed like it deserved its own thread for discussion...

I think you're making it hard for yourself by using the dc motor rather than a stepper. You are trying to do exact motion movements, which a motor with sensors is never going to be as accurate as. A stepper on the other hand will be exact every time, since they have a "home" position to reference.

But in either case, I don't know that Hubduino has anything that would match either of these use-cases out of the box. You could use a combination as follows:

Each direction for the DC motor would use the EX_Switch device and each of the limit inputs would use the IS_Contact device. Then, within the sketch, you could use the "callback method" to stop the motor when the IS_Contact reads as close (or open, depending on how you want to do it). That would allow you to turn on one switch to move them in one direction, then they would automatically stop and turn on the other switch to move them in the other direction and automatically stop. However, forcing the board to not turn on the motor again once the limit pin is tripped, that I have no idea if it's possible within the board. However, that should be possible within the parent device in the driver. That would take a fair bit of coding knowledge though.

What are you using to control them today?

I haven't had much success with this model either. Turned out to be pretty unreliable, one minute it worked, then it would be on and off or just lock up completely. I might have to get something like that Bosch one you mentioned and try it out again.

I've had 5 of these working for over 2 years without a single problem with them.

Interesting. anything I should know when connecting to a NodeMCU processor? Maybe I missed something then?

I has considered a stepper motor but as I believe only rotation angle is measured I thought I'd still need a limit switch or sensor as it won't know where the carrier (the part on the threaded section that I am moving) when power is lost.

Hmm. That I don't have yet so maybe I'll stick with what I know in arduino ide and lol into the Web server which I think is reasonably easy. The use a virtual switch in hubitat to trigger a http post to it.

Thanks for your feedback.

How far do you have to rotate? Would a servo work? There is a EX_Servo device in Hudbuino already. It's set up for a 180 degree servo but I suspect it would be easier to adapt that to a 270 or 360 degree servo than trying to develop a whole new device class.

Well, all of my sensors are far away from the boards. Like, feet away. So mine don't suffer from the RF interference that they do when they are close to the board. They're also in enclosures mounted on the wall. I have good power supplies for them on surge protected outlets. I'm using old phone chargers that put out at least an amp. Maybe I just got lucky and got a really good batch...i dunno.

1 Like