This version of Domoticz also contains a correction of wrong range of values returned for a request() of V_PERCENTAGE as described here : [https://www.domoticz.com/forum/viewtopic.php?t=20461]
Posts made by Tias
-
RE: Domoticz version 4.9700 released (stable)
-
RE: Adding MY_INCLUSION_MODE_INDICATOR_PIN ?
@mfalkvidd Thanks and sorry for the mess I caused.
/T -
RE: Adding MY_INCLUSION_MODE_INDICATOR_PIN ?
@mfalkvidd Ugh, well that looks messy. I finally managed to follow the guideline step by step but since I have never used github for any project (I normally work in projects hosted in-house) I have obviously messed up in some of the step(s).
I assume you can make this right and I can continue applying my small patch in my own copy of MySensors, it's not too much work for me anyway
/T -
RE: Philips LivingColors MySensor node
@jonathan-pucel said in Philips LivingColors MySensor node:
components
Hi !
One 74LVC125A is needed so the MISO-lines on the two antennas (NRF24L01 and CS2500) can be tri-stated. Otherwise they will collide and you will just get garbage on MISO (D12) on the Arduino and most probably fry one or both of the radio circuits too.
Cheers !
/T -
RE: Adding MY_INCLUSION_MODE_INDICATOR_PIN ?
Well, it looks like I finally solved my issues with the git verison.
I hope I made everything right since the Pull Request looked slightly different from what I expected of the examples steps at https://www.mysensors.org/download/contributingCheers !
/T -
RE: Adding MY_INCLUSION_MODE_INDICATOR_PIN ?
Hi !
I'd love to do it but I failed miserably using git in both Windows (unable to install bash) and Linux (bootstrap-dev.sh claims "Found git however, version 2.0 or greater is required..." but when I run git --version it happily shows 2.7.4) makes me going bananas (skogstokig ! ) when I need to debug all tools needed. I've been developing software for almost 40 years, but (obviously) never used git...
Cheers !
/T -
Adding MY_INCLUSION_MODE_INDICATOR_PIN ?
Hi !
About 10 months ago, I modified MyInclusionMode.cpp in MySensors v2.0 to be able to put a user-selected pin (by defining MY_INCLUSION_MODE_INDICATOR_PIN) to HIGH when the Inclusion button (as defiend by MY_INCLUSION_MODE_BUTTON_PIN) has been pressed and it will go to LOW when Inclusion mode times out.
It has been working fine for me since then so I'd like to see if it's possible to get this following small modifications included in the main trunk of MyInclusionMode.cpp ?In the end of inclusionInit() :
#if defined (MY_INCLUSION_MODE_INDICATOR_PIN) // Setup LED pin that indicates inclusion mode pinMode(MY_INCLUSION_MODE_INDICATOR_PIN, OUTPUT); digitalWrite(MY_INCLUSION_MODE_INDICATOR_PIN, LOW); #endif
...and in the end of inclusionModeSet() :
#if defined (MY_INCLUSION_MODE_INDICATOR_PIN) // Show inclusion mode with the LED: digitalWrite(MY_INCLUSION_MODE_INDICATOR_PIN,_inclusionMode); #endif```
-
RE: Philips LivingColors MySensor node
Neat !
Never saw that post coming up when googling aroundCheers !
/T -
Philips LivingColors MySensor node
I had a Philips LivingColors Generation 1 light lying around at home and by chance and I stumbled upon Ivo Knutsel's instructions on how to control the LivingColors using an Arduino here : http://www.knutsel.org/tag/livingcolors/
So I thought that this will be a good start for me to mess with the MySensors !
I tested some controllers and I decided to go for the Domoticz controller with a MySensors Ethernet Gateway.
Domoticz works just fine with my MySensors, it also works with my Philips Hue lamps, it allows me to display a drawing of my apartment and is open source; perfect !After some fiddling around and building other small MySensors (relays, LED-strip controllers, replacing our alarm system, etc) I finally came up with the following solution to control my LivingColors lamp.
Below s the information on what I came up with to control a LivingColors lamp using a MySensor node :-
First : All credits goes to Ivo Knutsel for all his hard work ! Please have a look at his webpage because it contains all the details on how the connection and detection of the lamp works.
-
Second : This only works for a Philips LivingColors Generation 1 lamp.
To make it easier to connect the CC2500 antenna to the Arduino I decided for a Arduino Pro Mini 3.3V. This avoids one of the 74LVC125A-circuits (which for me was a nightmare to solder !).
The schematic :
And the components mounted on a small board :
BOM:
- NRF24L01+
- Arduino Pro Mini 3.3V
- CS2500
- 74LVC125A
- 47ยตF capacitor
- 10 ยตF capacitor
- 100nF capacitor
- LD33V voltage regulator
Finally the sketch :
/* MTLivingColors --- Link a gen 1 Philips LivingColors lamp with MySensors. Author : Mathias Thorell. ----------------------------------------------------------------------------- This would never have been possible without the efforts of the following people : Ivo Knutsel : The investigations, schematic and source code to interact with the Living Light : http://www.knutsel.org/tag/livingcolors/ Henrik Ekblad : Founder of MySensors : www.mysensors.org darkoman : Class for fading from one RGB to another RGB color : http://www.codeproject.com/Articles/13497/An-advanced-gradient-rendering-class johnwasser : The Fire effect : http://forum.arduino.cc/index.php?topic=135206.msg1016852#msg1016852 Google : For everything else... 2016-02-27 First working version. 2016-02-28 Tested to adda DHT221 sensor, just for fun. Removed. 2016-02-29 Added fading. First realese candidate. 2016-03-01 Added Fire- and Aurora effects. 2016-03-08 Added Water-effect (requested by my daughter Angelina). 2016-08-05 Cleaned up and removed all non-LivingColors stuff. 2016-08-23 Removed effects to keep theis example as clean as possible. Note : Make sure to undef the SOFTSPI-constant in MyConfig.h, otherwise the two radios on the SPI bus will not cooperate at all. Known issues : Lamp flickers while fading. ToDo : Fix flickering while fading. Add possibility to find lamp address/id. Perhaps use an I/O-pin to enter learning mode ? Enable handling of more than only one lamp. Test: Should we become a S_RGBW instead of a S_RGB lamp ? Shall we or shall we not handle the V_PERCENT message ? Store Lamp Id in program memory ? */ //---------------------------------------------------------------------------------- #include <MyConfig.h> #include <MyHw.h> #include <MyHwATMega328.h> #include <MyMessage.h> #include <MyParser.h> #include <MyParserSerial.h> #include <MySensor.h> #include <MySigning.h> #include <MySigningNone.h> #include <MyTransport.h> #include <MyTransportNRF24.h> #include <Version.h> #include <DigitalIO.h> #include <DigitalPin.h> #include <I2cConstants.h> #include <PinIO.h> #include <SoftI2cMaster.h> #include <SoftSPI.h> #include <CC2500.h> #include <ColourConversion.h> #include <LivingColors.h> #include <SPI.h> //---------------------------------------------------------------------------------- // NRF24 pins for MySensors : #define RF24_CE_PIN 9 // Default value #define RF24_CS_PIN 6 // Default is 10, but we must use 6 since 10 is used by the CC2500 // CC2250 pins (sharing MISO, MOSI and SCK with the NRF24) #define lcMOSI 11 // SPI master data out pin #define lcMISO 12 // SPI master data in pin #define lcSCK 13 // SPI clock pin #define lcCS 10 // SPI slave select pin 10 #define node 1 // Assigning the node Id (this will be the address for controller) #define TheLampNum 1 // Sensor number needed in the custom devices set up #define StateOff 0 #define StateOn 1 //---------------------------------------------------------------------------------- // Helper class : class RGBColor { private: int FRed, FGreen, FBlue; public: RGBColor (int Red,int Green,int Blue) : FRed(Red), FGreen(Green), FBlue(Blue) { } RGBColor(void) { FRed = 0; FGreen = 0; FBlue = 0; } RGBColor(const RGBColor &From) { FRed = From.Red(); FGreen = From.Green(); FBlue = From.Blue(); } void Set(int red,int green,int blue) { FRed = red; FGreen = green; FBlue = blue; } void Set(RGBColor From) { FRed = From.Red(); FGreen = From.Green(); FBlue = From.Blue(); } int Red() const { return (FRed); } int Green() const { return (FGreen); } int Blue() const { return (FBlue); } }; //---------------------------------------------------------------------------------- // Class to fade from one RGB set to another RGB set class Fader { private: LivingColors *FLivCol; public: // Thanks to darkoman /* Construct the fader for the pins to manipulate. * Make sure these are pins that support Pulse * width modulation (PWM), these are the digital pins * denoted with a tilde(~) common are ~3, ~5, ~6, ~9, ~10 * and ~11 but check this on your type of arduino. */ Fader(LivingColors *livCol) { FLivCol = livCol; } // Fade from in to out void fade(const RGBColor &in, const RGBColor &out, unsigned n_steps = 256, //default take 256 steps unsigned timeMS = 2) //wait 10 ms per step { // Based on work by Darkoman; http://www.codeproject.com/Articles/13497/An-advanced-gradient-rendering-class double percent; int red,green,blue; for (int i = 0;i < 100;i++) { percent = 1.0 - ((double)i / (double)100); red = (int)((double)in.Red() * percent) + (int)(out.Red() * (1.0 - percent)); green = (int)((double)in.Green() * percent) + (int)(out.Green() * (1.0 - percent)); blue = (int)((double)in.Blue() * percent) + (int)(out.Blue() * (1.0 - percent)); red = red < 0 ? 0 : red; green = green < 0 ? 0 : green; blue = blue < 0 ? 0 : blue; red = red > 255 ? 255 : red; green = green > 255 ? 255 : green; blue = blue > 255 ? 255 : blue; // Write the new color output : FLivCol->turnLampOnRGB(0,red,green,blue); delay(timeMS); } } }; //---------------------------------------------------------------------------------- // NRF24 MyTransportNRF24 transport(RF24_CE_PIN,RF24_CS_PIN,RF24_PA_LEVEL_GW); // Hardware profile MyHwATMega328 hw; // Main sensor class : MySensor su; // Main control class to handle LivingColors : LivingColors livcol(lcCS,lcSCK,lcMOSI,lcMISO); RGBColor CurrentRGB,LastRGB; MyMessage livMsg(TheLampNum,V_RGB); //---------------------------------------------------------------------------------- // Lamp address(es) : // This is the address of my Living Colors lamp. // To find your unique id see reference to sketch below at the call to livcol.addLamp(). unsigned char lamp1[9] = { 0x00, 0xC7, 0x87, 0x66, 0xB7, 0x1A, 0xFF, 0x8A, 0x11 }; // Lamp address // Last known state; On (1) or Off (0) int LastState; // Instance of our fader class : Fader TheFader(&livcol); //---------------------------------------------------------------------------------- void setup() { // setup serial port Serial.begin(115200); // Initialize library and add callback for incoming messages su.begin(DoIncomingMessage,node,true); // Send the sketch version information to the gateway and Controller su.sendSketchInfo("RGB Node","1.1"); // Register the sensor to gw su.present(TheLampNum,S_RGB_LIGHT,"LivingColors"); // Load last known states of our lamp : LastState = su.loadState(0); // Last lamp state LastRGB.Set(su.loadState(1),su.loadState(2),su.loadState(3)); // Initialize or lamp : livcol.init(); livcol.clearLamps(); livcol.addLamp(lamp1); // Add our lamp. Lamp address/id must be taken from Ivo's original sketch from here : // http://www.knutsel.org/2010/04/11/using-the-cc2500-arduino-shield/ if (LastState) { // Turn on lamp is it was on before : livcol.turnLampOnRGB(0,LastRGB.Red(),LastRGB.Green(),LastRGB.Blue()); } else { // Turn off lamp is it was off before : livcol.turnLampOff(0); } } //---------------------------------------------------------------------------------- void loop() { // Do the MySensors dance : su.process(); } //---------------------------------------------------------------------------------- // Parse MySensors messages : void DoIncomingMessage(const MyMessage &message) { if (message.type == V_LIGHT) { if (message.getBool()) { Serial.println("Lamp On"); if (LastState == StateOff) { RGBColor fromRGB(0,0,0); RGBColor toRGB(LastRGB); TheFader.fade(fromRGB,toRGB); } livcol.turnLampOnRGB(0,LastRGB.Red(),LastRGB.Green(),LastRGB.Blue()); LastState = su.loadState(0); } else { Serial.println("Lamp Off"); if (LastState >= StateOn) { RGBColor fromRGB(LastRGB); RGBColor toRGB(0,0,0); TheFader.fade(fromRGB,toRGB); } livcol.turnLampOff(0); LastState = StateOff; } // Store state in eeprom su.saveState(0,LastState); } else if (message.type == V_RGB) { // starting to process the hex code String hexstring = message.getString(); // Here goes the hex color code coming from controller through MySensors (ex: FF9A00) long number = (long) strtol(&hexstring[0],NULL,16); CurrentRGB.Set((number >> 16) & 0xFF,(number >> 8) & 0xFF,number & 0xFF); // Write some debug info Serial.print("Red is " ); Serial.println(CurrentRGB.Red()); Serial.print("Green is " ); Serial.println(CurrentRGB.Green()); Serial.print("Blue is " ); Serial.println(CurrentRGB.Blue()); TheFader.fade(LastRGB,CurrentRGB); livcol.turnLampOnRGB(0,CurrentRGB.Red(),CurrentRGB.Green(),CurrentRGB.Blue()); LastRGB.Set(CurrentRGB); LastState = StateOn; su.saveState(0,LastState); su.saveState(1,LastRGB.Red()); su.saveState(2,LastRGB.Green()); su.saveState(3,LastRGB.Blue()); } else if (message.type == V_PERCENTAGE) { //Todo/missing: We need to consider this dimmer value when setting RGB's. String percstring = message.getString(); // 0-100 % long number = (long) strtol(&percstring[0],NULL,10); Serial.print("Dim value="); Serial.println(number); double dRed = (double)CurrentRGB.Red() * ((double)number / 100.0); double dGreen = (double)CurrentRGB.Green() * ((double)number / 100.0); double dBlue = (double)CurrentRGB.Blue() * ((double)number / 100.0); // Nope, tested and we don't need this. Taken care of via RGB ? // livcol.turnLampOnRGB(0,(int)dRed,(int)dGreen,(int)dBlue); } else { Serial.print("Unknown MsgType="); Serial.println(message.type); } } //----------------------------------------------------------------------------------
(This sketch is the bare minimum to control the LivingColors lamp.
I do possess a more complete sketch which includes some nice light effects too.)Questions and suggestions are welcome !
Enjoy !
/T -
-
RE: LEDs not blinking in my Ethernet Gateway
Hi !
Thanks, but as I mentioned in my OP, it is not working with that configuration neither so that's why I am trying to get help figuring out why it doesn't work in my case.Cheers !
/T -
RE: LEDs not blinking in my Ethernet Gateway
Hi !
Well, that's my main problem, the default configuration in MyConfig.h is :
#define DEFAULT_RX_LED_PIN 6
// The TX LED default pin
#define DEFAULT_TX_LED_PIN 5
// The Error LED default pin
#define DEFAULT_ERR_LED_PIN 4But the Ethernet Gateway using a WizNet (W5100) module is already occupying pin #5 and #6 as per the instructions at http://www.mysensors.org/build/ethernet_gateway
Cheers !
/T -
LEDs not blinking in my Ethernet Gateway
Hi !
I have successfully managed to set up an Ethernet Gateway using a WizNET (W5100) Ethernet module with an Arduino Pro Mini 5V module and it communicates fine with a Sensor node and Domoticz. So it works 100% fine and now I want to us the LEDs blinking feature (WITH_LEDS_BLINKING defined).
However, it does not matter which pins I choose, the error and TX LED's are always lit 100% of the time and the TX LED is always off.Since 2 of the default pins for the LED's are used by the NRF24 radio, by the I've tried :
#define RADIO_ERROR_LED_PIN 2
#define RADIO_RX_LED_PIN 3
#define RADIO_TX_LED_PIN 4#define RADIO_ERROR_LED_PIN 7
#define RADIO_RX_LED_PIN 8
#define RADIO_TX_LED_PIN 9With the same result as mentioned above.
Am I missing something here, or is it not possible to use the LED's in this kind of Gateway ?Cheers & TIA !
/T -
RE: Problem with Ardunio Ethernet as gateway
@Tias
Right, I gave up and got an Arduino Nano to use as a Serial gateway instead.It's initializing ok and entering the loop() but presents other issues, however, that's for another thread.
Cheers & thanks !
/T -
RE: Problem with Ardunio Ethernet as gateway
@anibaldiniz
Nope, it's an Arduino Ethernet (there's a link to it in my OP above). -
RE: Problem with Ardunio Ethernet as gateway
@flopp
No Problem, here's my EthernetGateway.ino and below MyConfig.h :EthernetGateway.ino :
#include <MyConfig.h> #include <MyHw.h> #include <MyHwATMega328.h> #include <MyHwESP8266.h> #include <MyMessage.h> #include <MyParser.h> #include <MyParserSerial.h> #include <MySensor.h> #include <MySigning.h> #include <MySigningAtsha204.h> #include <MySigningAtsha204Soft.h> #include <MySigningNone.h> #include <MyTransport.h> #include <MyTransportNRF24.h> #include <MyTransportRFM69.h> #include <Version.h> #include <MyConfig.h> #include <MyHw.h> #include <MyHwATMega328.h> #include <MyHwESP8266.h> #include <MyMessage.h> #include <MyParser.h> #include <MyParserSerial.h> #include <MySensor.h> #include <MySigning.h> #include <MySigningAtsha204.h> #include <MySigningAtsha204Soft.h> #include <MySigningNone.h> #include <MyTransport.h> #include <MyTransportNRF24.h> #include <MyTransportRFM69.h> #include <Version.h> #include <MyConfig.h> #include <MyHw.h> #include <MyHwATMega328.h> #include <MyHwESP8266.h> #include <MyMessage.h> #include <MyParser.h> #include <MyParserSerial.h> #include <MySensor.h> #include <MySigning.h> #include <MySigningAtsha204.h> #include <MySigningAtsha204Soft.h> #include <MySigningNone.h> #include <MyTransport.h> #include <MyTransportNRF24.h> #include <MyTransportRFM69.h> #include <Version.h> #include <NewPing.h> #include <MyConfig.h> #include <MyHw.h> #include <MyHwATMega328.h> #include <MyHwESP8266.h> #include <MyMessage.h> #include <MyParser.h> #include <MyParserSerial.h> #include <MySensor.h> #include <MySigning.h> #include <MySigningAtsha204.h> #include <MySigningAtsha204Soft.h> #include <MySigningNone.h> #include <MyTransport.h> #include <MyTransportNRF24.h> #include <MyTransportRFM69.h> #include <Version.h> #include <MyConfig.h> #include <MyHw.h> #include <MyHwATMega328.h> #include <MyHwESP8266.h> #include <MyMessage.h> #include <MyParser.h> #include <MyParserSerial.h> #include <MySensor.h> #include <MySigning.h> #include <MySigningAtsha204.h> #include <MySigningAtsha204Soft.h> #include <MySigningNone.h> #include <MyTransport.h> #include <MyTransportNRF24.h> #include <MyTransportRFM69.h> #include <Version.h> /** * 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 - Henrik EKblad * Contribution by a-lurker and Anticimex, * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de> * * * DESCRIPTION * The EthernetGateway sends data received from sensors to the ethernet link. * The gateway also accepts input on ethernet interface, which is then sent out to the radio network. * * The GW code is designed for Arduino 328p / 16MHz. ATmega168 does not have enough memory to run this program. * * * COMPILING WIZNET (W5100) ETHERNET MODULE * > Edit MyConfig.h in (libraries\MySensors\) to enable softspi (remove // before "#define SOFTSPI"). * * COMPILING ENC28J60 ETHERNET MODULE * > Use Arduino IDE 1.5.7 (or later) * > Disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch will probably not fit in program space when downloading. * > Remove Ethernet.h include below and include UIPEthernet.h * > Remove DigitalIO include * Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which means you have to choose a static IP for that module) * * VERA CONFIGURATION: * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin. * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003 * * LED purposes: * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly * - ERR (red) - fast blink on error during transmission error or recieve crc error * * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions. * */ #define DEBUG 1 #define NO_PORTB_PINCHANGES #include <DigitalIO.h> // This include can be removed when using UIPEthernet module #include <SPI.h> #include <MySigningNone.h> #include <MyTransportRFM69.h> #include <MyTransportNRF24.h> #include <MyHwATMega328.h> #include <MySigningAtsha204Soft.h> #include <MySigningAtsha204.h> #include <MyParserSerial.h> #include <MySensor.h> #include <stdarg.h> #include <PinChangeInt.h> #include "GatewayUtil.h" // Use this if you have attached a Ethernet ENC28J60 shields // #include <UIPEthernet.h> // Use this for WizNET W5100 module and Arduino Ethernet Shield #include <Ethernet.h> #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled #define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button #define RADIO_CE_PIN 7 // radio chip enable #define RADIO_SPI_SS_PIN 8 // radio SPI serial select #define RADIO_ERROR_LED_PIN 7 // Error led pin #define RADIO_RX_LED_PIN 8 // Receive led pin #define RADIO_TX_LED_PIN 9 // the PCB, on board LED // NRFRF24L01 radio driver (set low transmit power by default) MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW); //MyTransportRFM69 transport; // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) //MySigningNone signer; //MySigningAtsha204Soft signer; //MySigningAtsha204 signer; // Hardware profile MyHwATMega328 hw; // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h #ifdef WITH_LEDS_BLINKING MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN); #else MySensor gw(transport, hw /*, signer*/); #endif #define IP_PORT 5003 // The port you want to open IPAddress myIp (192, 168, 1, 89); // Configure your static ip-address here COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later! // The MAC address can be anything you want but should be unique on your network. // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use. // Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address. byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x45, 0x5F }; // DEAD BEEF FEED // a R/W server on the port EthernetServer server = EthernetServer(IP_PORT); // handle to open connection EthernetClient client = EthernetClient(); char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface int inputPos = 0; bool sentReady = false; void output(const char *fmt, ... ) { va_list args; va_start (args, fmt ); vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args); va_end (args); Serial.print(serialBuffer); server.write(serialBuffer); } void setup() { Serial.begin(115200);//MT: Without this, I don't get any debug msgs on the serial port. Ethernet.begin(mac, myIp); setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output); // Add interrupt for inclusion button to pin PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING); // give the Ethernet interface a second to initialize delay(1000); // Initialize gateway at maximum PA level, channel 70 and callback for write operations gw.begin(incomingMessage, 0, true, 0); // start listening for clients server.begin(); } void loop() { gw.process(); checkButtonTriggeredInclusion(); checkInclusionFinished(); // if an incoming client connects, there will be // bytes available to read via the client object EthernetClient newclient = server.available(); // if a new client connects make sure to dispose any previous existing sockets if (newclient) { if (client != newclient) { client.stop(); client = newclient; output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"), C_INTERNAL, I_GATEWAY_READY); } } if (client) { if (!client.connected()) { client.stop(); } else if (client.available()) { // read the bytes incoming from the client char inChar = client.read(); if (inputPos<MAX_RECEIVE_LENGTH-1) { // if newline then command is complete if (inChar == '\n') { Serial.println("Finished"); // a command was issued by the client // we will now try to send it to the actuator inputString[inputPos] = 0; // echo the string to the serial port Serial.print(inputString); parseAndSend(gw, inputString); // clear the string: inputPos = 0; } else { // add it to the inputString: inputString[inputPos] = inChar; inputPos++; } } else { // Incoming message too long. Throw away inputPos = 0; } } } }
MyConfig.h :
/** * 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. */ #ifndef MyConfig_h #define MyConfig_h #include <stdint.h> // Enable debug flag for debug prints. This will add a lot to the size of the final sketch but good // to see what is actually is happening when developing #define DEBUG // Disable this line, If you are using TX(1), RX(0) as normal I/O pin #define ENABLED_SERIAL // Serial output baud rate (for debug prints and serial gateway) #define BAUD_RATE 115200 /********************************** * Over the air firmware updates ***********************************/ // The following define enables the safe over-the-air firmware update feature // which requires external flash and the DualOptiBoot bootloader. // Note: You can still have OTA FW updates without external flash but it // requires the MYSBootloader and disabled MY_OTA_FIRMWARE_FEATURE //#define MY_OTA_FIRMWARE_FEATURE // Slave select pin for external flash #define MY_OTA_FLASH_SS 8 // Flash jdecid #define MY_OTA_FLASH_JDECID 0x1F65 /********************************** * Information LEDs blinking ***********************************/ // This feature enables LEDs blinking on message receive, transmit // or if some error occured. This was commonly used only in gateways, // but now can be used in any sensor node. Also the LEDs can now be // disabled in the gateway. //#define WITH_LEDS_BLINKING // The following setting allows you to inverse the blinking feature WITH_LEDS_BLINKING // When WITH_LEDS_BLINKING_INVERSE is enabled LEDSs are normally turned on and switches // off when blinking //#define WITH_LEDS_BLINKING_INVERSE // default LEDs blinking period in milliseconds #define DEFAULT_LED_BLINK_PERIOD 300 // The RX LED default pin #define DEFAULT_RX_LED_PIN 6 // The TX LED default pin #define DEFAULT_TX_LED_PIN 5 // The Error LED default pin #define DEFAULT_ERR_LED_PIN 4 /********************************** * Message Signing Settings ***********************************/ // Disable to completly disable signing functionality in library //#define MY_SIGNING_FEATURE // Define a suitable timeout for a signature verification session // Consider the turnaround from a nonce being generated to a signed message being received // which might vary, especially in networks with many hops. 5s ought to be enough for anyone. #define MY_VERIFICATION_TIMEOUT_MS 5000 // Enable to turn on whitelisting // When enabled, a signing node will salt the signature with it's unique signature and nodeId. // The verifying node will look up the sender in a local table of trusted nodes and // do the corresponding salting in order to verify the signature. // For this reason, if whitelisting is enabled on one of the nodes in a sign-verify pair, both // nodes have to implement whitelisting for this to work. // Note that a node can still transmit a non-salted message (i.e. have whitelisting disabled) // to a node that has whitelisting enabled (assuming the receiver does not have a matching entry // for the sender in it's whitelist) //#define MY_SECURE_NODE_WHITELISTING // MySigningAtsha204 default setting #define MY_ATSHA204_PIN 17 // A3 - pin where ATSHA204 is attached // MySigningAtsha204Soft default settings #define MY_RANDOMSEED_PIN 6 // A7 - Pin used for random generation (do not connect anything to this) // Key to use for HMAC calculation in MySigningAtsha204Soft (32 bytes) #define MY_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /********************************** * NRF24L01 Driver Defaults ***********************************/ #define RF24_CE_PIN 7 #define RF24_CS_PIN 8 #define RF24_PA_LEVEL RF24_PA_MAX #define RF24_PA_LEVEL_GW RF24_PA_LOW // RF channel for the sensor net, 0-127 #define RF24_CHANNEL 76 //RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps #define RF24_DATARATE RF24_250KBPS // This is also act as base value for sensor nodeId addresses. Change this (or channel) if you have more than one sensor network. #define RF24_BASE_RADIO_ID ((uint64_t)0xA8A8E1FC00LL) // Enable SOFTSPI for NRF24L01 when using the W5100 Ethernet module #define SOFTSPI #ifdef SOFTSPI // Define the soft SPI pins used for NRF radio const uint8_t SOFT_SPI_MISO_PIN = 12; const uint8_t SOFT_SPI_MOSI_PIN = 11; const uint8_t SOFT_SPI_SCK_PIN = 13; #endif /********************************** * RFM69 Driver Defaults ***********************************/ // Default network id. Use the same for all nodes that will talk to each other #define RFM69_NETWORKID 100 // Default frequency to use. This must match the hardware version of the RFM69 radio (uncomment one): // #define RFM69_FREQUENCY RF69_433MHZ #define RFM69_FREQUENCY RF69_868MHZ //#define FREQUENCY RF69_915MHZ // Enable this for encryption of packets //#define RFM69_ENABLE_ENCRYPTION #define RFM69_ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes! #endif
-
RE: Problem with Ardunio Ethernet as gateway
Hi !
Sorry, I tried both version 5 & 4 and then 7 & so that's why I messed it up in my post.
It is 7 & 8 (now corrected in my OP) based on the info for the Arduino Ethernet I linked to in tho OP.Cheers !
-
Problem with Ardunio Ethernet as gateway
Hi !
Trying to make my first gateway to work with no success.
I found out (by adding some Serial.println() statements) it fails in rf24.isPVariant().
Output (shown by the serial monitor) from MySensors is "0;0;3;0;9;radio init fail"
I am rather sure I have wired my NRF24L01+ wrong since the Arduino Ethernet board does not have the exact same pin markings as listen in MySenbors,org.(Ethernet is correctly setup since in my sketch I can ping the Arduino from my PC without problem)
My setup : Arduino Ethernet
Arduino IDE : 1.6.5
OS : Windows 10 Prof.
MySensors library version : 1.5.4
NRF devices are clearly the Plus version, chip is marked as
NRF M
24L01+
1452ABWiring (based on info I found here:
Arduino NRF24
GND GND
3.3V Vcc
Digital pin 7 CE
Digital pin 8 CSN/CS
SCK SCK
MOSI MOSI
MISO MISO
IRQ Not connectedChanges in the EthernetGateway sketch :
#define RADIO_CE_PIN 7 // radio chip enable
#define RADIO_SPI_SS_PIN 8 // radio SPI serial selectChanges in MyConfig.h :
#define DEBUG (obviously... )
...
#define RF24_CE_PIN 7
#define RF24_CS_PIN 8
....
const uint8_t SOFT_SPI_MISO_PIN = 12;
const uint8_t SOFT_SPI_MOSI_PIN = 11;
const uint8_t SOFT_SPI_SCK_PIN = 13;Has anyone else been successful using the Arduino Ethernet as a MySensor gateway ? If so, what am I doing wrong here... ?
Cheers & TIA !
/T