Setpoint for a Temperature
-
good evening Jkandasa
back with MyController
I can't find a way to modulate a value on a myS Node, a value that can be a setpoint for a temperature, or a value (hour:minute) to change the start and stop time of a remote clock
my sketch on the clock
https://forum.mysensors.org/topic/4809/real-time-clock-module-lcd-display-and-controller-time/8I added the On Off part on local time program, it works well
... int ledPin = 13; // Assigned Pin for test const int OnHour = 20; const int OnMin = 51; const int OffHour = 21; const int OffMin = 52; .. ...... if (hour() == OnHour && minute() == OnMin) // Lorsque les valeurs sont équivalente { digitalWrite(ledPin, HIGH); // Pin 4 is HIGH // Serial.println("LIGHT ON"); // Print the Message } else if (hour() == OffHour && minute() == OffMin) // Lorsque les valeurs sont équivalente { digitalWrite(ledPin, LOW); // Pin 4 is Low // Serial.println("LIGHT OFF"); // Print the Message } ...
lll
I can't find the thread that will give me the solution?
What to add in the sketch so that MyController changes the parameters of my MySensors Node?
is my question understandable?
Thanks
ps; the title of the post is "Setpoint for a Temperature"
because this will be the next step -
Hi @JeeLet
you have to add a custom sensor and var for this on your sketch
in MyController you can use the following widget (Control Panel >> Mixed Control
),you can set the values as string
20:51
and onreceive
function you have to parse the stringyou can setup this schedule in MyController scheduler
The easiest way you can setup a schedule in MyController as follows,
LED ON
LED OFF
This schedule triggered at
20:51
andled_pin_off
exactly after 1 hour (1h
- Pre Delay)
We have some documents for schedule, but not complete https://v2.mycontroller.org/docs/user-interface/operations/schedules/ -
thank you for the direction
the idea is one thing, to unfold it is difficult to find the beginning.
.... a bit like a roll of tape -
@JeeLet provide your nodeid, sensorid,variable you want to control by schedule
I can create starting point for you -
re_edit https://forum.mysensors.org/topic/4970/setting-parameters-in-nodes/5
the sketch is not yet operational.
(Re-Edit le 6juin=/* * LIBRAIRIE: * MySensors v2 : https://github.com/mysensors/MySensors * TimeLib.h : https://github.com/PaulStoffregen/Time * SSD1306Ascii.h : https://github.com/greiman/SSD1306Ascii * * MATERIEL: * Arduino Uno * -Afficheur OLED 0,96" I2C TF052 / circuit SSD1306. * bus TTLModule RS485 * * REVISION HISTORY * base de Henrik Ekblad 2013-2015 et autres :) * et DimmableLEDActuator.ino de Bruce Lacey * ajout bus RS485 et OLED * * DESCRIPTION * demander Date et Heure au contrôleur et l'affiche sur ecran OLED * Request date and time from the controller and display it on OLED screen * Ajout Relay sur Horloge et parametres debut/fin par MyC * * Connectique i2c: * Arduino : A4 A5 * OLED : SDA SCL * */ //-- The sketch uses 12264 octets (38%) ----global variables use 809 octets (39%)----------- //- //------------ 2022 ----------------------- Fonctionnelle avec MyC et MyS------------------- //#define MY_DEBUG /*Enable debug prints to serial monitor*/ #define MY_TRANSPORT_WAIT_READY_MS 3000 /*Timeout (ms) pour mis en Com.(0 pour aucun)*/ #define MY_NODE_ID 22 /*Node en ID static*/ /* ----- Module RS485 ----*/ #define MY_RS485 /*Apl du transport RS485 (protocol?)*/ #define MY_RS485_DE_PIN 2 /*Cmd DE pin*/ #define MY_RS485_BAUD_RATE 9600 /*Set RS485 baud rate to use*/ //#define MY_RS485_HWSERIAL Serial1 /*pour port Serial autre*/ #include "SSD1306Ascii.h" #include "SSD1306AsciiAvrI2c.h" #include <MySensors.h> #include <TimeLib.h> // ------ objet - MyS numero du Node ------ #define CHILD_ID_2 2 //On time #define CHILD_ID_4 4 //Off time // #define CHILD_ID_TXT 3 #define I2C_ADDRESS 0x3C /*i2c adresse*/ #define RST_PIN -1 // Define proper RST_PIN if required.(oled) SSD1306AsciiAvrI2c oled; //type de com oled //----- MyS ------ bool timeReceived = false; bool stateCom = false; unsigned long lastUpdate=0, lastRequest=0 , lastmillis = 0; unsigned long newTime = 0, ComTime = 4000; // 4sec //----------- test commande Relay ---------------- int ledPin = 7; // Assigned Pin for Relay Module int timecurrent ; // Conversion des heure en minutes int requestOn; int requestOff; //----- MyS ------ MyMessage dimmerMsg(CHILD_ID_2, V_PERCENTAGE); MyMessage dimmerMsg4(CHILD_ID_4, V_PERCENTAGE); bool info; // pour info GW sur MyC //---------------- SETUP ---------------------------- void setup() { //--- OLED ---- #if RST_PIN >= 0 oled.begin(&Adafruit128x32, I2C_ADDRESS, RST_PIN); #else // RST_PIN >= 0 oled.begin(&Adafruit128x32, I2C_ADDRESS); #endif // RST_PIN >= 0 oled.setFont(Adafruit5x7); /*font Oled*/ oled.clear(); // requestTime(receiveTime); // apl controlller au boot ,desactiver pour teste //test time Relay pinMode(ledPin, OUTPUT); // Relay fictif digitalWrite(ledPin, LOW); // mis a Low //---- test set point ----- send(dimmerMsg.set(info)); send(dimmerMsg4.set(info)); } //--------------MySensors------------- void presentation() { sendSketchInfo("Clock", "2.0"); present( CHILD_ID_2, S_DIMMER, "Debut" ); // Register the LED Dimmable Light with the gateway present( CHILD_ID_4, S_DIMMER, "Fin" ); } //------------------ LOOP ----------------------- void loop() { unsigned long now = millis(); // ---- MyS time -------- if (now-lastRequest > (ComTime)) { timeReceived = false; requestTime(receiveTime); // Request time from controller. lastRequest = now; } //----- Tempo Display Oled ---------- if (now-lastUpdate > 10000) { //10secondes lastUpdate = now; lastmillis = millis(); updateDisplay(); // Serial.print(" time current : "); Serial.print(timecurrent); // Serial.print(" requestOn : "); Serial.print(requestOn); // Serial.print(" requestOff : "); Serial.println(requestOff); //----- Stat Com --- if (timeReceived == 1) { //En Com Controller stateCom ComTime = 480UL*1000UL; // 480=8 minutes cycles for Control presence controller } else { // Erreur Com Controller stateCom = false; ComTime = 10UL*1000UL; // secondes for attempted reconnection to the controller //(ajouter un nombre maxi d'essai) // Serial.println(" ----*** Erreur Com Controller *** ---- "); } } //----- commande Relay dans une plage horaire ----- // Conversion des heure en minutes timecurrent = hour()*100 + minute(); //@Kamill:multiplié l’heure par 100 et ajouté les minutes. //C’est plus pratique pour écrire les heures limites 10:00 → 1000 et 21:52 → 2152 . if (timecurrent >= requestOn && timecurrent <= requestOff) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } } //---Loop stop---- // -------------------- MyS -------------------------------- void receiveTime(unsigned long controllerTime) { if (receiveTime) stateCom = true ; else stateCom = false; newTime = controllerTime; timeReceived = true; setTime(controllerTime); // apl pour TimeLib.h } //----- reception set time------------ void receive(const MyMessage &message) { if (message.getType() == V_PERCENTAGE) { int requestedLevel = atoi( message.data ); //Récupérer la valeur à partir du message //limite valeur entrant dans la plage valide 0 to 2400 requestedLevel = requestedLevel > 2400 ? 2400 : requestedLevel; requestedLevel = requestedLevel < 0 ? 0 : requestedLevel; if((requestedLevel % 100) > 59) { requestedLevel = 00; } // modulo Minutes switch (message.sensor) { case 2: // message 1 requestOn = requestedLevel; break; case 4: // message 2 requestOff = requestedLevel; break; } //----- retour valeur pour MyC ------- send( dimmerMsg.set(requestOn) ); send( dimmerMsg4.set(requestOff) ); } } //------------Gestion de l'affichage OLED--------------- void updateDisplay() { //test function to power off the display //oled.ssd1306WriteCmd(SSD1306_DISPLAYOFF); //wait (10); //oled.ssd1306WriteCmd(SSD1306_DISPLAYON); oled.set1X(); //ligne Message oled.setCursor(2, 0); printStatDay () ; // affiche jour de la semaine/poster day of the week //oled.print(day()); oled.set2X(); //ligne Heures oled.setCursor(18,1); oled.print(hour()); printDigits(minute()); printDigits(second()); oled.print(" "); oled.set1X(); // ligne jour mois Année / day month year oled.setCursor(35,3); oled.print(day()); printDigitsDay(month()); printDigitsDay(year()); } //-------- Day displaying------- void printDigitsDay(int digitday) { //function for Day displaying "0" and separator "/" for day/month/year values oled.print("/"); if(digitday < 10) oled.print('0'); oled.print(digitday); } //-------- Time displaying------- void printDigits(int digits) { //function for Time displaying "0" and separator ":" for hour:minute:sec values oled.print(":"); if(digits < 10) oled.print('0'); oled.print(digits); } //------ conversion date en texte (fonction weekday) et statu Com Controller ----------- void printStatDay () { //function for display Day texte oled.invertDisplay(!(stateCom)); // inverse N/B Oled sur erreur Com if(stateCom == true) { oled.print("com "); } //com okai if(stateCom == false){ oled.print("Error"); } //com Error // oled.print(stateCom); oled.print(" "); if(weekday() == 1) { oled.print("dimanche"); } //Sunday if(weekday() == 2) { oled.print("lundi"); } //Monday if(weekday() == 3) { oled.print("mardi"); } //Tuesday if(weekday() == 4) { oled.print("mercredi"); } //Wednesday if(weekday() == 5) { oled.print("jeudi"); } //Thursday if(weekday() == 6) { oled.print("vendredi"); } //Friday if(weekday() == 7) { oled.print("samedi"); } //Saturday oled.print(" "); oled.print(day()); } //-------------------FIN PGM --------------------------
-
@JeeLet said in Setpoint for a Temperature:
the choice of constants OnHour OnMin separated is maybe not good ?
if you use MyController, you have the option to schedule in controller. no need to add code in your sketch. I will give you the config for schedule. can you provide your gateway name in MyController?
-
id: GW2560
description: Gateway USB
..... portname: /dev/ttyACM0ou node
gatewayId: GW2560
nodeId: '22'
name: Clockas said in the link at the beginning of the post
"I prefer that the basic logic is in the sensor node,... ." texte du lienUse the controller's calendar to change the day's values.
the controller is the scheduler
Merci Jkandasa
-
@JeeLet here is the yaml file to control from MyController
on your sketchreceive
function process, a sensorId with1
andV_STATUS
variable. control your relay with the received payloadcustomVariableType: none id: control_relay enabled: true type: simple spec: frequency: daily dayOfWeek: sun,mon,tue,wed,thu,fri,sat date: '' dayOfMonth: '' time: '20:51' validity: {} handlerParameters: turn_on: >- {"type":"resource_by_quick_id","disabled":"","data":"cmVzb3VyY2VUeXBlOiBmaWVsZApxdWlja0lkOiBHVzI1NjAuMjIuMS5WX1NUQVRVUwpwYXlsb2FkOiAnb24nCnByZURlbGF5OiAwcwo="} turn_off: >- {"type":"resource_by_quick_id","disabled":"","data":"cmVzb3VyY2VUeXBlOiBmaWVsZApxdWlja0lkOiBHVzI1NjAuMjIuMS5WX1NUQVRVUwpwYXlsb2FkOiAnb2ZmJwpwcmVEZWxheTogMWgK"} handlers: - resource_handler
You can move all your schedule logic to your sketch. As mentioned here you have to use custom variable to submit your inputs.
-
Hello jkandasa
Thank you for the information, I will test it in practice .
yes I am often absent from the world of micro i,informatique at the moment
-
in the topic https://forum.mysensors.org/topic/4970/setting-parameters-in-nodes/12
there is an interesting information"..... This way you can see what openhab is sending to your MySensors gateway. Here is how to do it
Open an ssh connection to your openhab server
Type ssh -p 8101 openhab@localhost. ......."the same thing is possible with MyController ???
read in real time the MyC and MyS dialog and the Log
-
@JeeLet you can watch it in MyController,
on your gateway setup enable message logger as follows,
On the computer where MyController is running, got to MyController directory, you can see a
logs
directory. there is file will be named as your gateway name, tail itlogs/ └── gateway_logs ├── gw_mysensor.log tail -f logs/gateway_logs/gw_mysensor.log 2022-06-03T14:43:04.941+0530 Recd out_rfm69/31/4/1/0/24 917730 2022-06-03T14:43:05.579+0530 Recd out_rfm69/31/5/1/0/24 989894 2022-06-03T14:43:06.008+0530 Recd out_rfm69/31/6/1/0/24 998194 2022-06-03T14:43:06.494+0530 Recd out_rfm69/1/1/1/0/25 72 2022-06-03T14:43:06.665+0530 Recd out_rfm69/31/4/1/0/25 512 2022-06-03T14:43:06.816+0530 Recd out_rfm69/1/1/1/0/35 65.00 2022-06-03T14:43:07.389+0530 Recd out_rfm69/31/4/1/0/37 49.94 2022-06-03T14:43:07.740+0530 Recd out_rfm69/31/5/1/0/37 49.94 2022-06-03T14:43:08.419+0530 Recd out_rfm69/31/6/1/0/37 32.00 2022-06-03T14:43:09.129+0530 Recd out_rfm69/31/4/1/0/26 1 2022-06-03T14:43:11.066+0530 Recd out_rfm69/13/1/1/0/38 244.01 2022-06-03T14:43:11.485+0530 Recd out_rfm69/13/1/1/0/39 0.00 2022-06-03T14:43:12.026+0530 Sent in_rfm69/13/1/1/1/35 65 2022-06-03T14:43:12.872+0530 Recd out_rfm69/13/1/1/1/35 65 2022-06-03T14:43:13.635+0530 Recd out_rfm69/13/255/3/0/1 2022-06-03T14:43:13.660+0530 Sent in_rfm69/13/255/3/1/1 1654267393 2022-06-03T14:43:14.463+0530 Recd out_rfm69/13/255/3/1/1 1654267393
-
xxxi@odroidc2:/opt/apps/mycontroller$ tail -f executable/mc_home/logs/gateway_logs/gw_GW2560.log 2022-06-03T12:10:23.225+0200 recd 0;12;1;0;0;0.0 2022-06-03T12:10:23.225+0200 recd 0;13;1;0;1;0.0 2022-06-03T12:10:43.728+0200 recd 0;255;3;0;9;620470 .
-
Hello
here is my sketch is clean and functional.
the values sent with the bodyboard work well.one step finished
now i tried with the examples of the schedules you gave me, and well i'm lost
I recapitulate the need.
MyC sends at a certain time or day, the value of on and off
for the time slots of the relay on the clock.integer values without comma,
example : 1630 for 16hours 30minutes.
the sketch of MyS manages withThanks for your help.
many stars in the sky for youthe recopies and other info
the parts of the sketch
... // ------ objet - MyS numero du Node ------ #define CHILD_ID_2 2 //On time #define CHILD_ID_4 4 //Off time ... //----------- test commande Relay ---------------- int ledPin = 7; // test Assigned Pin for Relay Module int requestOn; int requestOff; //----- MyS ------ MyMessage dimmerMsg(CHILD_ID_2, V_PERCENTAGE); //hour walk MyMessage dimmerMsg4(CHILD_ID_4, V_PERCENTAGE); //stop time bool info; // for your information GW sur MyC //---------------- SETUP ---------------------------- void setup() { ... //---- test set point ----- send(dimmerMsg.set(info)); send(dimmerMsg4.set(info)); } //--------------MySensors------------- void presentation() { sendSketchInfo("Clock", "2.0"); present( CHILD_ID_2, S_DIMMER, "Debut" ); // Register the LED Dimmable Light with the gateway present( CHILD_ID_4, S_DIMMER, "Fin" ); } //------------------ LOOP ----------------------- void loop() { .... //----- commande Relay dans une plage horaire ----- timecurrent = hour()*100 + minute(); // Conversion des heure en minutes //----- reception set time On Off ------------ int requestedLevel = atoi( message.data ); //Récupérer la valeur à partir du message //----- limite valeur entrant dans la plage valide 0 to 2400 ------ requestedLevel = requestedLevel > 2400 ? 2400 : requestedLevel; requestedLevel = requestedLevel < 0 ? 0 : requestedLevel; if((requestedLevel % 100) > 59) { requestedLevel = 00; } //----- trie des messages ------- switch (message.sensor) { case 2: // message 1 requestOn = requestedLevel; break; case 4: // message 2 requestOff = requestedLevel; break; } //----- commande Relay dans une plage horaire ----- if (timecurrent >= requestOn && timecurrent <= requestOff) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } //----- return value for MyC ------- send( dimmerMsg.set(requestOn) ); send( dimmerMsg4.set(requestOff) ); } }
-
@JeeLet good to know that you achieved your requirement. thanks for sharing the final result
-
No, the commands through the Schedules are not sent.
I waited for the night, but nothing happens on the Arduino.
Sending with widgets is fine
-
Hi @JeeLet for your schedule variables are not required and in
Parameters to handler
selectResource By Quick ID
and add your payload.But you are controlling time based action on your arduino sketch, but still why do you want to send the config payload from MyController schedule?
In your case controlling the V_STATUS (led or relay) directly, then you can use MyController Scheduler, otherwise you can go with your arduino sketch schedule
-
hello jkandasa
"...but why do you want to send the configuration payload from the MyController calendar?" for each Node to be autonomous, the principle of distributed intelligence, no centralization, the MyC Controller can be turned off or the link cut (and also to test MyC )
"otherwise you can use your arduino sketch program" ... Yes
MyC sends a time setting for the drift of the Arduino and also the management of time slots.
(afterwards the Gateways will have a RTC clock)Thanks
Parameters to handler select Resource By Quick ID and add your payload.