@Rene046 Your sketch doesn't show either of the send commands you say you are attempting. This makes it difficult to determine why it wouldn't be working. I am relative new to all of this as well, and use Vera not a Domoticz. On the first version that is sending a message, what data is getting through? I would try putting the "send" command someplace in the code where msgTemp has already been set. Then just call send(msgTemp).
Posts made by CurtisMack
-
RE: 💬 Temperature Sensor
-
RE: 💬 Temperature Sensor
Thank you for posting this project!
Could like to suggest a small change to the sketch. There are several posts out there about this not running with the latest DallasTemperature library. The call to sensors.millisToWaitForConversion won't compile because the method is not public. From another post I learned that this method is very simple and could be included in the sketch. I would suggest changing the line
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
to read
int16_t conversionTime = millisToWaitForConversion(sensors.getResolution());
and add this function to the sketch:
int16_t millisToWaitForConversion(uint8_t bitResolution)
{
switch (bitResolution)
{
case 9:
return 94;
case 10:
return 188;
case 11:
return 375;
default:
return 750;
}
}In any case, this might help the next person using this project.
-
RE: RGB Controller app on Vera causing NACK:0 messages on my sensor.
Does this look like a radio error, or something else? Could it just be message collisions? Is there a way to tell the system to attempt to resend a message on a NACK?
-
RE: RGB Controller app on Vera causing NACK:0 messages on my sensor.
I checked the logs on the Vera, and it looks like the command to change the color is being sent, but it is getting a NACK:96
50 03/10/17 18:37:37.670 luup_log:3: Arduino: Log: TSF:MSG:SEND,0-0-3-3,s=1,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:0 <0x2e8fd680>
50 03/10/17 18:37:37.720 luup_log:3: Arduino: Log: !TSF:MSG:SEND,0-0-3-3,s=2,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=NACK:96 <0x2e8fd680>
50 03/10/17 18:37:37.722 luup_log:3: Arduino: Log: TSF:MSG:SEND,0-0-3-3,s=3,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=OK:94 <0x2e8fd680>Any sugestion on how to debug this further?
-
RGB Controller app on Vera causing NACK:0 messages on my sensor.
Hi, I'm a first time poster, but plan on getting involved in this more.
I have a custom made sensor that controls a single RGB LED. The SN value is set to "Dimmable RGBW LED". I think it is working well. It is controlled with a serial controller connected to a Vera3. The device registered 3 DimmableLight sensors which I can control perfectly using the sliders. I installed the RGB Controller app on my Vera, and registered the three sensors for the three colors. This is working well unless I choose a color that would turn on the sensor 2 color. The sensor seems to be throwing an error when trying to get a status on sensor 1, so something upstream skips setting a value for 2 and jumps to sensor 3.Here is a log from my sensor. There are a couple of custom debug messages, but I think they are self explanatory. It includes the boot, a few good results, and then a few bad at the end:
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
3 TSM:INIT
4 TSF:WUR:MS=0
11 TSM:INIT:TSP OK
13 TSF:SID:OK,ID=3
14 TSM:FPAR
51 TSF:MSG:SEND,3-3-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
324 TSF:MSG:READ,0-0-3,s=255,c=3,t=8,pt=1,l=1,sg=0:0
328 TSF:MSG:FPAR OK,ID=0,D=1
2058 TSM:FPAR:OK
2059 TSM:ID
2060 TSM:ID:OK
2062 TSM:UPL
2065 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2074 TSF:MSG:READ,0-0-3,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2079 TSF:MSG:PONG RECV,HP=1
2081 TSM:UPL:OK
2083 TSM:READY:ID=3,PAR=0,DIS=1
2088 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2095 TSF:MSG:READ,0-0-3,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2102 TSF:MSG:SEND,3-3-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
2110 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
2132 TSF:MSG:READ,0-0-3,s=255,c=3,t=6,pt=0,l=1,sg=0:I
2139 TSF:MSG:SEND,3-3-0-0,s=1,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
2147 TSF:MSG:SEND,3-3-0-0,s=2,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
2154 TSF:MSG:SEND,3-3-0-0,s=3,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
2161 TSF:MSG:SEND,3-3-0-0,s=4,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
2169 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=11,pt=0,l=17,sg=0,ft=0,st=OK:Dimmable RGBW LED
2180 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.1
2186 MCO:REG:REQ
2189 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
2196 TSF:MSG:READ,0-0-3,s=255,c=3,t=27,pt=1,l=1,sg=0:1
2201 MCO:PIM:NODE REG=1
2203 MCO:BGN:STP
Setting up: 32550
Setting up: 52550
Setting up: 62550
5208 TSF:MSG:SEND,3-3-0-0,s=1,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
5215 TSF:MSG:SEND,3-3-0-0,s=2,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
5223 TSF:MSG:SEND,3-3-0-0,s=3,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
5264 !TSF:MSG:SEND,3-3-0-0,s=4,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=NACK:
5270 MCO:BGN:INIT OK,TSP=1
5273 TSF:MSG:READ,0-0-3,s=2,c=1,t=3,pt=0,l=2,sg=0:70
Message for sensor: 2 Type : 3 newLevel : 70 requestedLevel : 70
Changing level to 70, sensor 2, PIN 5
5317 !TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=2,l=2,sg=0,ft=1,st=NACK:70
5323 TSF:MSG:READ,0-0-3,s=3,c=1,t=3,pt=0,l=2,sg=0:93
Message for sensor: 3 Type : 3 newLevel : 93 requestedLevel : 93
Changing level to 93, sensor 3, PIN 6
5334 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=2,st=OK:93
25615 TSF:MSG:READ,0-0-3,s=2,c=1,t=3,pt=0,l=2,sg=0:33
25619 TSF:MSG:ACK REQ
25623 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=OK:33
Message for sensor: 2 Type : 3 newLevel : 33 requestedLevel : 33
Changing level to 33, sensor 2, PIN 5
25634 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:33
43226 TSF:MSG:READ,0-0-3,s=1,c=1,t=3,pt=0,l=2,sg=0:37
43231 TSF:MSG:ACK REQ
43235 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=OK:37
Message for sensor: 1 Type : 3 newLevel : 37 requestedLevel : 37
Changing level to 37, sensor 1, PIN 3
43246 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:37
64391 TSF:MSG:READ,0-0-3,s=1,c=1,t=3,pt=0,l=1,sg=0:0
64396 TSF:MSG:ACK REQ
64400 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:0
Message for sensor: 1 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 1, PIN 3
64410 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
64420 TSF:MSG:READ,0-0-3,s=2,c=1,t=3,pt=0,l=1,sg=0:7
64424 TSF:MSG:ACK REQ
64429 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:7
Message for sensor: 2 Type : 3 newLevel : 7 requestedLevel : 7
Changing level to 7, sensor 2, PIN 5
64474 !TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=NACK:7
64480 TSF:MSG:READ,0-0-3,s=3,c=1,t=3,pt=0,l=1,sg=0:0
64485 TSF:MSG:ACK REQ
64523 !TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=0,l=1,sg=0,ft=1,st=NACK:0
Message for sensor: 3 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 3, PIN 6
64534 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=2,st=OK:0
64543 TSF:MSG:READ,0-0-3,s=2,c=1,t=3,pt=0,l=1,sg=0:0
64548 TSF:MSG:ACK REQ
64551 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:0
Message for sensor: 2 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 2, PIN 5
64563 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
80031 TSF:MSG:READ,0-0-3,s=1,c=1,t=3,pt=0,l=2,sg=0:95
80035 TSF:MSG:ACK REQ
80039 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=OK:95
Message for sensor: 1 Type : 3 newLevel : 95 requestedLevel : 95
Changing level to 95, sensor 1, PIN 3
80051 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:95
80060 TSF:MSG:READ,0-0-3,s=2,c=1,t=3,pt=0,l=1,sg=0:0
80065 TSF:MSG:ACK REQ
80069 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:0
Message for sensor: 2 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 2, PIN 5
80080 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
80090 TSF:MSG:READ,0-0-3,s=3,c=1,t=3,pt=0,l=1,sg=0:0
80094 TSF:MSG:ACK REQ
80098 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:0
Message for sensor: 3 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 3, PIN 6
80109 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
121469 TSF:MSG:READ,0-0-3,s=1,c=1,t=3,pt=0,l=1,sg=0:0
121475 TSF:MSG:ACK REQ
121479 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:0
Message for sensor: 1 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 1, PIN 3
121490 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
121499 TSF:MSG:READ,0-0-3,s=2,c=1,t=3,pt=0,l=1,sg=0:0
121504 TSF:MSG:ACK REQ
121508 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:0
Message for sensor: 2 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 2, PIN 5
121520 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
121529 TSF:MSG:READ,0-0-3,s=3,c=1,t=3,pt=0,l=2,sg=0:95
121534 TSF:MSG:ACK REQ
121538 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=OK:95
Message for sensor: 3 Type : 3 newLevel : 95 requestedLevel : 95
Changing level to 95, sensor 3, PIN 6
121549 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:95
149488 TSF:MSG:READ,0-0-3,s=1,c=1,t=3,pt=0,l=1,sg=0:0
149493 TSF:MSG:ACK REQ
149531 !TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=NACK:0
Message for sensor: 1 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 1, PIN 3
149542 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=1,st=OK:0
149552 TSF:MSG:READ,0-0-3,s=3,c=1,t=3,pt=0,l=2,sg=0:10
149557 TSF:MSG:ACK REQ
149561 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=OK:10
Message for sensor: 3 Type : 3 newLevel : 10 requestedLevel : 10
Changing level to 10, sensor 3, PIN 6
149572 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:10
192808 TSF:MSG:READ,0-0-3,s=1,c=1,t=3,pt=0,l=1,sg=0:0
192813 TSF:MSG:ACK REQ
192850 !TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=NACK:0
Message for sensor: 1 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 1, PIN 3
192862 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=1,st=OK:0
192872 TSF:MSG:READ,0-0-3,s=3,c=1,t=3,pt=0,l=2,sg=0:10
192877 TSF:MSG:ACK REQ
192880 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=OK:10
Message for sensor: 3 Type : 3 newLevel : 10 requestedLevel : 10
Changing level to 10, sensor 3, PIN 6
192892 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:10
239961 TSF:MSG:READ,0-0-3,s=1,c=1,t=3,pt=0,l=2,sg=0:95
239965 TSF:MSG:ACK REQ
240004 !TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=NACK:95
Message for sensor: 1 Type : 3 newLevel : 95 requestedLevel : 95
Changing level to 95, sensor 1, PIN 3
240015 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=1,st=OK:95
240025 TSF:MSG:READ,0-0-3,s=3,c=1,t=3,pt=0,l=1,sg=0:0
240029 TSF:MSG:ACK REQ
240033 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:0
Message for sensor: 3 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 3, PIN 6
240045 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
272983 TSF:MSG:READ,0-0-3,s=1,c=1,t=3,pt=0,l=1,sg=0:2
272988 TSF:MSG:ACK REQ
273026 !TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=NACK:2
Message for sensor: 1 Type : 3 newLevel : 2 requestedLevel : 2
Changing level to 2, sensor 1, PIN 3
273037 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=1,st=OK:2
273046 TSF:MSG:READ,0-0-3,s=3,c=1,t=3,pt=0,l=2,sg=0:95
273051 TSF:MSG:ACK REQ
273055 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=OK:95
Message for sensor: 3 Type : 3 newLevel : 95 requestedLevel : 95
Changing level to 95, sensor 3, PIN 6
273067 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:95
312927 TSF:MSG:READ,0-0-3,s=1,c=1,t=3,pt=0,l=2,sg=0:95
312932 TSF:MSG:ACK REQ
312936 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=OK:95
Message for sensor: 1 Type : 3 newLevel : 95 requestedLevel : 95
Changing level to 95, sensor 1, PIN 3
312947 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:95
312956 TSF:MSG:READ,0-0-3,s=2,c=1,t=3,pt=0,l=1,sg=0:0
312962 TSF:MSG:ACK REQ
312966 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:0
Message for sensor: 2 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 2, PIN 5
312976 TSF:MSG:SEND,3-3-0-0,s=2,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
312986 TSF:MSG:READ,0-0-3,s=3,c=1,t=3,pt=0,l=1,sg=0:2
312991 TSF:MSG:ACK REQ
312994 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=OK:2
Message for sensor: 3 Type : 3 newLevel : 2 requestedLevel : 2
Changing level to 2, sensor 3, PIN 6
313006 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:2
449119 TSF:MSG:READ,0-0-3,s=1,c=1,t=3,pt=0,l=1,sg=0:0
449123 TSF:MSG:ACK REQ
449161 !TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=0,l=1,sg=0,ft=0,st=NACK:0
Message for sensor: 1 Type : 3 newLevel : 0 requestedLevel : 0
Changing level to 0, sensor 1, PIN 3
449172 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=3,pt=2,l=2,sg=0,ft=1,st=OK:0
449182 TSF:MSG:READ,0-0-3,s=3,c=1,t=3,pt=0,l=2,sg=0:95
449186 TSF:MSG:ACK REQ
449190 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=0,l=2,sg=0,ft=0,st=OK:95
Message for sensor: 3 Type : 3 newLevel : 95 requestedLevel : 95
Changing level to 95, sensor 3, PIN 6
449202 TSF:MSG:SEND,3-3-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:95
1011819 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
1011825 TSF:MSG:BC
1011942 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0Here is the sketch. The code is adapted from several projects I found on this site, but has been modified heavily without attribution (so far). Don't laugh or cringe too much. It is my first attempt at one of these:
// Enable debug prints to serial monitor
#define MY_DEBUG// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69#include <MySensors.h>
#define SN "Dimmable RGBW LED"
#define SV "1.1"#define RED_PIN 3
#define GREEN_PIN 5
#define BLUE_PIN 6
#define WHITE_PIN 0
#define FADE_DELAY 10 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)int RGB_pins[5] = {0, RED_PIN, GREEN_PIN, BLUE_PIN,WHITE_PIN};
int CurrentValue[5] = {0,0,0,0,0};
int r = 1;
int g = 2;
int b = 3;
int w = 4;
int i;
int newLevel;
char convBuffer[10];static int16_t currentLevel = 0; // Current dim level...
MyMessage RedStatus(r, V_DIMMER);
MyMessage GreenStatus(g, V_DIMMER);
MyMessage BlueStatus(b, V_DIMMER);
MyMessage WhiteStatus(w, V_DIMMER);/***
Dimmable LED initialization method
*/
void setup()
{
for(int i = 1; i < 4; i++)
{
Serial.print( "Setting up: " );
Serial.print(RGB_pins[i]);
pinMode(RGB_pins[i], OUTPUT);
analogWrite(RGB_pins[i], 0);
Serial.print(255);
delay( 1000 );
analogWrite(RGB_pins[i], 255);
Serial.println(0);
}// Pull the gateway's current dim level - restore light level upon sendor node power-up
request( r, V_DIMMER );
request( g, V_DIMMER );
request( b, V_DIMMER );
request( w, V_DIMMER );
}void presentation()
{
// Register the LED Dimmable Light with the gateway
present( r, S_DIMMER );
present( g, S_DIMMER );
present( b, S_DIMMER );
present( w, S_DIMMER );
sendSketchInfo(SN, SV);
}/***
Dimmable LED main processing loop
*/
void loop()
{
}void receive(const MyMessage &message)
{
if (message.type == V_LIGHT || message.type == V_DIMMER) {newLevel = atoi(message.getString(convBuffer)); int requestedLevel = atoi( message.data ); i = message.sensor; Serial.print( "Message for sensor: " ); Serial.print( i ); Serial.print( " Type : " ); Serial.print( message.type ); Serial.print( " newLevel : " ); Serial.print( newLevel ); Serial.print( " requestedLevel : " ); Serial.println( requestedLevel ); fadeToLevel (i, newLevel);
}
}/***
This method provides a graceful fade up/down effect
*/
void fadeToLevel(int LED, int toLevel )
{// int delta = ( toLevel - CurrentValue[LED] ) < 0 ? -1 : 1;
// while ( currentLevel != toLevel ) {
// currentLevel += delta;
// analogWrite( RGB_pins[LED], (int)(currentLevel / 100. * 255) );
// delay( FADE_DELAY );
// }
if (LED != 4){
analogWrite( RGB_pins[LED], (int)((100 -toLevel) / 100. * 255) );
}Serial.print( "Changing level to " ); Serial.print( newLevel ); Serial.print( ", sensor " ); Serial.print( LED ); Serial.print( ", PIN " ); Serial.println( RGB_pins[LED] ); sendStatus(LED, toLevel);
}
void sendStatus(int idx, int level) {
switch (idx) {
case 1:
send(RedStatus.set(level), false);
break;
case 2:
send(GreenStatus.set(level), false);
break;
case 3:
send(BlueStatus.set(level), false);
break;}
}Thank you in advance for any time you spend on this.