2nd Dimming Expansion Module

Do you have a question on how to do something.
Ask in here.

Posts: 12241
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Wed Feb 28, 2018 7:04 pm
OK, so we need to update both your RA* and your cloud wifi hub.
Let do the RA* first.
On your code, add this above setup()
Code: Select all
unsigned long last16channelcheck = millis();
int OldPercentage16[16];
byte OldPercentage16Override[16];
char buffer[15];


Add this to setup()
Code: Select all
  ReefAngel.Add16ChPWM();


And add this to loop() right above ReefAngel.Network.Cloud()
Code: Select all
  ReefAngel.PWM.Set16Channel(0, (now() % 10 < 5) ? 50 : 100);
  if (millis() - last16channelcheck > 1000 && ReefAngel.Network.IsMQTTConnected())
  {
    last16channelcheck = millis();
    for (byte a = 0; a < 16; a++)
    {
      if (ReefAngel.PWM.SIXTEENChExpansionChannel[a] != OldPercentage16[a])
      {
        if (a<10)
          sprintf(buffer, "%s0%d:%d", "PWM16E", a, ReefAngel.PWM.SIXTEENChExpansionChannel[a]);
        else
          sprintf(buffer, "%s%d:%d", "PWM16E", a, ReefAngel.PWM.SIXTEENChExpansionChannel[a]);
        Serial.println(buffer);
        ReefAngel.Network.CloudPublish(buffer);
        OldPercentage16[a] = ReefAngel.PWM.SIXTEENChExpansionChannel[a];
      }
      if (ReefAngel.PWM.SIXTEENChExpansionChannelOverride[a] != OldPercentage16Override[a])
      {
        if (a<10)
          sprintf(buffer, "%s0%d:%d", "PWM16EO", a, ReefAngel.PWM.SIXTEENChExpansionChannelOverride[a]);
        else
          sprintf(buffer, "%s%d:%d", "PWM16EO", a, ReefAngel.PWM.SIXTEENChExpansionChannelOverride[a]);
        Serial.println(buffer);
        ReefAngel.Network.CloudPublish(buffer);
        OldPercentage16Override[a] = ReefAngel.PWM.SIXTEENChExpansionChannelOverride[a];
      }
    }
  }


This should start sending the 16ch messages to the cloud server.
Roberto.
User avatar
Posts: 50
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD
PostPosted: Thu Mar 01, 2018 7:01 am
Thanks Roberto. I got off work late yesterday.

Will update the RA* with this code this evening.

Question - I use the WebWizard's code page to upload code, is there another way I could/should be using? I do have the Reef Angel Arduino loaded on my computer, but the RA* isn't listed there on the drop-down list and am didn't see an option for remote uploading; I try not to touch the RA* as it likes to reboot when I do.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink

Posts: 12241
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Thu Mar 01, 2018 8:15 am
Just use the webwizard.
Roberto.
User avatar
Posts: 50
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD
PostPosted: Thu Mar 01, 2018 3:56 pm
Added and uploaded.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink

Posts: 12241
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Thu Mar 01, 2018 10:36 pm
Ok, now using a paper clip, push the button through the pinhole on the side of the module.
If the module is connected to wifi, it should start downloading the new firmware. It will go through a reset and come back alive in a few seconds.
Use Arduino IDE and open serial port to get the debug message.
Roberto.
User avatar
Posts: 50
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD
PostPosted: Fri Mar 02, 2018 5:16 am
Module reset

