2nd Dimming Expansion Module

Do you have a question on how to do something.
Ask in here.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

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
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

Just use the webwizard.
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

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
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

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
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

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
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

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
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

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.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

:lol:
Yes, it absolutely is an awesome device!! First huh? That's kinda cool... Hey, if you want to test code in an operational setting, just let me know.

For my setup, it makes it a clean(er) look with my family room show piece.
If I could build a hobby-business around installing and maintaining reef tanks, this device would be a key feature to the (RA based) setup. ;)

I did take the millis() check out (the parabola/slope waveforms don't change that much over a few hours) but will put it back in and experiment with working it under the full second... I'd like to work the connected channels into lightening code and I think 1 sec response is a bit too long.

Couple questions from the picture below, what are these ports and are they active?
Attachments
Arrows point to ports.
Arrows point to ports.
Cloud Wifi Hub 2.jpg (112.71 KiB) Viewed 9459 times
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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

The broadcast of data through the cloud server is not going to be fast enough for lightning.
If you want to implement that, you will have to program the cloud wifi hub code itself and implement the lightning code in there and just send a trigger signal to start and stop the lightning code.
If you want to do that, you will need to use the Arduino IDE with the latest dev branch of the libraries.
The header is for two temp probe and two input channels. They are enabled and are currently T4 and T5 and channel 6 and channel 7 of the I/O expansion.
Roberto.
User avatar
Loose
Posts: 90
Joined: Fri Sep 01, 2017 8:15 am
Location: Severna Park, MD

Re: 2nd Dimming Expansion Module

Post by Loose »

Ahhh... data throughput limit is with the cloud server and not with the module.

Header for two temp probes, two I/O ports, and can accept code independently of the RA*, this module looks better and better.
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
tngo
Posts: 131
Joined: Wed Apr 27, 2011 9:08 am

Re: 2nd Dimming Expansion Module

Post by tngo »

Hey Roberto,

Has the 2nd dimming expansion module been implemented into the libraries? I wanted to connect and test a new light fixture using a second dimming module.

Thanks,
Tim

rimai wrote:Actually,I just remember that you also have to change the ID of the 2nd expansion module.
Open the module and place a jumper on ID1.
That way both your modules will have distinct addresses.
The first one is I2CPWM_PCA9685 and the second one is I2CPWM_16CH_PCA9685.
Also, I just looked at the libraries and since both these addresses are distinct and already in the libraries, all you need to do is place this line on the setup() section:

Code: Select all

ReefAngel.Add16ChPWM();
Then you can control the channels of the second module as if it were a 16ch.

Code: Select all

ReefAngel.PWM.SetChannel(0,4096); // Sets channel 0 of 1st dimming module to 4096
ReefAngel.PWM.Set16Channel(0,4096); // Sets channel 0 of 2nd dimming module to 4096
Channels for both modules start at 0.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

It's been in the libraries for a long time, but none of the apps will allow you to override the %.
Roberto.
tngo
Posts: 131
Joined: Wed Apr 27, 2011 9:08 am

Re: 2nd Dimming Expansion Module

Post by tngo »

Okay, cool thanks.

Tim
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: 2nd Dimming Expansion Module

Post by binder »

rimai wrote:It's been in the libraries for a long time, but none of the apps will allow you to override the %.
if you are referring to the 16ch dimming module, my android app supports it and allows for overriding the %.
if you are talking about something else, then you are probably right.

Sent from my XT1585 using Tapatalk
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: 2nd Dimming Expansion Module

Post by rimai »

Oh. I thought I didnt.
Good to know :)
Roberto.
Post Reply