As an OH3 user looking to upgrade, I'm wondering, do all of the binding points from OH to mysensor nodes, children etc work after upgrade and loading this new .jar?
Or do I have to re-build everything in OH?
As an OH3 user looking to upgrade, I'm wondering, do all of the binding points from OH to mysensor nodes, children etc work after upgrade and loading this new .jar?
Or do I have to re-build everything in OH?
Hi OSD, thanks for your input.
Those are the 4 relays on IO-MCU. I buzzed out the circuit and found that I had an open circuit on the 12v line to the relays.
Furthermore 2 of the relays indicator LEDs were illuminating, 2 were not.
I suspect, when I first juiced up the circuit on this MCU, the 2 relays fired, but I'd made the trace too thin for the required current. I wired up some jumper wire on the reverse of the PCB and the 2 relays started working.
The 2 that remain inoperable?
https://forum.arduino.cc/t/using-pins-a6-a7-on-pro-mini-compatible/118050
A6 and A7 can only be analogue inputs, cannot be digitally written to..... - so this part of my PCB is now redundant.
However, all in all, some good fault finding, found the two issues, and I'm now going away to re-think my PCB trace widths and reading the datasheets more accurately
Thanks
Hi, this may be a long one, but I'm seriously at my whits end and could do with some guidance on how to progress fault finding.
I've designed a PCB that, whilst looks confusing, is simple enough. It consists of 4 Arduino Pro Minis - 3 of which have MAX485 circuits, plumbed in to an RS485 network (in and out), Off PCB there is a MySensors gateway in to Openhab Instance.
On the whole, everything works - there are over 14 'nodes', arduino pro minis dotted around the network which all communicate properly, including the other 2 working nodes on this PCB. And I do believe that the defective node (#12 - IO_MCU) is communicating correctly, but relays just simply do not pull in.
I'm an electrical Engineer by trade, I've got the relays working on the Alarm MCU, and the circuit is exactly the same for each.
I think my problem is with the configuration of the Arduino Sketch - maybe something to do with the Analogue pins, output type, or something
https://pastebin.com/RH2X8Ja9 - Arduino Sketch for the IO_MCU.
// Dimmer
Tags bracket the PWM controller output sections
// Button
Tags bracket the button input sections
// Relay
Tags bracket the relay output sections
When listening over serial to the node, I can see it is getting comms, presents all its IO - and even received on and off commands for relay children - however, no action on the PCB.
Similarly Openhab logs give all of the node 12s children as inbox things, I can tie them to items and command them on / off.
__ __ ____
| \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___
| |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
| | | | |_| |___| | __/ | | \__ \ _ | | \__ \
|_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/
|___/ 2.3.2
16 MCO:BGN:INIT NODE,CP=RSNNA---,FQ=16,REL=255,VER=2.3.2
26 MCO:BGN:BFR
28 TSM:INIT
29 TSF:WUR:MS=0
30 TSM:INIT:TSP OK
32 TSM:INIT:STATID=12
34 TSF:SID:OK,ID=12
36 TSM:FPAR
61 ?TSF:MSG:SEND,12-12-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
346 TSF:MSG:READ,0-0-12,s=255,c=3,t=8,pt=1,l=1,sg=0:0
351 TSF:MSG:FPAR OK,ID=0,D=1
2069 TSM:FPAR:OK
2070 TSM:ID
2071 TSM:ID:OK
2073 TSM:UPL
2092 TSF:MSG:SEND,12-12-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2121 TSF:MSG:READ,0-0-12,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2126 TSF:MSG:PONG RECV,HP=1
2129 TSM:UPL:OK
2130 TSM:READY:ID=12,PAR=0,DIS=1
2152 TSF:MSG:SEND,12-12-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2186 TSF:MSG:READ,0-0-12,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2213 TSF:MSG:SEND,12-12-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
2247 TSF:MSG:SEND,12-12-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
2284 TSF:MSG:READ,0-0-12,s=255,c=3,t=6,pt=0,l=1,sg=0:M
2306 TSF:MSG:SEND,12-12-0-0,s=1,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
2330 TSF:MSG:SEND,12-12-0-0,s=2,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
2355 TSF:MSG:SEND,12-12-0-0,s=3,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
2379 TSF:MSG:SEND,12-12-0-0,s=4,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
2404 TSF:MSG:SEND,12-12-0-0,s=5,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=OK:
2427 TSF:MSG:SEND,12-12-0-0,s=6,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=OK:
2464 TSF:MSG:SEND,12-12-0-0,s=7,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=OK:
2498 TSF:MSG:SEND,12-12-0-0,s=8,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=OK:
2521 TSF:MSG:SEND,12-12-0-0,s=9,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=OK:
2543 TSF:MSG:SEND,12-12-0-0,s=10,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=OK:
2584 TSF:MSG:SEND,12-12-0-0,s=11,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=OK:
2627 TSF:MSG:SEND,12-12-0-0,s=12,c=0,t=0,pt=0,l=0,sg=0,ft=0,st=OK:
2651 TSF:MSG:SEND,12-12-0-0,s=13,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
2690 TSF:MSG:SEND,12-12-0-0,s=14,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
2718 TSF:MSG:SEND,12-12-0-0,s=15,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
2749 TSF:MSG:SEND,12-12-0-0,s=16,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
2778 TSF:MSG:SEND,12-12-0-0,s=255,c=3,t=11,pt=0,l=4,sg=0,ft=0,st=OK:N012
2808 TSF:MSG:SEND,12-12-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
2814 MCO:REG:REQ
2845 TSF:MSG:SEND,12-12-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
2886 TSF:MSG:READ,0-0-12,s=255,c=3,t=27,pt=1,l=1,sg=0:1
2891 MCO:PIM:NODE REG=1
2893 MCO:BGN:STP
2912 TSF:MSG:SEND,12-12-0-0,s=1,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
2951 TSF:MSG:SEND,12-12-0-0,s=2,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
2991 TSF:MSG:SEND,12-12-0-0,s=3,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
3017 TSF:MSG:SEND,12-12-0-0,s=4,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
3023 MCO:BGN:INIT OK,TSP=1
3054 TSF:MSG:READ,0-0-12,s=3,c=1,t=3,pt=0,l=1,sg=0:0
3090 TSF:MSG:SEND,12-12-0-0,s=3,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
3119 TSF:MSG:SEND,12-12-0-0,s=3,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
3155 TSF:MSG:READ,0-0-12,s=4,c=1,t=3,pt=0,l=1,sg=0:0
3184 TSF:MSG:SEND,12-12-0-0,s=4,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
3227 TSF:MSG:SEND,12-12-0-0,s=4,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=OK:0
92765 TSF:MSG:READ,0-0-12,s=16,c=1,t=2,pt=0,l=1,sg=0:1
99421 TSF:MSG:READ,0-0-12,s=16,c=1,t=2,pt=0,l=1,sg=0:0
202292 TSF:MSG:READ,0-0-12,s=16,c=1,t=2,pt=0,l=1,sg=0:1
202394 TSF:MSG:READ,0-0-12,s=16,c=1,t=2,pt=0,l=1,sg=0:0
203639 TSF:MSG:READ,0-0-12,s=16,c=1,t=2,pt=0,l=1,sg=0:1
204679 TSF:MSG:READ,0-0-12,s=16,c=1,t=2,pt=0,l=1,sg=0:0
Any and all help is appreciated. I get that this is a big ask, I'm more than willing to give any more data that is required - testing, serial prints etc etc. Just struggling right now.
Appreciate your time.
Hi @nagelc , thanks for coming back to me - Apologies I didn't realise you'd replied nearer the time.
Am I right in thinking, so long as I define the new patterns function later on in the sketch - I can include it in the switch of function updateLightPattern, and it will be added to the mapping?
How do we know what definitive figures the 0 to 100 percentage map to in 0 to 15? Or is that basic arithmetic and each switch state will be called in each 'chunk'. I also only count 10 items in the switch state. Does that mean we can add 5 more? and if wanting more than 15 simply change our mapping size to have more?
Appreciate the help.
void updateLightPattern(){
// global: curPattern, updatePatternDelay, lastPatternUpdate
unsigned long now = millis() ;
if (now > lastPatternUpdate + updatePatternDelay){ // check if time for update
switch (curPattern) {
case pAlarm: // flash light
patternAlarm();
break ;
case pFire: // wild fire
patternFire();
break ;
case pFire2: // cosy fire
patternFire2();
break ;
case pCandle: // flame
patternCandle();
break ;
case pCircle: // flame
patternCircle();
break ;
case pRainbow: // rotating rainbow
patternRainbow();
break ;
case pSinelon: // rotating rainbow
patternSinelon();
break ;
case pSolid: // do nothing fall through
case pOff:
case pOn:
default : // def
break ;
}
lastPatternUpdate = now ;
}
}
Morning all, apologies for waking up an old thread, but it's pertinent to this chain of thought:
I'd like to build on this code and introduce a few more LED settings according to the percentage figure sent in the RGB dimmer.
Can anyone explain which part looks at the percentage and translates it out to the pattern?
How would I go about adding a new pattern to a chosen percentage value?
Many thanks
Adam
/*
PROJECT: MySensors / RGB light NEOPIXEL
PROGRAMMER: AWI
DATE: october 10, 2015/ last update: september 20, 2016
FILE: AWI_Wall_LIght_x.ino
LICENSE: Public domain
https://forum.mysensors.org/topic/4934/wall-mounted-mood-light-v2
Hardware: Nano and MySensors 2.0, Wall light 16 WS2812B leds (neopixel)
Special:
uses Fastled library with NeoPixel (great & fast RBG/HSV universal library) https://github.com/FastLED/FastLED
SUMMARY:
Different patterns and brightness settings
Button switches on/off and cycles through all Color patterns on long press
Remarks:
Fixed node-id
Change log:
20160915 - Updated to MySensors 2.0
20160920 - Changed state change to dimmer i.s.o. switch()
*/
/*
RGB Dimmer percentages = pattern
0 - 6 = Solid Colour
7 - 19 = Dim (think supposed to be off)
20 - 26 - Alarm (white and red light)
27 - 34 = Fire
35 - 46 = Fire2
47 - = one way Runner (set the colour first)
= Two way Runner (White)
You will be limited by RAM as to how many LEDs you can run
Using a Mega you can run 2000 LEDs
Arduino Nano = 2kb ram = 600 pixels
Arduino Uno = 2kb ram = 600 pixels
Arduino Mega = 8kb ram = 2400 pixels
*/
//**** MySensors *****
// Enable debug prints to serial monitor
#define MY_DEBUG
//#define MY_RADIO_NRF24 // Enable and select radio type attached
//#define MY_RF24_CHANNEL 80 // radio channel, default = 76
#define MY_RS485
#define MY_RS485_DE_PIN 2
#define MY_RS485_BAUD_RATE 9600
#define MY_NODE_ID 2
#define NODE_TXT "WS2812 N2" // Text to add to sensor name
// #define MY_RF24_CE_PIN 7 // Ceech board, 3.3v (7,8) (pin default 9,10)
// #define MY_RF24_CS_PIN 8
// helpers
#define LOCAL_DEBUG // enable if print wanted
#ifdef LOCAL_DEBUG
#define Sprint(a) (Serial.print(a)) // macro as substitute for print, enable if no print wanted
#define Sprintln(a) (Serial.println(a)) // macro as substitute for println
#else
#define Sprint(a)
#define Sprintln(a)
#endif
#include <SPI.h> // My Sensors
#include <MySensors.h>
#include <FastLED.h> // https://github.com/FastLED/FastLED
#include "JC_Button.h" // https://github.com/JChristensen/Button
const int stripPin = 4 ; // pin where 2812 LED strip is connected
const int buttonPin = 5 ; // push button
const int numPixel = 156 ; // set to number of pixels (x top / y bottom)
const int RGB_LightChild = 0 ; // Child Id's, standard light child on/off/ dim
const int RGB_RGBChild = 1 ; // RGB light child (on/off/dim/color, if controller supports V_RBG))
const int RGB_SolidColorChild = 2 ; // when set, node reads Color text from ColorTextChild
const int RGB_TextColorChild = 3 ; // Holds Text value for color (custom colors from controller)
const int RGB_AlarmPatternChild = 4 ; // Switches to alarm status
const int RGB_NextPatternChild = 5 ; // Move to next pattern when set
CRGB leds[numPixel];
// Kelving colors: Light & daylight (in Fastled reference only)
/// 1900 Kelvin Candle=0xFF9329 /* 1900 K, 255, 147, 41 */,
/// 2600 Kelvin Tungsten40W=0xFFC58F /* 2600 K, 255, 197, 143 */,
/// 2850 Kelvin Tungsten100W=0xFFD6AA /* 2850 K, 255, 214, 170 */,
/// 3200 Kelvin Halogen=0xFFF1E0 /* 3200 K, 255, 241, 224 */,
/// 5200 Kelvin CarbonArc=0xFFFAF4 /* 5200 K, 255, 250, 244 */,
/// 5400 Kelvin HighNoonSun=0xFFFFFB /* 5400 K, 255, 255, 251 */,
/// 6000 Kelvin DirectSunlight=0xFFFFFF /* 6000 K, 255, 255, 255 */,
/// 7000 Kelvin OvercastSky=0xC9E2FF /* 7000 K, 201, 226, 255 */,
/// 20000 Kelvin ClearBlueSky=0x409CFF /* 20000 K, 64, 156, 255 */
char setRGBvalue[] = "FFC58F"; // Controller sent RGB value, default tungsten40W
uint16_t curBrightness = 0x7F, setBrightness = 0x7F ; // Brightness globals (actualBrightness)
unsigned long updateBrightnessDelay, lastBrightnessUpdate ; // Brightness timers
int RGBonoff ; // OnOff flag
enum { pSolid, pOff, pOn, pAlarm, pFire, pFire2, pCandle, pCircle, pSinelon, pRainbow} ; // Pattern states (stored in int for convenience)
const int lastPatternIdx = pRainbow + 1 ; // use last pattern for patterncount
int curPattern = pSolid ; // current pattern
int setPattern = pSolid ; // set pattern (controller)
unsigned long updatePatternDelay, lastPatternUpdate ; // Pattern timers
unsigned long idleTimer = millis() ; // return to idle timer
const unsigned long idleTime = 10000UL; // return to idle after 10 secs
const unsigned long dimTime = 1000UL; // dim period
const unsigned long heartbeatInterval = 1 * 60UL * 1000UL ; // heartbeatinterval, just to let the controller know I am alive
unsigned long heartbeatCounter = 0 ;
MyMessage lightRGBMsg(RGB_LightChild, V_RGB); // standard messages, light
MyMessage lightdimmerMsG(RGB_LightChild ,V_DIMMER);
MyMessage lightOnOffMessage(RGB_LightChild, V_STATUS);
Button myBtn(buttonPin, true, true, 20); //Declare the button (pin, pull_up, invert, debounce_ms)
// Simple state machine for button state
enum {sIdle, sBrightness, sPattern} ; // simple state machine for button press
int State ;
void setup() {
FastLED.addLeds<WS2812B, stripPin, RGB >(leds, numPixel); // initialize led strip (NEOPIXEL =WS...)
for(int i = 0 ; i < 6 ; i++) { // get color value from EEPROM (6 char)
setRGBvalue[i] = loadState(i) ;
}
setLightPattern(pSolid, 0) ; // default controller Solid
FastLED.show();
State = sIdle ; // Initial state
//randomSeed(analogRead(0));
}
void presentation(){
// MySensors
sendSketchInfo("AWI RGB Wall " NODE_TXT, "2.0");
present(RGB_RGBChild, S_RGB_LIGHT, "RGB Wall RGB " NODE_TXT);// present to controller
present(RGB_LightChild, S_LIGHT, "RGB Wall Light " NODE_TXT);
present(RGB_SolidColorChild, S_LIGHT, "RGB Set Solid color (text) " NODE_TXT);
present(RGB_TextColorChild, S_INFO, "RGB Wall textcolor " NODE_TXT);
present(RGB_AlarmPatternChild, S_BINARY, "RGB Wall Alarm " NODE_TXT);
present(RGB_NextPatternChild, S_DIMMER, "RGB Wall Pattern " NODE_TXT);
}
// read button and act accordingly
// short press: on/off
// longer press: set patterns with following short press
// long press: set brightness increase
void loop() {
myBtn.read(); //Read the button (only read)
unsigned long now = millis(); // loop timer reference
switch (State) {
case sIdle: // default state, browse through patterns
if (myBtn.wasReleased()){ // light on/ off in idle
RGBonoff = !RGBonoff ; // invert light state
setLightBrightness((RGBonoff == 1)?setBrightness:0, dimTime);
send(lightOnOffMessage.set(RGBonoff)); // and update controller
} else if (myBtn.pressedFor(800)){ // move to Pattern update state with long press
idleTimer = now ; // return to idle after ...
State = sPattern ;
}
break ;
case sPattern: // entered after long press
if (myBtn.pressedFor(4000)){ // when press even longer move to Brightness update
State = sBrightness ;
} else if (myBtn.wasPressed()){
setPattern = (setPattern + 1) % lastPatternIdx ; // increase pattern and wrap
setLightPattern((setPattern), 500 );
idleTimer = now ;
} else if ( now > idleTime + idleTimer ){ // return to idle after ...
State = sIdle ;
}
break ;
case sBrightness: // entered after looong press
if (myBtn.wasPressed()){ // if pressed again increase brightness
setLightBrightness((curBrightness+0x1F) % 0xFF, 0) ; // increase brightness and wrap (0..0xFF)
idleTimer = now ;
} else if ( now > idleTime + idleTimer ){ // return to idle after ...
State = sIdle ;
}
break ;
default :
State = sIdle ;
break ;
}
updateLightBrightness(); // update Brightness if time
updateLightPattern(); // update Pattern if time
if ( now > heartbeatCounter + heartbeatInterval){ // heartbeat every hour
sendHeartbeat();
heartbeatCounter = now ;
}
}
// Sets the light brightness, takes value and time (ms) as input
void setLightBrightness(int newBrightness, unsigned long updateTime){
// global: curBrightness, actualBrightness, updateBrightnessDelay
updateBrightnessDelay = updateTime / 0xFF ; // delay = time / max steps
curBrightness = newBrightness ; // set curBrightness to new value, rest is done in update
}
// Update the light brightness if time
void updateLightBrightness(){
// global: curBrightness, actualBrightness, updateBrightnessDelay, lastBrightnessUpdate ;
static byte actualBrightness ; // store real brightness state for slow dim
unsigned long now = millis() ;
if (now > lastBrightnessUpdate + updateBrightnessDelay){// check if time for update
if ( actualBrightness > curBrightness) {
FastLED.setBrightness( --actualBrightness );
FastLED.show();
} else if ( actualBrightness < curBrightness){
FastLED.setBrightness( ++actualBrightness );
FastLED.show();
}
lastBrightnessUpdate = now ;
}
}
// **** Pattern routines *****
// Sets and initializes the light pattern if nescessary
void setLightPattern( int newPattern, unsigned long updateDelay){
// global: curPattern, updatePatternDelay
static int lastPattern = pSolid ; // last pattern for pOn / pOff virtual patterns
if (newPattern == pOff) lastPattern = curPattern ; // remember last pattern
if (newPattern == pOn) curPattern = lastPattern ; // only for pOn switch to last pattern
else curPattern = newPattern ;
updatePatternDelay = updateDelay ; // delay for next pattern update, can be changed in pattern
switch(curPattern){
case pSolid: // solid is set value in all pixels (and on)
for(int i = 0 ; i < numPixel ; i++) leds[i] = strtol( setRGBvalue, NULL, 16);
setLightBrightness(setBrightness, dimTime) ; // slow dim to on
FastLED.show();
break ;
case pOn: // On is set Brightness in all pixels
setLightBrightness(setBrightness, dimTime) ; // slow dim to on
FastLED.show();
break ;
case pOff: // off state all pixels off (add dim and pOn)
setLightBrightness(0, dimTime) ; // slow dim to off
FastLED.show();
break ;
case pCircle: // all pixels off
for(int i = 0 ; i < numPixel ; i++) leds[i] = 0 ;
for(int i = 0 ; i < 2 ; i++){
leds[i] = strtol( setRGBvalue, NULL, 16) ; // 1 pixel on
}
FastLED.show();
break ;
default :
setLightBrightness(setBrightness, dimTime) ; // slow dim to on
FastLED.show();
break ;
}
}
// Update the light pattern when time for it
void updateLightPattern(){
// global: curPattern, updatePatternDelay, lastPatternUpdate
unsigned long now = millis() ;
if (now > lastPatternUpdate + updatePatternDelay){ // check if time for update
switch (curPattern) {
case pAlarm: // flash light
patternAlarm();
break ;
case pFire: // wild fire
patternFire();
break ;
case pFire2: // cosy fire
patternFire2();
break ;
case pCandle: // flame
patternCandle();
break ;
case pCircle: // flame
patternCircle();
break ;
case pRainbow: // rotating rainbow
patternRainbow();
break ;
case pSinelon: // rotating rainbow
patternSinelon();
break ;
case pSolid: // do nothing fall through
case pOff:
case pOn:
default : // def
break ;
}
lastPatternUpdate = now ;
}
}
// Define the different patterns
// Alarm - intermittent white and red color, full intensity, intermittent top & bottom half
void patternAlarm() {
static boolean topBot ; // indicates direction for next entry
const CRGB colorTop = CRGB(0xFF, 0, 0 ); // red color
const CRGB colorBottom = CRGB(0xFF, 0xFF, 0xFF ); // white color
FastLED.setBrightness(0xFF); // set the strip brightness to max for Alarm
for(int i=0; i <= (numPixel / 2 - 1) ; i++) { // for half of strip size
leds[i] = topBot?colorTop:colorBottom ;
leds[i+ (numPixel/2)] = topBot?colorBottom:colorTop ;
}
topBot = !topBot ; // switch direction
FastLED.show();
}
// Simulate fire with red color, varying number of leds intensity & tempo
void patternFire() {
byte numberLeds = random(0,numPixel); // start number and end of led's for flickering
int lum = ((random(100,255) * curBrightness)) / 0xFF ; // set brightness and scale
CRGB color = CRGB(200, random(70,230),0 ); // get red color with varying green
for(int i=0; i <= numberLeds; i++) {
leds[i] = color ;
FastLED.setBrightness(lum); // set the strip brightness
FastLED.show();
wait(random(0,10)); // (blocking, need to be changed)
}
updatePatternDelay = 100 ;
}
// Simulate fire with red color and varying intensity & tempo
void patternFire2() {
CRGB color = CRGB(200, random(100,150),0); // get red color with varying green
for (byte p=0; p < numPixel; p++) {
leds[p] = color;
}
FastLED.setBrightness((random(50,255) * curBrightness)/ 0xFF ); // set Brightness and scale
FastLED.show();
updatePatternDelay = random(20,300); // variable delay
}
// Simulate candle based on fire with red color, varying number of leds intensity & tempo
void patternCandle() {
byte numberLeds = random(0,numPixel); // start number and end of led's for flickering
byte lum = ((random(100, 255) * curBrightness)/ 0xFF); // set brightness
CRGB color = CRGB(200, random(90,130),0 ); // get red color with varying green
for(int i=0; i <= numberLeds; i++) {
leds[i] = color ;
FastLED.setBrightness(lum); // set the strip brightness
FastLED.show();
wait(random(5,10)); // (blocking, need to be changed)
}
updatePatternDelay = 100 ;
}
// a colored dot sweeping back and forth, with fading trails, adapted from Fastled sinelon
void patternSinelon()
{
fadeToBlackBy( leds, numPixel, 10); // fade all leds a small amount
int pos = beatsin8(25,0,numPixel); // get a new position for the led (BPM = 13, min, max, )
leds[pos] += strtol( setRGBvalue, NULL, 16);
FastLED.show();
updatePatternDelay = 2 ;
}
// Rotate all Leds with current content and trail
void patternCircle() {
static int currentLed ; // indicated current led to light
// CRGB tempLed = leds[0]; // temporary variable for color
fadeToBlackBy( leds, numPixel, 128); // fade all leds for trail..
leds[currentLed] = strtol( setRGBvalue, NULL, 16); // set to current color
currentLed = (currentLed + 1) % numPixel ; // wrap
FastLED.show();
updatePatternDelay = 100 ;
}
void patternRainbow() {
static uint16_t hue ; // starting color
FastLED.clear();
// for(hue=10; hue<255*3; hue++) {
hue = (hue+1) % 0xFF ; // incerease hue and wrap
fill_rainbow( leds, numPixel , hue /*static hue value */, 1);// set a rainbow from hue to last in stepsize 1
FastLED.show();
updatePatternDelay = 100 ;
}
// Incoming messages from MySensors
void receive(const MyMessage &message) {
int ID = message.sensor;
Serial.print("Sensor: ");
Serial.println(ID);
switch (ID){
case RGB_LightChild: // same behaviour as RGB child/ fall through
case RGB_RGBChild: // if controller can handle V_RGB
if (message.type == V_RGB) { // check for RGB type
strcpy(setRGBvalue, message.getString()); // get the payload
setLightPattern(pSolid, 0); // and set solid pattern
} else if (message.type == V_DIMMER) { // if DIMMER type, adjust brightness
setBrightness = map(message.getInt(), 0, 100, 0, 255);
setLightBrightness(setBrightness, dimTime) ;
} else if (message.type == V_STATUS) { // if on/off type, toggle brightness
RGBonoff = message.getInt();
setLightBrightness((RGBonoff == 1)?setBrightness:0, dimTime);
}
break ;
case RGB_SolidColorChild: // request color from controller
if (message.type == V_STATUS) { // if get color from text child
request(RGB_TextColorChild, V_TEXT);
setLightPattern(pSolid, 0); // and set solid pattern (if not alre)
}
break ;
case RGB_TextColorChild: // Text color from controller
if (message.type == V_TEXT) { // if get color from text child
strcpy(setRGBvalue, message.getString()); // get the payload
for(int i = 0 ; i < 6 ; i++) { // save color value to EEPROM (6 char)
saveState(i, setRGBvalue[i]) ;} // Save to EEPROM
}
break ;
case RGB_AlarmPatternChild: // set Alarm pattern
if (message.type == V_STATUS) { // if get color from text child
if (message.getInt() == 1){
setLightPattern(pAlarm, 500); // set slow alarm pattern
} else {
setLightPattern(setPattern, 0); // and reset pattern
FastLED.setBrightness(setBrightness);
}
}
break ;
case RGB_NextPatternChild: // next pattern
if (message.type == V_PERCENTAGE) { // Percentage indicates the pattern
setPattern = map(message.getInt(), 0, 100, 0, 15) % lastPatternIdx ; // mapper dimmer value to state 0..9 and wrap
setLightPattern((setPattern), 500 );
Sprint("Pattern: ") ; Sprintln(setPattern) ;
} else if (message.type == V_STATUS){ // if off switch pattern to default == 0
setPattern = 0 ;
setLightPattern((setPattern), 500 );
Sprint("Pattern: ") ; Sprintln(setPattern) ;
}
break ;
}
FastLED.show();
dispRGBstat();
}
// debug
// display the status of all RGB: controller, requested, real
void dispRGBstat(void){
Serial.print(" Color: "); Serial.print(setRGBvalue);
Serial.print(" Brightness: "); Serial.println(setBrightness);
}
@BearWithBeard said in Relay Actuator with momentary (pulse) action:
digitalWrite(relayPin[message.getSensor()-7], RELAY_ON)
Many thanks for coming back @BearWithBeard, its a huge help.
So my logic for correcting the State problem at the bottom would be to do the same calculation to get them in to 0 and 1.
saveState(message.getSensor()-7, message.getBool());
Compiled correctly and then uploaded and it works! Fantastic. The following sketch has 3 dimmers, 4 buttons and 2 relay outputs.
Thank you very much - I'm learning
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - February 15, 2014 - Bruce Lacey
* Version 1.1 - August 13, 2014 - Converted to 1.4 (hek)
*
* DESCRIPTION
* This sketch provides a Dimmable LED Light using PWM and based Henrik Ekblad
* <henrik.ekblad@gmail.com> Vera Arduino Sensor project.
* Developed by Bruce Lacey, inspired by Hek's MySensor's example sketches.
*
* The circuit uses a MOSFET for Pulse-Wave-Modulation to dim the attached LED or LED strip.
* The MOSFET Gate pin is connected to Arduino pin 3 (LED_PIN), the MOSFET Drain pin is connected
* to the LED negative terminal and the MOSFET Source pin is connected to ground.
*
*/
// Button
// The below includes 4 buttons using code examples from here: https://forum.mysensors.org/topic/9538/multiple-switch-inputs/8
// Button
// Relay
// The below includes 2 relays from https://www.mysensors.org/build/relay
// https://forum.mysensors.org/topic/5906/relay-actuator-with-momentary-pulse-action/2
// Relay
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
//#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
// Enable RS485 transport layer
#define MY_RS485
// Define this to enables DE-pin management on defined pin
#define MY_RS485_DE_PIN 2
// Set RS485 baud rate to use
#define MY_RS485_BAUD_RATE 9600
#define MY_NODE_ID 4
#include <SPI.h>
#include <MySensors.h>
// Button
#include <Bounce2.h>
//
#define SN "N004"
#define SV "1.0"
#define noLEDs 2
const int LED_Pin[] = {5, 6};
#define FADE_DELAY 10 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
static int currentLevel1 = 0; // Current dim level...
static int currentLevel2 = 0; // Current dim level...
MyMessage dimmer1Msg(1, V_DIMMER);
MyMessage light1Msg(1, V_LIGHT);
MyMessage dimmer2Msg(2, V_DIMMER);
MyMessage light2Msg(2, V_LIGHT);
// Button
#define FIRST_BUTTON_ID 3
#define MAX_BUTTON 4
const uint8_t buttonPin[] = {4, 10, 11, 12}; // switch around pins to your desire
Bounce debouncer[MAX_BUTTON];
MyMessage buttonMsg(0, V_TRIPPED);
bool oldButton[MAX_BUTTON] = {false};
// Button
// Relay
#define FIRST_RELAY_ID 7
#define MAX_RELAY 2
const uint8_t relayPin[] = {3, 7}; // Pins of relays
MyMessage relayMsg(0, V_STATUS);
#define RELAY_ON 1
#define RELAY_OFF 0
// Relay
void before()
{
}
/***
* Dimmable LED initialization method
*/
void setup()
{
// LEDS
// 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 );
}
// Button
for (uint8_t i = 0; i < MAX_BUTTON; i++) {
debouncer[i] = Bounce(); // initialize debouncer
debouncer[i].attach(buttonPin[i], INPUT_PULLUP);
debouncer[i].interval(5);
oldButton[i] = debouncer[i].read();
}
// Button
// Relay
for (uint8_t i = 0; i < MAX_RELAY; i++) {
pinMode(relayPin[i], OUTPUT);
//digitalWrite(relayPin, loadState(i)?RELAY_ON:RELAY_OFF);
if (loadState(i) == RELAY_ON) {
digitalWrite(relayPin, RELAY_ON);
wait(500);
digitalWrite(relayPin, RELAY_OFF);
}
}
// Relay
}
void presentation() {
// Register the LED Dimmable Light with the gateway
for (int sensor=1; sensor<=noLEDs; sensor++){
present(sensor, S_DIMMER);
wait(2);
}
// Button
for (int i = 0; i < MAX_BUTTON; i++) { //i < numSensors &&
present(FIRST_BUTTON_ID + i, S_DOOR);
}
// Button
// Relay
for (int i = 0; i < MAX_RELAY; i++) {
present(FIRST_RELAY_ID + i, S_BINARY);
}
// Relay
sendSketchInfo(SN, SV);
}
/***
* Dimmable LED main processing loop
*/
void loop()
{
// Button
bool button[MAX_BUTTON];
for (uint8_t i = 0; i < MAX_BUTTON; i++) {
debouncer[i].update();
button[i] = debouncer[i].read();
if (button[i] != oldButton[i]) {
send(buttonMsg.setSensor(FIRST_BUTTON_ID + i).set( button[i])); // Send tripped value to gw
oldButton[i] = button[i];
}
}
// Button
}
void receive(const MyMessage &message) {
if (message.type == V_LIGHT || message.type == V_DIMMER) {
if (message.sensor == 1) {
// Retrieve the power or dim level from the incoming request message
int requestedLevel1 = atoi( message.data );
// Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
requestedLevel1 *= ( message.type == V_LIGHT ? 100 : 1 );
// Clip incoming level to valid range of 0 to 100
requestedLevel1 = requestedLevel1 > 100 ? 100 : requestedLevel1;
requestedLevel1 = requestedLevel1 < 0 ? 0 : requestedLevel1;
fadeToLevel1( requestedLevel1, message.sensor );
send(light1Msg.set(currentLevel1 > 0 ? 1 : 0));
send(dimmer1Msg.set(currentLevel1) );}
if (message.sensor == 2) {
// Retrieve the power or dim level from the incoming request message
int requestedLevel2 = atoi( message.data );
// Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
requestedLevel2 *= ( message.type == V_LIGHT ? 100 : 1 );
// Clip incoming level to valid range of 0 to 100
requestedLevel2 = requestedLevel2 > 100 ? 100 : requestedLevel2;
requestedLevel2 = requestedLevel2 < 0 ? 0 : requestedLevel2;
fadeToLevel2( requestedLevel2, message.sensor );
send(light2Msg.set(currentLevel2 > 0 ? 1 : 0));
send(dimmer2Msg.set(currentLevel2) );}
}
// Relay
if (message.type == V_STATUS) {
if (message.sensor == 7) {
if (message.getBool() == RELAY_ON) {
//digitalWrite(message.getSensor()-1+relayPin, RELAY_ON);
digitalWrite(relayPin[message.getSensor()-7], RELAY_ON);
wait(500);
//digitalWrite(message.getSensor()-1+relayPin, RELAY_OFF);
digitalWrite(relayPin[message.getSensor()-7], RELAY_OFF);
}
saveState(message.getSensor()-7, message.getBool());
}
if (message.sensor == 8) {
if (message.getBool() == RELAY_ON) {
//digitalWrite(message.getSensor()-1+relayPin, RELAY_ON);
digitalWrite(relayPin[message.getSensor()-7], RELAY_ON);
wait(500);
//digitalWrite(message.getSensor()-1+relayPin, RELAY_OFF);
digitalWrite(relayPin[message.getSensor()-7], RELAY_OFF);
}
saveState(message.getSensor()-7, message.getBool());
}
}
// Relay
}
/***
* This method provides a graceful fade up/down effect
*/
void fadeToLevel1( int toLevel1, int ledid1 ) {
int delta1 = ( toLevel1 - currentLevel1 ) < 0 ? -1 : 1;
while ( currentLevel1 != toLevel1 ) {
currentLevel1 += delta1;
analogWrite(LED_Pin[ledid1-1], (int)(currentLevel1 / 100. * 255) );
wait( FADE_DELAY );
}
}
void fadeToLevel2( int toLevel2, int ledid2 ) {
int delta2 = ( toLevel2 - currentLevel2 ) < 0 ? -1 : 1;
while ( currentLevel2 != toLevel2 ) {
currentLevel2 += delta2;
analogWrite(LED_Pin[ledid2-1], (int)(currentLevel2 / 100. * 255) );
wait( FADE_DELAY );
}
}
Morning all,
I'm smashing together 3 types of sketches here (3 x Dimmer, 4 x Button, 2 x relay) and am struggling with this 'momentary' relay action. The relays do not fire at all.
Everything is presented to the controller (Openhab) via an RS485 gateway, and the dimmer and buttons work and feedback their states. The log output shows that this device is receiving a 0 and 1 from Openhab on its relay nodes (7 and however, still no actuation.
I wonder if someone was able to take a cursery glance at my code. The relay sections of code are bracketed with // Relay
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - February 15, 2014 - Bruce Lacey
* Version 1.1 - August 13, 2014 - Converted to 1.4 (hek)
*
* DESCRIPTION
* This sketch provides a Dimmable LED Light using PWM and based Henrik Ekblad
* <henrik.ekblad@gmail.com> Vera Arduino Sensor project.
* Developed by Bruce Lacey, inspired by Hek's MySensor's example sketches.
*
* The circuit uses a MOSFET for Pulse-Wave-Modulation to dim the attached LED or LED strip.
* The MOSFET Gate pin is connected to Arduino pin 3 (LED_PIN), the MOSFET Drain pin is connected
* to the LED negative terminal and the MOSFET Source pin is connected to ground.
*
*/
// Button
// The below includes 4 buttons using code examples from here: https://forum.mysensors.org/topic/9538/multiple-switch-inputs/8
// Button
// Relay
// The below includes 2 relays from https://www.mysensors.org/build/relay
// https://forum.mysensors.org/topic/5906/relay-actuator-with-momentary-pulse-action/2
// Relay
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
//#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
// Enable RS485 transport layer
#define MY_RS485
// Define this to enables DE-pin management on defined pin
#define MY_RS485_DE_PIN 2
// Set RS485 baud rate to use
#define MY_RS485_BAUD_RATE 9600
#define MY_NODE_ID 4
#include <SPI.h>
#include <MySensors.h>
// Button
#include <Bounce2.h>
//
#define SN "N004"
#define SV "1.0"
#define noLEDs 2
const int LED_Pin[] = {5, 6};
#define FADE_DELAY 10 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
static int currentLevel1 = 0; // Current dim level...
static int currentLevel2 = 0; // Current dim level...
MyMessage dimmer1Msg(1, V_DIMMER);
MyMessage light1Msg(1, V_LIGHT);
MyMessage dimmer2Msg(2, V_DIMMER);
MyMessage light2Msg(2, V_LIGHT);
// Button
#define FIRST_BUTTON_ID 3
#define MAX_BUTTON 4
const uint8_t buttonPin[] = {4, 10, 11, 12}; // switch around pins to your desire
Bounce debouncer[MAX_BUTTON];
MyMessage buttonMsg(0, V_TRIPPED);
bool oldButton[MAX_BUTTON] = {false};
// Button
// Relay
#define FIRST_RELAY_ID 7
#define MAX_RELAY 2
const uint8_t relayPin[] = {3, 7}; // Pins of relays
MyMessage relayMsg(0, V_STATUS);
#define RELAY_ON 1
#define RELAY_OFF 0
// Relay
void before()
{
}
/***
* Dimmable LED initialization method
*/
void setup()
{
// LEDS
// 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 );
}
// Button
for (uint8_t i = 0; i < MAX_BUTTON; i++) {
debouncer[i] = Bounce(); // initialize debouncer
debouncer[i].attach(buttonPin[i], INPUT_PULLUP);
debouncer[i].interval(5);
oldButton[i] = debouncer[i].read();
}
// Button
// Relay
for (uint8_t i = 0; i < MAX_RELAY; i++) {
pinMode(relayPin[i], OUTPUT);
//digitalWrite(relayPin, loadState(i)?RELAY_ON:RELAY_OFF);
if (loadState(i) == RELAY_ON) {
digitalWrite(relayPin, RELAY_ON);
wait(500);
digitalWrite(relayPin, RELAY_OFF);
}
}
// Relay
}
void presentation() {
// Register the LED Dimmable Light with the gateway
for (int sensor=1; sensor<=noLEDs; sensor++){
present(sensor, S_DIMMER);
wait(2);
}
// Button
for (int i = 0; i < MAX_BUTTON; i++) { //i < numSensors &&
present(FIRST_BUTTON_ID + i, S_DOOR);
}
// Button
// Relay
for (int i = 0; i < MAX_RELAY; i++) {
present(FIRST_RELAY_ID + i, S_BINARY);
}
// Relay
sendSketchInfo(SN, SV);
}
/***
* Dimmable LED main processing loop
*/
void loop()
{
// Button
bool button[MAX_BUTTON];
for (uint8_t i = 0; i < MAX_BUTTON; i++) {
debouncer[i].update();
button[i] = debouncer[i].read();
if (button[i] != oldButton[i]) {
send(buttonMsg.setSensor(FIRST_BUTTON_ID + i).set( button[i])); // Send tripped value to gw
oldButton[i] = button[i];
}
}
// Button
}
void receive(const MyMessage &message) {
if (message.type == V_LIGHT || message.type == V_DIMMER) {
if (message.sensor == 1) {
// Retrieve the power or dim level from the incoming request message
int requestedLevel1 = atoi( message.data );
// Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
requestedLevel1 *= ( message.type == V_LIGHT ? 100 : 1 );
// Clip incoming level to valid range of 0 to 100
requestedLevel1 = requestedLevel1 > 100 ? 100 : requestedLevel1;
requestedLevel1 = requestedLevel1 < 0 ? 0 : requestedLevel1;
fadeToLevel1( requestedLevel1, message.sensor );
send(light1Msg.set(currentLevel1 > 0 ? 1 : 0));
send(dimmer1Msg.set(currentLevel1) );}
if (message.sensor == 2) {
// Retrieve the power or dim level from the incoming request message
int requestedLevel2 = atoi( message.data );
// Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
requestedLevel2 *= ( message.type == V_LIGHT ? 100 : 1 );
// Clip incoming level to valid range of 0 to 100
requestedLevel2 = requestedLevel2 > 100 ? 100 : requestedLevel2;
requestedLevel2 = requestedLevel2 < 0 ? 0 : requestedLevel2;
fadeToLevel2( requestedLevel2, message.sensor );
send(light2Msg.set(currentLevel2 > 0 ? 1 : 0));
send(dimmer2Msg.set(currentLevel2) );}
}
// Relay
if (message.type == V_STATUS) {
if (message.sensor == 7) {
if (message.getBool() == RELAY_ON) {
digitalWrite(message.getSensor()-1+relayPin, RELAY_ON);
wait(500);
digitalWrite(message.getSensor()-1+relayPin, RELAY_OFF);
}
saveState(message.sensor, message.getBool());
}
if (message.sensor == 8) {
if (message.getBool() == RELAY_ON) {
digitalWrite(message.getSensor()-1+relayPin, RELAY_ON);
wait(500);
digitalWrite(message.getSensor()-1+relayPin, RELAY_OFF);
}
}
}
// Relay
}
/***
* This method provides a graceful fade up/down effect
*/
void fadeToLevel1( int toLevel1, int ledid1 ) {
int delta1 = ( toLevel1 - currentLevel1 ) < 0 ? -1 : 1;
while ( currentLevel1 != toLevel1 ) {
currentLevel1 += delta1;
analogWrite(LED_Pin[ledid1-1], (int)(currentLevel1 / 100. * 255) );
wait( FADE_DELAY );
}
}
void fadeToLevel2( int toLevel2, int ledid2 ) {
int delta2 = ( toLevel2 - currentLevel2 ) < 0 ? -1 : 1;
while ( currentLevel2 != toLevel2 ) {
currentLevel2 += delta2;
analogWrite(LED_Pin[ledid2-1], (int)(currentLevel2 / 100. * 255) );
wait( FADE_DELAY );
}
}
Hello all, many thanks to @AWI for this great sketch - it performs very well and is my 'go to' for a WS28XX interface with Mysensors and Openhab.
I am however, starting to experience problems introduced with the FastLED 'wait' commands and the radio receiving a command - essentially, if I command the node to a pattern that is particularly blocking - I cant them command it to off, solid colour or another pattern.
Anyone solved this problem - or able to point me in the direction of solving. I'd be happy to refresh the sketch and re-share.
Does this need a resistor between the Arduino digital pin and the Gate of the MOSFET? To limit current draw?
No way - found it. Large comment at the top of sketch (not copied to this forum) had a line of *********s across the top.
Removed and all ok. Thanks for your help anyway @mfalkvidd
@mfalkvidd I had it running on a nano.
Now trying to put it in a mini pro.
However, cant get it to compile on either or an uno.
I'll re-install the IDE now and report back
@mfalkvidd just removed from the operating directory and installed via the Library Manager in the IDE - still same error.
Interestingly my RS485 Gateway sketch (Using the same library) compiles fine!
RS485GW (compiles fine)
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable RS485 transport layer
#define MY_RS485
// Define this to enables DE-pin management on defined pin
#define MY_RS485_DE_PIN 2
// Set RS485 baud rate to use
#define MY_RS485_BAUD_RATE 9600
// Enable this if RS485 is connected to a hardware serial port
//#define MY_RS485_HWSERIAL Serial1
// Enable serial gateway
#define MY_GATEWAY_SERIAL
// Enable inclusion mode
//#define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
//#define MY_INCLUSION_BUTTON_FEATURE
// Set inclusion mode duration (in seconds)
//#define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
//#define MY_INCLUSION_MODE_BUTTON_PIN 3
// Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300
// Flash leds on rx/tx/err
#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
#define MY_DEFAULT_RX_LED_PIN 5 // Receive led pin
#define MY_DEFAULT_TX_LED_PIN 6 // the PCB, on board LED
#include <MySensors.h>
void setup()
{
// Setup locally attached sensors
}
void presentation()
{
// Present locally attached sensors
}
void loop()
{
// Send locally attached sensor data here
}
RS485_WS2812_actuator (does not compile)
// Enable debug prints to serial monitor
#define MY_DEBUG
// Activate one of these
//#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
#define MY_RS485
#define MY_RS485_DE_PIN 2
// Set RS485 baud rate to use
#define MY_RS485_BAUD_RATE 9600
#include <MySensors.h>
#include <SPI.h>
#include <Adafruit_NeoPixel.h>
#define NUMPIXELS 58 // FIXME Number of connected pixels on a single datapin - Must be less than 500 due to RAM issues
#define PIN 4 // Digital output pin
#define MY_NODE_ID 1 // FIXME this needs to be decided and updated for this exact WS2812 node
#define CHILD_ID 0
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
long RGB_values[3] = {0,0,0};
void presentation()
{
sendSketchInfo("RS485_WS2812_Actuator", "1.0");
present(CHILD_ID, S_RGB_LIGHT);
}
void setup()
{
Serial.begin(9600);
Serial.println("Starting");
strip.begin();
strip.show(); // Update the strip, to start they are all 'off'
}
void loop()
{
}
void receive(const MyMessage &message) {
if (message.type==V_RGB) {
// starting to process the hex code
String hexstring = message.getString(); //here goes the hex color code coming from through MySensors (like FF9A00)
long number = (long) strtol( &hexstring[0], NULL, 16);
RGB_values[0] = number >> 16;
RGB_values[1] = number >> 8 & 0xFF;
RGB_values[2] = number & 0xFF;
colorWipe(Color(RGB_values[0],RGB_values[1],RGB_values[2]), 30);
}
if (message.type==V_DIMMER) {
strip.setBrightness(round((2.55*message.getInt())));
strip.show();
}
if (message.type==V_LIGHT) {
if (message.getInt() == 0) {
strip.clear();
strip.show();
}
}
}
void colorWipe(uint32_t c, uint8_t wait) {
int i;
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
/* Helper functions */
// Create a 15 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
uint32_t c;
c = r;
c <<= 8;
c |= g;
c <<= 8;
c |= b;
return c;
}
Good morning @mfalkvidd
I've not made amendements, I've tried to upload here, however received an error message with a 100% uploading. The library is 2.3.2 downlaoded from github.
[0_1608024751465_MyConfig.h](Uploading 100%)
@mfalkvidd many thanks for coming back. I think I'll keep more complex things seperate, however will explore multiple binary sensors and relays on the same node.
Thanks
Hi, So I had this 'WS2812 actuator' sketch running on a Nano with a nrf24 radio and I'm not converting it to run in a rs485 network. However I encounter the following when I try and compile it. I've uninstalled and re-installed the library, both via the IDE and directly downloading from github - to no avail
Arduino: 1.8.13 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\z003rtbs\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\z003rtbs\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\UserData\z003rtbs\OneDrive - Siemens AG\Documents\Arduino\libraries -fqbn=arduino:avr:pro:cpu=16MHzatmega328 -ide-version=10813 -build-path C:\Users\z003rtbs\AppData\Local\Temp\arduino_build_449327 -warnings=none -build-cache C:\Users\z003rtbs\AppData\Local\Temp\arduino_cache_80315 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avrdude.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\z003rtbs\Nextcloud\Projects\Van\OpenHab\MySensors\RS485_WS2812_Actuator\RS485_WS2812_Actuator.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\z003rtbs\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\z003rtbs\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\UserData\z003rtbs\OneDrive - Siemens AG\Documents\Arduino\libraries -fqbn=arduino:avr:pro:cpu=16MHzatmega328 -ide-version=10813 -build-path C:\Users\z003rtbs\AppData\Local\Temp\arduino_build_449327 -warnings=none -build-cache C:\Users\z003rtbs\AppData\Local\Temp\arduino_cache_80315 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7 -prefs=runtime.tools.avrdude.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\z003rtbs\Nextcloud\Projects\Van\OpenHab\MySensors\RS485_WS2812_Actuator\RS485_WS2812_Actuator.ino
Using board 'pro' from platform in folder: C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Using core 'arduino' from platform in folder: C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
Detecting libraries used...
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "C:\\Users\\z003rtbs\\AppData\\Local\\Temp\\arduino_build_449327\\sketch\\RS485_WS2812_Actuator.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for MySensors.h: [MySensors-master@2.3.2]
ResolveLibrary(MySensors.h)
-> candidates: [MySensors-master@2.3.2]
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "C:\\Users\\z003rtbs\\AppData\\Local\\Temp\\arduino_build_449327\\sketch\\RS485_WS2812_Actuator.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
-> candidates: [SPI@1.0]
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "C:\\Users\\z003rtbs\\AppData\\Local\\Temp\\arduino_build_449327\\sketch\\RS485_WS2812_Actuator.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for Adafruit_NeoPixel.h: [Adafruit_NeoPixel@1.7.0]
ResolveLibrary(Adafruit_NeoPixel.h)
-> candidates: [Adafruit_NeoPixel@1.7.0]
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel" "C:\\Users\\z003rtbs\\AppData\\Local\\Temp\\arduino_build_449327\\sketch\\RS485_WS2812_Actuator.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel" "C:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master\\MyASM.S" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel" "C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src\\SPI.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel" "C:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel\\Adafruit_NeoPixel.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel" "C:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel\\esp.c" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel" "C:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel\\esp8266.c" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel" "C:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel\\kendyte_k210.c" -o nul -DARDUINO_LIB_DISCOVERY_PHASE
Generating function prototypes...
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel" "C:\\Users\\z003rtbs\\AppData\\Local\\Temp\\arduino_build_449327\\sketch\\RS485_WS2812_Actuator.ino.cpp" -o "C:\\Users\\z003rtbs\\AppData\\Local\\Temp\\arduino_build_449327\\preproc\\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\z003rtbs\\AppData\\Local\\Temp\\arduino_build_449327\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\cores\\arduino" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\variants\\eightanaloginputs" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\MySensors-master" "-IC:\\Users\\z003rtbs\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.3\\libraries\\SPI\\src" "-IC:\\UserData\\z003rtbs\\OneDrive - Siemens AG\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel" "C:\\Users\\z003rtbs\\AppData\\Local\\Temp\\arduino_build_449327\\sketch\\RS485_WS2812_Actuator.ino.cpp" -o "C:\\Users\\z003rtbs\\AppData\\Local\\Temp\\arduino_build_449327\\sketch\\RS485_WS2812_Actuator.ino.cpp.o"
In file included from C:\UserData\z003rtbs\OneDrive - Siemens AG\Documents\Arduino\libraries\MySensors-master/core/MyHelperFunctions.cpp:20:0,
from C:\UserData\z003rtbs\OneDrive - Siemens AG\Documents\Arduino\libraries\MySensors-master/MySensors.h:44,
from C:\Users\z003rtbs\Nextcloud\Projects\Van\OpenHab\MySensors\RS485_WS2812_Actuator\RS485_WS2812_Actuator.ino:45:
C:\UserData\z003rtbs\OneDrive - Siemens AG\Documents\Arduino\libraries\MySensors-master/core/MyHelperFunctions.h:28:1: error: expected unqualified-id before 'static'
static uint8_t convertH2I(const char c) __attribute__((unused));
^~~~~~
C:\UserData\z003rtbs\OneDrive - Siemens AG\Documents\Arduino\libraries\MySensors-master/core/MyHelperFunctions.h:28:1: error: expected constructor, destructor, or type conversion before 'static'
Using library MySensors-master at version 2.3.2 in folder: C:\UserData\z003rtbs\OneDrive - Siemens AG\Documents\Arduino\libraries\MySensors-master
Using library SPI at version 1.0 in folder: C:\Users\z003rtbs\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3\libraries\SPI
Using library Adafruit_NeoPixel at version 1.7.0 in folder: C:\UserData\z003rtbs\OneDrive - Siemens AG\Documents\Arduino\libraries\Adafruit_NeoPixel
exit status 1
Error compiling for board Arduino Pro or Pro Mini.
Any and all help is appreciated.
Adam
I'm looking to use the examples from https://www.mysensors.org/build and combine them together in one arduino sketch so that one node can communicate a number of pieces of information back to the controller via a MAX485 module and network
I understand this is quite simple and possible with multiple, one time actions. Simply double up on the items in the code
For instance an arduino Mega:
Reading 10 button states https://www.mysensors.org/build/binary
Controlling 4 relay outputs https://www.mysensors.org/build/binary
And maybe even when a function is called periodically with a "sleep time" between reads, such as:
However, it's not clear to me if this can be done with sensors/actuators that are constantly 'working' for instance:
Controlling the brightness (via PWM) of a LED https://www.mysensors.org/build/dimmer
Controlling ws2812 LED data signal similar to https://www.domoticz.com/forum/viewtopic.php?f=42&t=8039&sid=71a5c0904f9a1662ff5447d264e6bb78
Can I amalgamate these .ino files? Am I only limited by the PWM / SPI outputs? Do I need to understand interrupts? Can a button press here go to the controller, run through an automation rule (I use Openhab) and then action a relay on the same node?
I'm drawing up some Gerber files for bespoke PCBs - the answer to the above will determine whether each function requires its own Arduino pro mini or whether I can simply have the functions ancilliary devices (relay, mosfet, 12v supply) on the pcb. I'll be sure to include the PCB somewhere for anyone else who would benefit from it.
Many thanks in advance, Adam
Hi @xydix , glad to hear you have the sketch working properly. Do you have the pinmode as OUTPUT or did you change to input?
And do you still have the saveStateL(closedPositionEE, closedPosition); line commented out?
If I change the pinMode to input, I get the system powered up and connected to the mysensors gateway fine - serial print repeats 'Button Release'. If I short press the button, the system does nothing. If I hold the button for 3000ms serial print reads 'Button Long Press' and the motor turns - however If I let go of the button, the motor stop and system returns to its 'button release' state.
I'm not able to get the system in to calibration mode.
@AWI Sorry for butting in to an old thread, but automating my blinds is top priority!
I've copied your sketch and have everything setup - however, I have eratic behaviour and a few questions:
void setup() {
// setup buttons
pinMode(buttonPin1, OUTPUT);
stepper1.setMaxSpeed(2000.0);
stepper1.setAcceleration(1000.0);
//saveStateL(closedPositionEE, closedPosition) ; // INIT: save closed position in EEPROM
closedPosition = loadStateL(closedPositionEE) ; // need to get last values from EEPROM and assume the current position is correct
setPosition = loadStateL(setPositionEE) ;
stepper1.setCurrentPosition(setPosition );
}//--(end setup )---
Should the pinMode on buttonPin1 actually be an INPUT?
Can you please describe how to go about calibrating the system?
Does the //saveStateL(closedPositionEE, closedPosition);
need uncommenting for one boot of the arduino and the blind closed - then the sketch re-uploading with it commented again?
Your help is greatly appreciated as I have a twitching motor and feel I'm almost there!