Serial output:
Code: Select all
Connecting to cloud server...
Connected
Subscribing to Loose/out/#
Loose/in: all:0
Loose/in: io:255
cloud:PWM16E00:2047
PWM16E00:2047
cloud:ATOLOW:0
cloud:ATOHIGH:0
cloud:EM:137
cloud:EM1:20
cloud:REM:7
cloud:BID:4
cloud:AF:0
cloud:SF:0
cloud:PWMD:89
cloud:PWMA:100
cloud:PWMDO:255
cloud:PWMAO:255
cloud:R1:99
R1:99
cloud:ROFF1:255
ROFF1:255
cloud:RON1:0
RON1:0
cloud:R2:131
R2:131
cloud:ROFF2:255
ROFF2:255
cloud:RON2:0
RON2:0
cloud:R3:0
R3:0
cloud:ROFF3:255
ROFF3:255
cloud:RON3:0
RON3:0
cloud:R4:0
R4:0
cloud:ROFF4:255
ROFF4:255
cloud:RON4:0
RON4:0
cloud:R5:0
R5:0
cloud:ROFF5:255
ROFF5:255
cloud:RON5:0
RON5:0
cloud:R6:0
R6:0
cloud:ROFF6:255
ROFF6:255
cloud:RON6:0
RON6:0
cloud:R7:0
R7:0
cloud:ROFF7:255
ROFF7:255
cloud:RON7:0
RON7:0
cloud:R8:0
R8:0
cloud:ROFF8:255
ROFF8:255
cloud:RON8:0
RON8:0
cloud:ALARM:0
cloud:PWMD2:36
cloud:PWMA2:0
cloud:PWMD2O:255
cloud:PWMA2O:255
cloud:WL:0
cloud:WL1:103
cloud:WL2:83
cloud:WL3:35
cloud:WL4:4
cloud:HUM:0
cloud:DCM:0
cloud:DCS:0
cloud:DCD:0
cloud:DCT:0
cloud:PWME0:15
PWME0:15
cloud:PWME1:0
PWME1:0
cloud:PWME2:12
PWME2:12
cloud:PWME3:0
PWME3:0
cloud:PWME4:0
PWME4:0
cloud:PWME5:0
PWME5:0
cloud:PWME0O:255
PWME0O:255
cloud:PWME1O:255
PWME1O:255
cloud:PWME2O:255
PWME2O:255
cloud:PWME3O:255
PWME3O:255
cloud:PWME4O:255
PWME4O:255
cloud:PWME5O:255
PWME5O:255
cloud:AIW:0
cloud:AIB:0
cloud:AIRB:0
cloud:RFM:0
cloud:RFS:0
cloud:RFD:0
cloud:RFW:0
cloud:RFRB:0
cloud:RFR:0
cloud:RFG:0
cloud:RFB:0
cloud:RFI:0
cloud:RFWO:0
cloud:RFRBO:0
cloud:RFRO:0
cloud:RFGO:0
cloud:RFBO:0
cloud:RFIO:0
cloud:IO:0
cloud:LEAK:0
cloud:C0:0
cloud:C1:0
cloud:C2:0
cloud:C3:0
cloud:C4:0
cloud:C5:0
cloud:C6:0
cloud:C7:0
cloud:R:0
cloud:ROFF:255
cloud:RON:0
cloud:T1:739
cloud:T2:768
cloud:T3:771
cloud:PH:797
cloud:T4:694
cloud:T5:0
cloud:T6:0
cloud:ORP:0
cloud:SAL:344
cloud:PHE:0
cloud:PAR:0
cloud:CEXP0:0
cloud:CEXP1:0
cloud:CEXP2:0
cloud:CEXP3:0
cloud:CEXP4:0
cloud:CEXP5:0
cloud:CEXP6:0
cloud:CEXP7:0
cloud:WL1:102
cloud:PH:798
cloud:WL1:99
cloud:PH:797
cloud:PWM16E00:4095
PWM16E00:4095
cloud:WL1:98
cloud:PH:798
cloud:WL2:84
cloud:PH:797
cloud:WL1:102
cloud:PH:798
cloud:WL1:99
cloud:WL2:82
cloud:WL1:102
cloud:WL2:83
cloud:PWM16E00:2047
PWM16E00:2047
cloud:WL1:101
cloud:WL1:103
cloud:WL2:82
cloud:PH:797
cloud:WL1:102
cloud:WL2:84
cloud:PH:798
cloud:WL1:98
cloud:WL2:83
cloud:WL1:100
cloud:PWM16E00:4095
PWM16E00:4095

Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
User avatar
Posts: 50
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD
PostPosted: Fri Mar 02, 2018 8:37 am
A note for someone else that is using this thread for their setup, when I reset the Cloud Wifi Hub, it didn't auto reconnect to the networks. I just did the factory reset procedures, as detailed in the Cloud Wifi Attachment Manual 2.0.1.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
User avatar
Posts: 50
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD
PostPosted: Fri Mar 02, 2018 9:09 am
Roberto, up and working with lights hooked to 0x41 channel 0 alternating from dim (50%) to bright (100%) every second.

