Controlling a servo

Very interesting this Arduino option :slight_smile: Time to build one.

Objective: controll via the servo a thermostate for my floorheating.

The thermostate is in the basement and the vera3 ( UI5 version 622) is about 15 meters away with one concrete wall in line of sight . There are some zwave devices near that thermostate , so the mesh network for Zwave devices is quite good.

Do I understand correctly with this radio "nRF24L01+. " it is not a zwave radio ? So to be able to use the servo wirelesly, I need 2 arduino’s , one as a gateway , and the second one for the servo?

Or when I get a ethernet cable to my basement , I need 1 arduino ( and the servo) .

Second question for now, how do I controll the servo via the GUI , can I insert a number in degrees and the servo will turn that amount degrees? Will I be able to use it in PLEG?

I will post a full report offcourse in this thread.

Thanks,
Cor

You might be better off getting a Z-Wave capable thermostat instead. Would be much more precise then trying to calibrate a servo and all…creating a mechanical way of moving it means parts could slip and you might have the system turned on way to high or too low…anything that generates HEAT needs to be very solid in its controls.

And to answer you question, yes you would need an Arduino for the gateway and one for the thermostat. And if you use RF then you would be covering the distance between the Vera and the thermostat unless you made a relay node or sensor, costing another Arduino.

Plus a servo controlled thermostat won’t give you FAN and ON/OFF control like a full blown digital thermostat would either.

Just my thoughts…I want to create a servo control for one of my curtain sets in the living room…20 foot ceilings in there and the 2nd window set is about 12 feet up, so I want that controllable. Just got a few test motors in today and will be tinkering with it this weekend.

@ Rokskinard: I need to mention it is for a floorheating, the pickup which senses the temperature senses the temperature of the water inside the " floorheating pump device" I allready demolished a danfoss thermostate trying to get the temperature sensor outside the casing. That didn’t work. That would indeed be the best, but unfortunately. I need only about 3 to 4 settings on the thermostate. The idea is ,I can somehow set a setting for 20 degrees ,30 degrees , 40 degrees and 50 degrees of rotation I don’t want vera to controll the temperature itself , the thromostate itself does a very good job.

