@BartE Thats great thank you. I am still learning anyway so there are gaps in my knowledge I knew I could do something like that -1.
delay was part of the original example I think?
@BartE Thats great thank you. I am still learning anyway so there are gaps in my knowledge I knew I could do something like that -1.
delay was part of the original example I think?
It looks like you are trying to add another LED/Mosfet? I have done it this way, I have 3 on mine:
To do this I may or may not have used some examples I found on this forum. I basically add the pins I am using (PWM capable) into an array. I have 4 pins defined (3 is in there twice) to get around the array references starting from 0. Probably a better way to do that but this was my quick way round it.
I have basically adapted the code from the example LED Dimmer sketch to work with the array / multiple child devices.
Hopefully thats helpful and what you were after?
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
#include <SPI.h>
#include <MySensors.h>
#define SN "MultiDimmableLED"
#define SV "1.1"
#define noLEDs 3
const int LED_Pin[] = {3, 3, 5, 6}; //put 3 in twice as a start from 0 workaround
#define FADE_DELAY 10 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
static int currentLevel = 0; // Current dim level...
MyMessage dimmerMsg(noLEDs, V_DIMMER);
MyMessage lightMsg(noLEDs, V_LIGHT);
/***
* Dimmable LED initialization method
*/
void setup()
{
// not sure this works
// Pull the gateway's current dim level - restore light level upon sendor node power-up
for (int sensor=1; sensor<=noLEDs; sensor++){
request( sensor, V_DIMMER );
}
}
void presentation() {
// Register the LED Dimmable Light with the gateway
for (int sensor=1; sensor<=noLEDs; sensor++){
present(sensor, S_DIMMER);
delay(2);
}
sendSketchInfo(SN, SV);
}
/***
* Dimmable LED main processing loop
*/
void loop()
{
}
void receive(const MyMessage &message) {
if (message.type == V_LIGHT || message.type == V_DIMMER) {
// Retrieve the power or dim level from the incoming request message
int requestedLevel = atoi( message.data );
// Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 );
// Clip incoming level to valid range of 0 to 100
requestedLevel = requestedLevel > 100 ? 100 : requestedLevel;
requestedLevel = requestedLevel < 0 ? 0 : requestedLevel;
Serial.print( "Changing LED " );
Serial.print(message.sensor);
Serial.print(", PIN " );
Serial.print( LED_Pin[message.sensor] );
Serial.print(" level to " );
Serial.print( requestedLevel );
Serial.print( ", from " );
Serial.println( currentLevel );
fadeToLevel( requestedLevel, message.sensor );
// Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
send(lightMsg.set(currentLevel > 0 ? 1 : 0));
// hek comment: Is this really nessesary?
send( dimmerMsg.set(currentLevel) );
}
}
/***
* This method provides a graceful fade up/down effect
*/
void fadeToLevel( int toLevel, int ledid ) {
int delta = ( toLevel - currentLevel ) < 0 ? -1 : 1;
while ( currentLevel != toLevel ) {
currentLevel += delta;
analogWrite( LED_Pin[ledid], (int)(currentLevel / 100. * 255) );
delay( FADE_DELAY );
}
}
Nice! I did something very similar! I used rcswitch and sent the codes directly to the controller. That way I could use the codes received as scene toggles in domoticz. I had another sketch doing the TX part though. I have since retired that set up in favour of rflink for controlling my 433MHz stuff.
C4 in your picture looks correct to me. You could put C4 up on the edge under where the radio would be as well. You have VCC up on the edge. I think the pins adjacent to that are ground too. EDIT: I think I replied before you edited your picture
You can solder the components underneath if you need to yes. I don't see why that would be an issue.
@hugows C4 goes over the ground and VCC of the NRF radio. I'm not sure about but C5, from some pictures I have seen I think it goes in the same place as C4 but I may be wrong. I have left that out without an issue.
OP - this board is great! it take the pain out of soldering the radio to a pro mini / nano. I really like these.
Did you get anywhere with this in the end? This is something I would like to do also!
Fixed the images. Apologies.
PIR was what I was thinking doing next. Perhaps more useful. There is not much room for it though.
So I got one of these things from asda a while back.
I opened it up and there was plenty of space for 'things' inside. So I connected a 3.3v regulator to the USB circuit to power a pro mini. On that, I am running the example humidity sensor sketch with repeater mode enabled. Connected to that is a DHT22. I cut a hole in the side for that to poke out of. I also managed to get the pro mini and NRF quite well stuck together. Compact is probably the word i'm after:
I tried to keep this away from the high voltage side as best I could. The gap I managed to stuff the pro mini + NRF into is a insulated area, so perfect! I am quite pleased with it.
It did just occur to me though.... the DHT could pick up heat from the USB circuit inside. I'm not sure if it runs warm when in use. I suppose I will find out.