Since I'm a novice at the language please allow me to confirm some things.

This code alternates between a dimming setting of 50% and 100% each time through the loop:
Code: Select all
  ReefAngel.PWM.Set16Channel(0, (now() % 10 < 5) ? 50 : 100);


I'm not sure what '% 10 < 5' actually does?

This 'if' statement checks to see if one second has passed since the last check and if MQTT is connected with the first line resetting the variable to the current time:
Code: Select all
if (millis() - last16channelcheck > 1000 && ReefAngel.Network.IsMQTTConnected())
  {
     last16channelcheck = millis();
     ...
     ...
  }


This main part of the code checks each of the 16 channels to see if there is a change in the percentage setting and if there is, it writes the new value to cloud Wifi hub using the variable 'buffer.' It then sets the old percentage equal to the new percentage for the next time it's checked (done on a per channel basis):
Code: Select all
for (byte a = 0; a < 16; a++)
    {
      if (ReefAngel.PWM.SIXTEENChExpansionChannel[a] != OldPercentage16[a])
      {
        if (a<10)
          sprintf(buffer, "%s0%d:%d", "PWM16E", a, ReefAngel.PWM.SIXTEENChExpansionChannel[a]);
        else
          sprintf(buffer, "%s%d:%d", "PWM16E", a, ReefAngel.PWM.SIXTEENChExpansionChannel[a]);
        Serial.println(buffer);
        ReefAngel.Network.CloudPublish(buffer);
        OldPercentage16[a] = ReefAngel.PWM.SIXTEENChExpansionChannel[a];
      }


This section of code is repeated for the Override function.
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink
User avatar
Posts: 50
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD
PostPosted: Fri Mar 02, 2018 9:20 am
I did a modification for testing, to this, for the 6ch expansion I currently have:
Code: Select all
    ReefAngel.PWM.Set16Channel(0, (now() % 10 < 5) ? 100 : 3);
    ReefAngel.PWM.Set16Channel(1, (now() % 10 < 5) ? 3 : 100);
    ReefAngel.PWM.Set16Channel(2, (now() % 10 < 5) ? 100 : 3);
    ReefAngel.PWM.Set16Channel(3, (now() % 10 < 5) ? 3 : 100);
    ReefAngel.PWM.Set16Channel(4, (now() % 10 < 5) ? 100 : 3);
    ReefAngel.PWM.Set16Channel(5, (now() % 10 < 5) ? 3 : 100);
  if (millis() - last16channelcheck > 1000 && ReefAngel.Network.IsMQTTConnected())
  {
    last16channelcheck = millis();
    for (byte a = 0; a < 6; a++) // a < 16 has been Modified for 6ch Dimming module


I believe I can make this operational code by changing
Code: Select all
ReefAngel.PWM.Set16Channel(0, (now() % 10 < 5) ? 100 : 3);

to something like this
Code: Select all
ReefAngel.PWM.Set16Channel(0, PWMParabola(13,0,20,0,0,63,0) );

and changing this
Code: Select all
  if (millis() - last16channelcheck > 1000 && ReefAngel.Network.IsMQTTConnected())

to this
Code: Select all
  if (ReefAngel.Network.IsMQTTConnected() )

Would this be correct?
Try to learn something about everything and everything about something... Thomas Huxley
210gal DT | 50gal sump/refug | Jebao DCP 10000 pump | RO 200-int skimmer | DIY built stand | DIY 160 led, 12 channel, 458 watt, on MakersLED 72" heatsink

Posts: 12241
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Fri Mar 02, 2018 5:50 pm
Yes, the code was set to alternate between 50 and 100.
Correct, you can change that code I used for testing to whatever you want including the one you posted above.
don't change anything regarding the millis() check.
The reason it is there is because sometimes, the module doesn't like to receive too much data too fast, so the check is simply to make sure we only send data once per second.
Just add the part where you set the 16 channels to whatever waveform type you want and you should be good.
Isn't the cloud wifi hub awesome???!!!!
I think you are the first one to actually use it :)
I tested it once with a Japanese guy holding an RA* in Japan and I was changing the water level module here in the USA. He was receiving data in Japan on his RA* just fine and it was so amazing!!! :)
Roberto.
PreviousNext

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 2 guests

cron