This is the thermostate which can not be modified:
[url=http://www.modelbouwforum.nl/forums/members/corvl-albums-diversen-picture123934-1.jpg]http://www.modelbouwforum.nl/forums/members/corvl-albums-diversen-picture123934-1.jpg[/url]

Don’t worry about the connection between servo and thermostate , got all the tools like cnc-router, mill in the house to make something appropriate.

It would be nice if you show your progress of the whole project on this forum.

Thanks,
Cor

I’d search through the blinds posts on arduino, lots of good stuff in there, people rotating servos to tilt blinds, a similar application to yours (albeit you seem to need a good servo with plenty of torque).

Don’t forget Hek’s MySensors for more help.

I wish I had all those nice tools :wink:

So why not use a thermostat that has external inputs for temp sensors?

I have 7 TZEMT500BB32MA which have an internal temp, or 2 aux inputs for external sensors. With the external sensors you can adv. the 2 or use one.
89.00 on ebay and I bought External sensors 5 for like 10.00 also on ebay.

http://www.ebay.com/itm/Trane-Z-Wave-thermostat-Schlage-Link-Nexia-TZEMT500BB32MA-New-89-00-/271395379920?pt=LH_DefaultDomain_0&hash=item3f306cdad0

@Bulldoglowell: The “MySensors” website gave me the idea and now I am very curious , this whole arduino thing gives an enormous amount of extra possibities. As a (bigscale) model airplane builder, enough servomotors and tools here :slight_smile:

@integlikewhoa: That would be ideal indeed, although I haven’t seen them for the european market. Also I see there is a controll panel on that ebay website ?? I would just need a thermostate , like these: [url=http://www.betaalbare-domotica.nl/verwarming-en-airco/danfoss-radiator-thermostaat.html]http://www.betaalbare-domotica.nl/verwarming-en-airco/danfoss-radiator-thermostaat.html[/url] I allready got 3 of them and they work fine together with my vera. Unfortunately not an external input possible.

Cor

The shoppinglist , before I order ,anything I missed or I need to add?

-vera3: already got one
-arduino UNO, that one will be the gateway : got one allready
-arduino nano: [url=http://www.ebay.com/itm/130977189883]http://www.ebay.com/itm/130977189883[/url] to be ordered.

I think that’s it to build the device.

Anyone who can also tell me how I will be able to controll this servo via the vera 3 , do I have to insert degrees in the UI ? how that does work?

Thanks,
Cor

[quote=“Cor, post:6, topic:180771”]@integlikewhoa: That would be ideal indeed, although I haven’t seen them for the european market. Also I see there is a controll panel on that ebay website ?? I would just need a thermostate , like these: [url=http://www.betaalbare-domotica.nl/verwarming-en-airco/danfoss-radiator-thermostaat.html]http://www.betaalbare-domotica.nl/verwarming-en-airco/danfoss-radiator-thermostaat.html[/url] I allready got 3 of them and they work fine together with my vera. Unfortunately not an external input possible.

Cor[/quote]

Your probley right, I don’t know much of anything about the European market. Isn’t your z-wave a different frequency too?

That thing you call a control panel is what we call in USA a thermostat. It hangs on the wall in the house. Has built in temp and humity sensor (this one also has external inputs but not all do) has 2 buttons to set what temp you want. Yes it has alot of options if you want them. Set which days it on which days its off and what times and such. Always displays current temp and humidity and time on its screen. Press the button to change the set points. The price looks to be close to the one you linked when I did a conversion to Euro. 57.00 Euro is 80.00 US $

@ integlikewhoa … ahhh, I need the thing which is attached to the valvle , and yes , europe has another frequency.

Cor

Yes … half a year later , and finally I made some time to make this.

This night I finally made some time to build a gateway and a device to use a servo.
The only issues I had was finding drivers to programm the nano and the uno ( I use the uno for the servo).

Now , there is 1 issue. The servo only turns max 90 degrees. I uploaded the sketch without changing anything.

It should to a full 180 degrees I think ? it is a standard futaba S3001.
The servo is good ( I checked with my RC transmitter and reciever)

Anyone has an idea how to troubleshoot?

Pictures will follow when I hook it up with my thermostat.

edit … oh … that’s wierd… when I use the slider or open-close , it does the 90 degrees. but when I click up-down, it does full 180 degrees … why not with the slider??

thanks,
Cor

Yesterday I started building a bracket for the servo to attach to the thermostat.
I will post some pictures next week when all is finished.

An issue with controlling the servo though , I hope someone can help, attached a screemshot what I have on the UI.

When I use the slider or close-open , the max servo range of movement is 90 degrees.
When I click up-down , I have a full 180 degrees of movement.

I need to use the servo with a thermostate , so I will create scenes when scene “20 degrees” moves the slider to a setting which correspondents with “temperature 20 degrees C” … and so on.

Anyone knows how to change this sketch so the slider can use the full 180 degrees like the “up down”- button instead of the 90-ish degrees it does now?

Thanks,
Cor

[code]// Example showing how to create an atuator for a servo.
// Connect red to +5V, Black or brown to GND and the last cable to Digital pin 3.
// The servo consumes much power and should probably have its own powersource.’
// The arduino might spontanally restart if too much power is used (happend
// to me when servo tried to pass the extreme positions = full load).
// Contribution by: Derek Macias

#include <MySensor.h>
#include <SPI.h>
#include <Servo.h>

#define SERVO_DIGITAL_OUT_PIN 3
#define SERVO_MIN 0 // Fine tune your servos min. 0-180
#define SERVO_MAX 180 // Fine tune your servos max. 0-180
#define DETACH_DELAY 900 // Tune this to let your movement finish before detaching the servo
#define CHILD_ID 10 // Id of the sensor child

MySensor gw;
MyMessage msg(CHILD_ID, V_DIMMER);
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created Sensor gw(9,10);
unsigned long timeOfLastChange = 0;
bool attachedServo = false;

void setup()
{
// Attach method for incoming messages
gw.begin(incomingMessage);

// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo(“Servo”, “1.0”);

// Register all sensors to gw (they will be created as child devices)
gw.present(CHILD_ID, S_COVER);

// Request last servo state at startup
gw.request(CHILD_ID, V_DIMMER);
}

void loop()
{
gw.process();
if (attachedServo && millis() - timeOfLastChange > DETACH_DELAY) {
myservo.detach();
attachedServo = false;
}
}

void incomingMessage(const MyMessage &message) {
myservo.attach(SERVO_DIGITAL_OUT_PIN);
attachedServo = true;
if (message.type==V_DIMMER) { // This could be M_ACK_VARIABLE or M_SET_VARIABLE
int val = message.getInt();
myservo.write(SERVO_MAX + (SERVO_MIN-SERVO_MAX)/100 * val); // sets the servo position 0-180
// Write some debug info
Serial.print("Servo changed. new state: ");
Serial.println(val);
} else if (message.type==V_UP) {
Serial.println(“Servo UP command”);
myservo.write(SERVO_MIN);
gw.send(msg.set(100));
} else if (message.type==V_DOWN) {
Serial.println(“Servo DOWN command”);
myservo.write(SERVO_MAX);
gw.send(msg.set(0));
} else if (message.type==V_STOP) {
Serial.println(“Servo STOP command”);
myservo.detach();
attachedServo = false;

}
timeOfLastChange = millis();
}

[/code]

Hello Cor,

I ran in the same problem. I fixed it by replacing the line:

myservo.write(SERVO_MAX + (SERVO_MIN-SERVO_MAX)/100 * val); // sets the servo position 0-180

by the following 2 lines of code:

 	val = map(val, 0, 100, 0, 180); // scale 0%-100% between 0 and 180) 
 	myservo.write(val); 		// sets the servo position 0-180

@ Cotejean:

That’s awesome! next week I will be home and change the sketch and try!

Do you have any idea why there would be a difference in using the slider or the up-down buttons?

One more question;
These 2 lines :

#define SERVO_MIN 0 // Fine tune your servos min. 0-180 #define SERVO_MAX 180 // Fine tune your servos max. 0-180

Does this do anything than when I change the code into your code? the finetuning I mean.

val = map(val, 0, 100, 0, 180); // scale 0%-100% between 0 and 180) 

I guess when I change the 0, 180 to what I want, I can finetune in that line of code.
for example:

val = map(val, 0, 100, 20, 160); // scale 0%-100% between 20 and 160) 

Thanks a lot,
Cor

I think that your suggestion would work

val = map(val, 0, 100, 20, 160); // scale 0%-100% between 20 and 160)

I have the servo motor mounted to one set of blinds in the living room. (Still experimenting with the Arduino plugin).
For now I was making it open and close using 2 different scenes and LUUP code:
To open the blinds

luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "72"}, 37)

To close the blinds

luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "17"}, 37)

