MySensors shield and RGBW Controller
-
Is it available for other people yet? I am very interested in LED strip drivers connected to mySensor network and your PCB seems to fit the bill nicely.
Good job.
-AM
-
Not yet, although the designs are above. I have to work out the errors in my normal pcb yet. Then I can easily switch over to the RGB(W) one.
PS: Good part: both nrf and arduino are still working. Bad part: They shut down again after about a second. So it has to be a power issue. What are the right settings/fuses/things to keep the arduino pro mini (3.3V) running with batteries at 2.8V and lower?
-
Thanks for the response. I will be watching your progress closely as I am very interested in this.
-AM
-
It's a little sad that it took me so long but I finally managed to find a few minutes to "finalize" and test my sketch.
Here is my working code for an RGBW node that is based on MySensors and works with domoticz (other controllers might send different strings => so you would have to change one part of the sketch).
The sketch smoothly fades between colors and seemed to be stable in my test. What I still want to add is some kind of saved last values for possible restarts or loss of connection.I am gratefull for any feedback.
Next I will finalize my (test) pcb design and order that.
-
i would like to test this RGWB also, are the PCB gerber files available ?
-
I was finally able to get my PCB designs done. They are currently being produced by dirtypcbs.com
I switched to big(ger) mosfets to be able to drive a longer LED strip and easier to use through hole components instead of SMD. My breadboard test worked great so I am really curious to see this in action.
I also updated my github repo with the Target3001 based design, XGerber export and a eagle file export (although I am not really sure how that works, I never really used eagle myself).
If you simply want to try these unchanged PCBs yourself here is a link where you can buy them: http://dirtypcbs.com/view.php?share=14600&accesskey=e4f6cec8b8aadb845d51076b0f1aaab0
Although I warn you, they are not tested yet!Love to hear your feedback guys!
-
I was finally able to get my PCB designs done. They are currently being produced by dirtypcbs.com
I switched to big(ger) mosfets to be able to drive a longer LED strip and easier to use through hole components instead of SMD. My breadboard test worked great so I am really curious to see this in action.
I also updated my github repo with the Target3001 based design, XGerber export and a eagle file export (although I am not really sure how that works, I never really used eagle myself).
If you simply want to try these unchanged PCBs yourself here is a link where you can buy them: http://dirtypcbs.com/view.php?share=14600&accesskey=e4f6cec8b8aadb845d51076b0f1aaab0
Although I warn you, they are not tested yet!Love to hear your feedback guys!
Nice work! Do you have a BOM for the RGBW board?
-
I was finally able to get my PCB designs done. They are currently being produced by dirtypcbs.com
I switched to big(ger) mosfets to be able to drive a longer LED strip and easier to use through hole components instead of SMD. My breadboard test worked great so I am really curious to see this in action.
I also updated my github repo with the Target3001 based design, XGerber export and a eagle file export (although I am not really sure how that works, I never really used eagle myself).
If you simply want to try these unchanged PCBs yourself here is a link where you can buy them: http://dirtypcbs.com/view.php?share=14600&accesskey=e4f6cec8b8aadb845d51076b0f1aaab0
Although I warn you, they are not tested yet!Love to hear your feedback guys!
@LastSamurai: I would also be really interested in the BOM!
-
I will post a real BOM on my github repo when I find the time for it (hopefully soon). It's not very complicated though:
- Arduino Pro mini
- NRF24L01+
- The rectangle on the bottom right side is a step down converter like e.g. this
- 4 10k stepup resistors and 4 mosfets
- 2 caps, one to smooth the 3.3 voltage line and one for the NRF. I guess it should work without them too most of the time
-
@LastSamurai You have an error on your RGBW board! The PWM pins for a Pro Mini are not 3,4,5 and 6! They should be according to this:
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
-
@LastSamurai You have an error on your RGBW board! The PWM pins for a Pro Mini are not 3,4,5 and 6! They should be according to this:
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
@korttoma said:
@LastSamurai You have an error on your RGBW board! The PWM pins for a Pro Mini are not 3,4,5 and 6! They should be according to this:
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
Ah yes, thanks for the reminder! I knew this at design time (though I forgot it myselft now). Pins 9-11 are already used by the nrf module, so there aren't enough pins left for 4x PWM. RGB channels are using the pins 3,5,6 in my design and white the "normal" pin 4. This isn't a huge problem because at least in domitcz all that the white channel does is on/off anyways (or mostly). I guess I have to update the texts though.
Do you guys know if there is a way to free up one additional pwm pin so that true 4 way pwm is possible? If thats not possible there is software pwm (although that might be a problem when using the network..?!).
@jeti For my tests I am using IRFZ44N, but that really only depends on how many leds you want to be able to drive.
-
@korttoma said:
@LastSamurai You have an error on your RGBW board! The PWM pins for a Pro Mini are not 3,4,5 and 6! They should be according to this:
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
Ah yes, thanks for the reminder! I knew this at design time (though I forgot it myselft now). Pins 9-11 are already used by the nrf module, so there aren't enough pins left for 4x PWM. RGB channels are using the pins 3,5,6 in my design and white the "normal" pin 4. This isn't a huge problem because at least in domitcz all that the white channel does is on/off anyways (or mostly). I guess I have to update the texts though.
Do you guys know if there is a way to free up one additional pwm pin so that true 4 way pwm is possible? If thats not possible there is software pwm (although that might be a problem when using the network..?!).
@jeti For my tests I am using IRFZ44N, but that really only depends on how many leds you want to be able to drive.
@LastSamurai To free up an additional pin for PWM, I believe you can change the CE and CS pins in the GW constructor. Use pin 4 for for CE to the radio and reroute the MOSFET to pin 9. And then designate the change in the GW constructor:
MyTransportNRF24 transport(4, 10);
MySensor gw(transport); -
@Dwalt is absolutely right. I have been using this kind of setup for a looong time allready.
-
I finally found the time to really test my RGBW boards and I found another error: 2 pins of the mosfets are switched. To test it anyways I just took the mosfets and bend some legs to get them to the right connectors on the pcb. Aside from that I tested it for some days and it works beautifully. Dimming, on/off, color changing and the rgb/white switching works.
I will try to create a second version soon that uses 4 pwm pins (so that white can be dimmed to) and fixes the mosfet's pins. Perhaps i'll switch to a barebone atmega 328p too because the full pro mini is kinda overkill here and I might be able to make smaller pcbs then.After I found out that my problems with programming the pro minis comes from FTDI's newest driver "features" (always prints "NON GENUINE DEVICE FOUND!" on the serial port) I can now also try my normal sensors boards again with some low power modifications.
What's annoying me at the moment is that my raspberry pi (running my domoticz) controller won't restart at the moment. I'll have to fix that first.
As always any input is welcome and I'll try to post updates and pictures as soon as possible.
-
Good news (I guess ;) ). I already redid my raspberry pi controller (where I kinda killed the old sd card :expressionless: ) and also fixed the 2 errors in my pcb.
Sometimes in the next few days I'll try out a smaller pcb with the barebone arduino and test my sensor nodes again. -
hi,
nice work,
I not understand why you said 2 pins of the mosfets are switched, for me it's ok,
I see G to arduino pins, S at center, and D to leds.. I miss something ?
I think I will buy some of them for testingps: maybe you can add your project on openhardware.io
sry for my english
-
hi,
nice work,
I not understand why you said 2 pins of the mosfets are switched, for me it's ok,
I see G to arduino pins, S at center, and D to leds.. I miss something ?
I think I will buy some of them for testingps: maybe you can add your project on openhardware.io
sry for my english
@vil1driver Thanks you! I did change them to IRFZ44N's to be able to drive longer strips. I think the new schematics aren't uploaded here yet. I did switch drain and source pins there. Other than that it seems to be working perfectly, so I will create a new (and hopefully final) version soon.
I am also thinking about adding SPI pins. Perhaps I also add pins for a DHT11/22, there is still some free space on there. Does anyone have another idea what would be good to add/change?
As soon as the updated PCB is done I will update my github and I guess also open a project on openhardware.io.
-
I just finished building another prototype and it's mostly working fine. I still have some lag/network issues and I am not 100% sure about the perfect software/dimming either but I am working on that.
I will update the code in my git soon and design the new board (I am trying to learn using kicad for that).With the RGBW strip I am using red seems to be a lot darker than the other colors. Has someone seen similar behaviour? Or an idea how to fix that?
-
The problem with the red channel seems to be on the controller's side. Once I switches red and green wires the green got dimmed way too much. I am not sure yet if i's software or hardware thats causing the problem though. :worried:
I now have a real demo up and running and found another problem: most of the time sending commands works but about 20-40% of the command simply get ignored. Once that happens it takes some time to react at all again.
On/off seems to work most of the time, changing colors slightly less, changing to/from white most of the time doesn't and dimming doesn't seem to work at all. It is really strange.
Also the domoticz webinterface gets really laggy after some of the commands failed.
Waiting some time and then retrying seems to help.Is there a good way to debug the domoticz/serial gateway part of the network (because the rgbw controller worked well when I tested it before). The domoticz log only gives me entries like this:
2016-03-12 18:23:46.917 (MySensors USB-Serial Gateway) Lighting Limitless/Applamp (RGBW test light)and I have no idea how to see what the serial output to the gateway is.
Can anyone help?
The updated code is in my github and here. If you find errors or stuff that could be improved please tell me :)
/** Based on the MySensors Project: http://www.mysensors.org This sketch controls a (analog)RGBW strip by listening to new color values from a (domoticz) controller and then fading to the new color. Version 0.9 TODO safe/request values after restart/loss of connection */ #define SN "RGBW Led strip testSketch 3" #define SV "v0.9" // Load mysensors library #include <MySensor.h> // Load Serial Peripheral Interface library #include <SPI.h> // Arduino pin attached to driver pins #define RED_PIN 3 #define WHITE_PIN 4 #define GREEN_PIN 5 #define BLUE_PIN 6 #define NUM_CHANNELS 4 // how many channels, RGBW=4 RGB=3... #define SENSOR_ID 1 // Smooth stepping between the values #define STEP 1 #define INTERVAL 10 const int pwmIntervals = 255; float R; // equation for dimming curve MySensor gw; // Stores the current color settings byte channels[4] = {RED_PIN, GREEN_PIN, BLUE_PIN, WHITE_PIN}; byte values[4] = {100, 100, 100, 100}; byte target_values[4] = {100, 100, 100, 100}; // stores dimming level byte dimming = 100; byte target_dimming = 100; // tracks if the strip should be on of off boolean isOn = true; // time tracking for updates unsigned long lastupdate = millis(); void setup() { // Initializes the sensor node (with callback function for incoming messages) gw.begin(incomingMessage, 123); // 123 = node id for testing // Present sketch (name, version) gw.sendSketchInfo(SN, SV); // Register sensors (id, type, description, ack back) gw.present(SENSOR_ID, S_RGBW_LIGHT, "RGBW test light", true); // Set all channels to output (pin number, type) for (int i = 0; i < NUM_CHANNELS; i++) { pinMode(channels[i], OUTPUT); } // set up dimming R = (pwmIntervals * log10(2))/(log10(255)); // init lights updateLights(); // debug if (isOn) { Serial.println("RGBW is running..."); } Serial.println("Waiting for messages..."); } void loop() { // Process incoming messages (like config and light state from controller) - basically keep the mysensors protocol running gw.process(); // and set the new light colors if (millis() > lastupdate + INTERVAL) { updateLights(); lastupdate = millis(); } } // callback function for incoming messages void incomingMessage(const MyMessage &message) { Serial.print("Got a message - "); Serial.print("Messagetype is: "); Serial.println(message.type); // acknoledgment if (message.isAck()) { Serial.println("Got ack from gateway"); } // new dim level else if (message.type == V_DIMMER) { Serial.println("Dimming to "); Serial.println(message.getString()); target_dimming = message.getByte(); } // on / off message else if (message.type == V_STATUS) { Serial.print("Turning light "); isOn = message.getInt(); if (isOn) { Serial.println("on"); } else { Serial.println("off"); } } // new color value else if (message.type == V_RGBW) { const char * rgbvalues = message.getString(); inputToRGBW(rgbvalues); } } // this gets called every INTERVAL milliseconds and updates the current pwm levels for all colors void updateLights() { // update pin values -debug //Serial.println(greenval); //Serial.println(redval); //Serial.println(blueval); //Serial.println(whiteval); //Serial.println(target_greenval); //Serial.println(target_redval); //Serial.println(target_blueval); //Serial.println(target_whiteval); //Serial.println("+++++++++++++++"); // for each color for (int v = 0; v < NUM_CHANNELS; v++) { if (values[v] < target_values[v]) { values[v] += STEP; if (values[v] > target_values[v]) { values[v] = target_values[v]; } } if (values[v] > target_values[v]) { values[v] -= STEP; if (values[v] < target_values[v]) { values[v] = target_values[v]; } } } // dimming if (dimming < target_dimming) { dimming += STEP; if (dimming > target_dimming) { dimming = target_dimming; } } if (dimming > target_dimming) { dimming -= STEP; if (dimming < target_dimming) { dimming = target_dimming; } } /* // debug - new values Serial.println(greenval); Serial.println(redval); Serial.println(blueval); Serial.println(whiteval); Serial.println(target_greenval); Serial.println(target_redval); Serial.println(target_blueval); Serial.println(target_whiteval); Serial.println("+++++++++++++++"); */ // set actual pin values for (int i = 0; i < NUM_CHANNELS; i++) { if (isOn) { //analogWrite(channels[i], dimming / 100 * values[i]); // non linear fading, idea from https://diarmuid.ie/blog/pwm-exponential-led-fading-on-arduino-or-other-platforms/ analogWrite(channels[i], pow (2, (values[i] / R)) - 1); } else { analogWrite(channels[i], 0); } } } // converts incoming color string to actual (int) values // ATTENTION this currently does nearly no checks, so the format needs to be exactly like domoticz sends the strings void inputToRGBW(const char * input) { Serial.print("Got color value of length: "); Serial.println(strlen(input)); if (strlen(input) == 6) { Serial.println("new rgb value"); target_values[0] = fromhex (& input [0]); target_values[1] = fromhex (& input [2]); target_values[2] = fromhex (& input [4]); target_values[3] = 0; } else if (strlen(input) == 9) { Serial.println("new rgbw value"); target_values[0] = fromhex (& input [1]); // ignore # as first sign target_values[1] = fromhex (& input [3]); target_values[2] = fromhex (& input [5]); target_values[3] = fromhex (& input [7]); } else { Serial.println("Wrong length of input"); } Serial.print("New color values: "); Serial.println(input); for (int i = 0; i < NUM_CHANNELS; i++) { Serial.print(target_values[i]); Serial.print(", "); } Serial.println(""); Serial.print("Dimming: "); Serial.println(dimming); } // converts hex char to byte byte fromhex (const char * str) { char c = str [0] - '0'; if (c > 9) c -= 7; int result = c; c = str [1] - '0'; if (c > 9) c -= 7; return (result << 4) | c; }Update:
fixed some small errors in the code.
I also just debugged the rgbw controller via serial to usb and the problem seems to be that most commands just don't reach the node. At least I got no errors via serial.
There also seems to be some kind of jam sometimes where I send multiple commands nothing happens and then after some seconds all of them are executed in very short order