I forgot to say that for now, in my setup, 72% is “open” and 17% is “closed”. I will try to use these values in the mapping code this weekend to see how it works and I will report the results here. It would be nice to “click” open and have the servo motor go to 72% and click “close” to make it go to 17%.

(That verification process is really a pain…)

@ Cotejean: Just came home from a working week and immediately hooked the arduino on my computer and changed the sketch ;D ;D ;D ;D

Awesome , I have now 180 degrees movement with the slider.

It is just ashame it only goes with 10% steps, if it would have been possible to set 1% steps, I could make like 20% is 20 degrees celcius, 21 %= 21 degrees celsius etc … ( now I just have to make a note somewhere that for example 30%= 24 degrees C)

But I think that’s a shortcomming of vera and can not be changes in the sketch?

Many thanks for your help,

Tomorrow I will install the bracket and servo on the thermostate.
Cor

edit :oh … I see that with authomation it is possible to set 21-22 % etcetera … cool!!!

I do notice that the “UP-DOWN” is responding wierd, it does sometimes something completely oposite and than again it goes correct , those 2 button are a bit strange.

Cor

This whole project is not without problems.

Finally today I got my bracket for the servo working ( photo’s to follow) , and it was time to switch from Arduino uno to a nano…

Hello all,

I have an arduino uno with a servo succesfully installed, but the arduino was just for testing purposes.

Ijust recieved my 2 nano’s ( [url=http://www.ebay.de/itm/291244948748?_trksid=p2060778.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT]http://www.ebay.de/itm/291244948748?_trksid=p2060778.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT[/url] )

Installed everything and uploaded the sketch , just to be sure I deleted the 2 devices I allready had ( the arduino node and the arduino win covering) . I press start to include , nothing happends.

Tried the second nano, exactly the same , tried to upload the sketch with "#define CHILD_ID 11 // Id of the sensor child " instead of 10 ( maybe an issue since the uno used 10 ).

But still the same .

Deleted the whole “my sensor plugin” and tried all again… no luck with the nano’s.

My last resort was to use again the uno , I press start to include , and yes , almost immediately the 2 devices were found.

What can be wrong??!

Hopefully someone can help, it’s quite frustrating.

Thanks,
Cor

Hi Cor, you probably best off asking for help at mysensors forum…

but what output do you get from the serial connection s of your arduinos, and have you used a decoupling capacitor on the radios? I’ve found many of the nanos cannot power the radio properly.

@Cor your powering the radios with the LE33ACZ right?
It says that this regulator has an output current up to 100mA and your using the -PA -LNA version of radio witch will need over 150mA when sending at full power. Did you lower the RF24_PA_LEVEL in the MyConfig.h ?
Your setup worked with the UNO right? Are you powering the radio differently now?
Bottom line is that most problems people have with the MySensor setup are due to powering of the radio modules (not enough current or dirty power).

Like gregl said you are also welcome to join the MySensors forum for support.

@ Gregl, I have posted as well on the mysensor- troubleshooting forum ( [url=http://forum.mysensors.org/topic/698/servo-on-arduino-uno-works-but-not-with-nano]http://forum.mysensors.org/topic/698/servo-on-arduino-uno-works-but-not-with-nano[/url] ) … the only thing someone came up with was to clear the eeprom , what I will try shortly.

You say , the nano might not give enough power to the radio , how can I test this? just a volt meter on ground and 3.3v?

@ korttoma,

this is the nano:
[url=http://www.ebay.de/itm/291244948748?_trksid=p2060778.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT]http://www.ebay.de/itm/291244948748?_trksid=p2060778.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT[/url]
and this the radio:
[url=http://www.ebay.de/itm/310651702557?_trksid=p2060778.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT]NRF24L01 + PA + LNA SMA Antenne Wireless Transceiver Kommunikationsmodul 2,4G 1100m | eBay

I will try to lower the rf24_PA_level , but to which number , what would be sensible , and, where do I find this myconfig.h?

thanks,
Cor