Can't get RFM69 working



  • I created a gateway with the RFM69 and a sensor with it. When i look at the serial monitor from the gateway i get

    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;14;Gateway startup complete.
    

    Now i try to send something like: 10;1;1;1;2;0

    then i get the startup message again:

    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;14;Gateway startup complete.
    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;14;Gateway startup complete.
    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;14;Gateway startup complete.
    

    When i try to send something with the sensor i get the know fail message.

    When uploading the serial gateway i enabled the RFM69:

    //MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
    MyTransportRFM69 transport;
    

    How can i set this for the sensors?



  • Hello,

    Did you set RFM69 parameters in MyConfig.h ?

    Put your gateway and sensor code. Without it's difficult to help you.
    I spent several hours to set mine.

    David



  • Gateway:

    /**
     * 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.
     *
     *******************************
     *
     * DESCRIPTION
     * The ArduinoGateway prints data received from sensors on the serial link. 
     * The gateway accepts input on seral which will be sent out on radio network.
     *
     * The GW code is designed for Arduino Nano 328p / 16MHz
     *
     * Wire connections (OPTIONAL):
     * - Inclusion button should be connected between digital pin 3 and GND  
     * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
     *
     * LEDs (OPTIONAL):
     * - 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 
     * 
     */
    
    #define NO_PORTB_PINCHANGES  
    
    #include <MySigningNone.h>
    #include <MyTransportRFM69.h>
    #include <MyTransportNRF24.h>
    #include <MyHwATMega328.h>
    #include <MySigningAtsha204Soft.h>
    #include <MySigningAtsha204.h>
    
    #include <SPI.h>  
    #include <MyParserSerial.h>  
    #include <MySensor.h>  
    #include <stdarg.h>
    #include <PinChangeInt.h>
    #include "GatewayUtil.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_ERROR_LED_PIN 4  // Error led pin
    #define RADIO_RX_LED_PIN    6  // Receive led pin
    #define RADIO_TX_LED_PIN    5  // the PCB, on board LED
    
    // NRFRF24L01 radio driver (set low transmit power by default) 
    //MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_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
    
    char inputString[MAX_RECEIVE_LENGTH] = "";    // A string to hold incoming commands from serial/ethernet interface
    int inputPos = 0;
    boolean commandComplete = false;  // whether the string is complete
    
    void parseAndSend(char *commandBuffer);
    
    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);
    }
    
      
    void setup()  
    { 
      gw.begin(incomingMessage, 0, true, 0);
    
      setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
    
      // Add interrupt for inclusion button to pin
      PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
    
    
      // Send startup log message on serial
      serial(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"),  C_INTERNAL, I_GATEWAY_READY);
    }
    
    void loop()  
    { 
      gw.process();
    
      checkButtonTriggeredInclusion();
      checkInclusionFinished();
      
      if (commandComplete) {
        // A command wass issued from serial interface
        // We will now try to send it to the actuator
        parseAndSend(gw, inputString);
        commandComplete = false;  
        inputPos = 0;
      }
    }
    
    
    /*
      SerialEvent occurs whenever a new data comes in the
     hardware serial RX.  This routine is run between each
     time loop() runs, so using delay inside loop can delay
     response.  Multiple bytes of data may be available.
     */
    void serialEvent() {
      while (Serial.available()) {
        // get the new byte:
        char inChar = (char)Serial.read(); 
        // if the incoming character is a newline, set a flag
        // so the main loop can do something about it:
        if (inputPos<MAX_RECEIVE_LENGTH-1 && !commandComplete) { 
          if (inChar == '\n') {
            inputString[inputPos] = 0;
            commandComplete = true;
          } else {
            // add it to the inputString:
            inputString[inputPos] = inChar;
            inputPos++;
          }
        } else {
           // Incoming message too long. Throw away 
            inputPos = 0;
        }
      }
    }
    

    Sensor (default binaryswitchsleep):

    /**
     * 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.
     *
     *******************************
     *
     * DESCRIPTION
     *
     * Interrupt driven binary switch example with dual interrupts
     * Author: Patrick 'Anticimex' Fallberg
     * Connect one button or door/window reed switch between 
     * digitial I/O pin 3 (BUTTON_PIN below) and GND and the other
     * one in similar fashion on digital I/O pin 2.
     * This example is designed to fit Arduino Nano/Pro Mini
     * 
     */
    
    
    #include <MySensor.h>
    #include <SPI.h>
    
    #define SKETCH_NAME "Binary Sensor"
    #define SKETCH_MAJOR_VER "1"
    #define SKETCH_MINOR_VER "0"
    
    #define PRIMARY_CHILD_ID 3
    #define SECONDARY_CHILD_ID 4
    
    #define PRIMARY_BUTTON_PIN 2   // Arduino Digital I/O pin for button/reed switch
    #define SECONDARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
    
    #if (PRIMARY_BUTTON_PIN < 2 || PRIMARY_BUTTON_PIN > 3)
    #error PRIMARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
    #endif
    #if (SECONDARY_BUTTON_PIN < 2 || SECONDARY_BUTTON_PIN > 3)
    #error SECONDARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
    #endif
    #if (PRIMARY_BUTTON_PIN == SECONDARY_BUTTON_PIN)
    #error PRIMARY_BUTTON_PIN and BUTTON_PIN2 cannot be the same
    #endif
    #if (PRIMARY_CHILD_ID == SECONDARY_CHILD_ID)
    #error PRIMARY_CHILD_ID and SECONDARY_CHILD_ID cannot be the same
    #endif
     
    MySensor sensor_node;
    
    // Change to V_LIGHT if you use S_LIGHT in presentation below
    MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED);
    MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED);
    
    void setup()  
    {  
      sensor_node.begin();
    
      // Setup the buttons
      pinMode(PRIMARY_BUTTON_PIN, INPUT);
      pinMode(SECONDARY_BUTTON_PIN, INPUT);
    
      // Activate internal pull-ups
      digitalWrite(PRIMARY_BUTTON_PIN, HIGH);
      digitalWrite(SECONDARY_BUTTON_PIN, HIGH);
      
      // Send the sketch version information to the gateway and Controller
      sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER);
    
      // Register binary input sensor to sensor_node (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      sensor_node.present(PRIMARY_CHILD_ID, S_DOOR);  
      sensor_node.present(SECONDARY_CHILD_ID, S_DOOR);  
    }
    
    // Loop will iterate on changes on the BUTTON_PINs
    void loop() 
    {
      uint8_t value;
      static uint8_t sentValue=2;
      static uint8_t sentValue2=2;
    
      // Short delay to allow buttons to properly settle
      sensor_node.sleep(5);
      
      value = digitalRead(PRIMARY_BUTTON_PIN);
      
      if (value != sentValue) {
         // Value has changed from last transmission, send the updated value
         sensor_node.send(msg.set(value==HIGH ? 1 : 0));
         sentValue = value;
      }
    
      value = digitalRead(SECONDARY_BUTTON_PIN);
      
      if (value != sentValue2) {
         // Value has changed from last transmission, send the updated value
         sensor_node.send(msg2.set(value==HIGH ? 1 : 0));
         sentValue2 = value;
      }
    
      // Sleep until something happens with the sensor
      sensor_node.sleep(PRIMARY_BUTTON_PIN-2, CHANGE, SECONDARY_BUTTON_PIN-2, CHANGE, 0);
    } 
    

    And i have set the RFM in the config.h to: #define RFM69_FREQUENCY RF69_433MHZ



  • What is your hardware configuration ? Looks like the gateway is in a reset loop, no ? Possible power issue ?



  • Arduino uno > level shifter > RFM69HW

    the level shifter / RFM is powered by a separate 5 > 3.3v converter.



  • hello,

    How did you powered the rfm69 on the uno ? using the 3.3 from the uno or using a voltage regulator ?
    I first used voltage regulator but I encountered some issues with the uno so I finally directly used the 3.3 from the uni board.

    another thing, remove not used include such 'MyTransportNRF24' in your code.

    I will post my gateway and sensor code thus evening as I can't do it from my phone now ...



  • The RFM is powered by the regulator. Havent tried to power it from the 3v from the arduino yet.



  • Hello,

    The code as promise.
    For the gateway I don't change a lot of thing from the example provided in the lib:

    /**
     * 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.
     *
     */
    
    /**************************************************************************************/
    /* Serial gateway (RFM69 with encryption, soft signing and LEDs).                     */
    /*                                                                                    */
    /* Version     : 0.1.1                                                                */
    /* Date        : 29/11/2015                                                           */
    /* Modified by : David Carlier                                                        */
    /**************************************************************************************/
    
    #define NO_PORTB_PINCHANGES
    
    #include <MyTransportRFM69.h>
    #include <MyHwATMega328.h>
    #include <MySigningAtsha204Soft.h>
    
    #include <SPI.h>
    #include <MyParserSerial.h>
    #include <MySensor.h>
    #include <stdarg.h>
    #include <PinChangeInt.h>
    #include "GatewayUtil.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_ERROR_LED_PIN 4  // Error led pin
    #define RADIO_RX_LED_PIN    6  // Receive led pin
    #define RADIO_TX_LED_PIN    5  // the PCB, on board LED
    
    //Construct MySensors library
    MySigningAtsha204Soft signer;
    MyHwATMega328 hw;
    MyTransportRFM69 transport;
    MySensor gw(transport, hw, signer, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
    
    //Variables
    char inputString[MAX_RECEIVE_LENGTH] = "";
    int inputPos = 0;
    boolean commandComplete = false;
    
    void parseAndSend(char *commandBuffer);
    
    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);
    }
    
      
    /**************************************************************************************/
    /* Initialization                                                                     */
    /**************************************************************************************/
    void setup()
      {
      //Start MySensors
      gw.begin(incomingMessage, 0, true, 0);
      setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
    
      //Add interrupt for inclusion button to pin
      PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
    
      //Send startup log message on serial
      serial(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"), C_INTERNAL, I_GATEWAY_READY);
      }
    
    /**************************************************************************************/
    /* Main loop                                                                          */
    /**************************************************************************************/
    void loop()
      {
      gw.process();
    
      checkButtonTriggeredInclusion();
      checkInclusionFinished();
    
      if (commandComplete)
        {
        //A command wass issued from serial interface
        //We will now try to send it to the actuator
        parseAndSend(gw, inputString);
        commandComplete = false;  
        inputPos = 0;
        }
      }
    
    /*
      SerialEvent occurs whenever a new data comes in the
     hardware serial RX.  This routine is run between each
     time loop() runs, so using delay inside loop can delay
     response.  Multiple bytes of data may be available.
     */
    void serialEvent() {
      while (Serial.available()) {
        // get the new byte:
        char inChar = (char)Serial.read(); 
        // if the incoming character is a newline, set a flag
        // so the main loop can do something about it:
        if (inputPos<MAX_RECEIVE_LENGTH-1 && !commandComplete) { 
          if (inChar == '\n') {
            inputString[inputPos] = 0;
            commandComplete = true;
          } else {
            // add it to the inputString:
            inputString[inputPos] = inChar;
            inputPos++;
          }
        } else {
           // Incoming message too long. Throw away 
            inputPos = 0;
        }
      }
    }
    

    For the sensor, there is more difference from the humidity example:

    /**
     * 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.
     *
     */
    
    /**************************************************************************************/
    /* Temperature, humidity and luminosity measurements.                                 */
    /*                                                                                    */
    /* Version     : 1.1.5                                                                */
    /* Date        : 04/01/2016                                                           */
    /* Modified by : David Carlier                                                        */
    /**************************************************************************************/
    /*                                ---------------                                     */
    /*                            RST |             |  A5                                 */
    /*                            RX  |             |  A4                                 */
    /*                            TX  |   ARDUINO   |  A3                                 */
    /*     RFM69 (DIO0) --------- D2  |     UNO     |  A2                                 */
    /*            DHT22 --------- D3  |             |  A1                                 */
    /*            Power --------- D4  | ATMEGA 328p |  A0 --------- Light dep. resistor   */
    /*              +3v --------- VCC |             | GND --------- GND                   */
    /*              GND --------- GND |  8MHz int.  | REF                                 */
    /*                            OSC |             | VCC --------- +3v                   */
    /*                            OSC |             | D13 --------- RFM69 (SCK)           */
    /*                            D5  |             | D12 --------- RFM69 (MISO)          */
    /*                            D6  |             | D11 --------- RFM69 (MOSI)          */
    /*                            D7  |             | D10 --------- RFM69 (NSS)           */
    /*                            D8  |             |  D9                                 */
    /*                                ---------------                                     */
    /*                                                                                    */
    /* Power = Vcc for LDR and DHT22 et SWITCH.                                           */
    /* +3v = 2*AA                                                                         */
    /*                                                                                    */
    /**************************************************************************************/
    
    #include <SPI.h>
    #include <MySensor.h>
    #include <dht.h>
    #include <MyTransportRFM69.h>
    #include <MySigningAtsha204Soft.h>
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_LIGHT 2
    #define CHILD_ID_VOLTAGE 3
    #define LIGHT_SENSOR_ANALOG_PIN 0
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    #define POWER_PIN 4
    unsigned long SLEEP_TIME = 275000; // Sleep time between reads (in milliseconds)
    
    //Construct MySensors library
    MySigningAtsha204Soft signer;
    MyHwATMega328 hw;
    MyTransportRFM69 transport;
    MySensor gw(transport, hw, signer);
    dht DHT;
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgLum(CHILD_ID_LIGHT, V_LEVEL);
    MyMessage msgVolt(CHILD_ID_VOLTAGE, V_VOLTAGE);
    
    /**************************************************************************************/
    /* Initialization                                                                     */
    /**************************************************************************************/
    void setup()
      {
      //Get time (for setup duration)
      #ifdef DEBUG
        unsigned long startTime = millis();
      #endif
    
      //Start MySensors
      gw.begin();
    
      //Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("GHAS sensor", "1.1.5");
    
      //Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_HUM, S_HUM);
      gw.present(CHILD_ID_TEMP, S_TEMP);
      gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
      gw.present(CHILD_ID_VOLTAGE, S_MULTIMETER);
    
      //Delay for DHT22
      delay(1500);
    
      //Print setup debug
      #ifdef DEBUG
        int duration = millis() - startTime;
        Serial.print("[Setup duration: "); Serial.print(duration, DEC); Serial.println(" ms]");
      #endif
      }
    
    /**************************************************************************************/
    /* Main loop                                                                          */
    /**************************************************************************************/
    void loop()
      {
      //Get time (for a complete loop)
      #ifdef DEBUG
        unsigned long startTime = millis();
      #endif
    
      //Power on
      powerOnPeripherals();
      delay(2000);
    
      //Get DHT22 data
      int dht22Result = DHT.read22(HUMIDITY_SENSOR_DIGITAL_PIN);
      switch (dht22Result)
        {
        case DHTLIB_OK:  
                    //Serial.println("OK,\t");
                    break;
        case DHTLIB_ERROR_CHECKSUM:
                    #ifdef DEBUG
                      Serial.println("Checksum error,\t");
                    #endif
                    break;
        case DHTLIB_ERROR_TIMEOUT:
                    #ifdef DEBUG
                      Serial.println("Time out error,\t");
                    #endif
                    break;
        case DHTLIB_ERROR_CONNECT:
                    #ifdef DEBUG
                      Serial.println("Connect error,\t");
                    #endif
                    break;
        case DHTLIB_ERROR_ACK_L:
                    #ifdef DEBUG
                      Serial.println("Ack Low error,\t");
                    #endif
                    break;
        case DHTLIB_ERROR_ACK_H:
                    #ifdef DEBUG
                      Serial.println("Ack High error,\t");
                    #endif
                    break;
        default:
                    #ifdef DEBUG
                      Serial.println("Unknown error,\t");
                    #endif
                    break;
        }
    
      //Get temperature and humidity
      float temperature = 0;
      float humidity = 0;
      if (dht22Result == DHTLIB_OK)
        {
        temperature = DHT.temperature;
        humidity = DHT.humidity;
        }
    
      //Get power before luminosity to use real voltage
      float realVoltage = getVoltage() / 100.0;
      int batteryPcnt = realVoltage * 100 / 3.0;
      if (batteryPcnt > 100) {batteryPcnt = 100;}
      int lux = computeIlluminance(realVoltage);
    
      //Power off
      powerOffPeripherals();
    
      //Send data to gateway
      gw.send(msgHum.set(humidity, 1));
      gw.send(msgTemp.set(temperature, 1));
      gw.send(msgLum.set(lux));
      gw.send(msgVolt.set(realVoltage, 2));
      gw.sendBatteryLevel(batteryPcnt);
    
      //Print debug
      #ifdef DEBUG
        Serial.print(temperature, 1);
        Serial.print(" degC");
        Serial.print("   ");
        Serial.print(humidity, 1);
        Serial.print(" %");
        Serial.print("   ");
        Serial.print(lux);
        Serial.print(" lx");
        Serial.print("   ");
        Serial.print(realVoltage);
        Serial.print(" v");
        int duration = millis() - startTime;
        Serial.print("   ");
        Serial.print("["); Serial.print(duration, DEC); Serial.println(" ms]");
        Serial.flush();
      #endif
    
      //Sleep
      gw.sleep(SLEEP_TIME);
      }
    
    /**************************************************************************************/
    /* Allows to compute illuminance (in LUX) from LIGHT_SENSOR_ANALOG_PIN.               */
    /**************************************************************************************/
    int computeIlluminance(float realVoltage)
      {
      //Get luminosity
      int luminosity = analogRead(LIGHT_SENSOR_ANALOG_PIN);
      //Calculating the voltage in the input of the ADC
      double voltage = realVoltage * ((double)luminosity / 1024.0);
      //Calculating the resistance of the photoresistor in the voltage divider
      double resistance = (10.0 * realVoltage) / voltage - 10.0;
      //Calculating the intensity of light in lux and return it
      int illuminance = 255.84 * pow(resistance, -10/9);
      return illuminance;
      }
    
    /**************************************************************************************/
    /* Allows to get the real Vcc (return value * 100).                                   */
    /**************************************************************************************/
    int getVoltage()
      {
      const long InternalReferenceVoltage = 1056L;
      ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
      delay(50);  // Let mux settle a little to get a more stable A/D conversion
      //Start a conversion  
      ADCSRA |= _BV( ADSC );
      //Wait for it to complete
      while (((ADCSRA & (1<<ADSC)) != 0));
      //Scale the value
      int result = (((InternalReferenceVoltage * 1023L) / ADC) + 5L) / 10L;
      return result;
      }
    
    /**************************************************************************************/
    /* Allows to power ON peripherals.                                                    */
    /**************************************************************************************/
    void powerOnPeripherals()
      {
      //Power-up
      pinMode (POWER_PIN, OUTPUT);
      digitalWrite (POWER_PIN, HIGH);
      delay(1);
      }
    
    /**************************************************************************************/
    /* Allows to power OFF peripherals.                                                   */
    /**************************************************************************************/
    void powerOffPeripherals()
      {
      //Power off
      digitalWrite (HUMIDITY_SENSOR_DIGITAL_PIN, LOW);
      digitalWrite (POWER_PIN, LOW);
      pinMode (HUMIDITY_SENSOR_DIGITAL_PIN, INPUT);
      pinMode (POWER_PIN, INPUT);
      }
    
    

    David



  • Thanks, will try it :)



  • How do you change I/O pins define for the RFM69 if using a different platform??

    will this work under 1.6 development ?

    Thanks



  • @carlierd I tried to compile your gateway but i get this error:

    Arduino: 1.6.5 (Mac OS X), Board:"Arduino Uno"
    
    SerialGateway:52: error: no matching function for call to 'MySensor::MySensor(MyTransportRFM69&, MyHwATMega328&, MySigningAtsha204Soft&, int, int, int)'
    SerialGateway.ino:52:91: note: candidates are:
    In file included from SerialGateway.ino:37:0:
    /Users/Wiebe/Documents/Arduino/libraries/MySensors/MySensor.h:158:2: note: MySensor::MySensor(MyTransport&, MyHw&)
      MySensor(MyTransport &radio =*new MyTransportNRF24(), MyHw &hw=*new MyHwDriver()
      ^
    /Users/Wiebe/Documents/Arduino/libraries/MySensors/MySensor.h:158:2: note:   candidate expects 2 arguments, 6 provided
    /Users/Wiebe/Documents/Arduino/libraries/MySensors/MySensor.h:149:7: note: MySensor::MySensor(const MySensor&)
     class MySensor
           ^
    /Users/Wiebe/Documents/Arduino/libraries/MySensors/MySensor.h:149:7: note:   candidate expects 1 argument, 6 provided
    no matching function for call to 'MySensor::MySensor(MyTransportRFM69&, MyHwATMega328&, MySigningAtsha204Soft&, int, int, int)'
    
    


  • Hello,

    I am using stable version of MySensors not the dev branch. What version are you using ?

    David





  • @Sweebee said:

    SerialGateway:52: error: no matching function for call to 'MySensor::MySensor(MyTransportRFM69&, MyHwATMega328&, MySigningAtsha204Soft&, int, int, int)'

    Did you enabled signing feature in MyConfig.h : #define MY_SIGNING_FEATURE ??



  • I think the gateway works now, i removed the separate 5-3.3v converter and used the arduino 3.3v.

    Now the sensor, i uploaden your sketch, but i get no init message?



  • Did you connect the gateway to a controller ? or to MYSController ? You get the gateway ready message ?

    For the sensor, you are using the sketch I upload ?
    Debug mode is enable in MyConfig.h ?

    You should have some debug messages in the console when connecting to the node.

    David.



  • The problem is on the uno everything seems to work fine.

    for the sensor i attached the RFM to a arduino pro mini 3.3v

    double checked the wiring, tried 2 different RFM's, tried 2 arduino pro mini's.

    uploaden the gateway to it and i get:

    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    

    but when i try to send something with the pro mini i get nothing back, while on the UNO I get:

    0;0;3;0;9;send: 0-0-10-10 s=1,c=1,t=2,pt=0,l=1,sg=0,st=fail:1
    

    So on the pro mini i get the init message, but no message when i try to send something.



  • RFM69 or RFM69HW ?

    For RFM69HW you have to modify MyTransportRFM69.hand enable HW model on line 33.
    Replace bool isRFM69HW=falseby bool isRFM69HW=true.

    Nothing on the serial output of the pro mini ??



  • Do you use 4.7uF capacitor ?



  • Yes i have the HW versions, so i replaced bool isRFM69HW=falsebybool isRFM69HW=true

    added a capacitor.

    refreshed and still no feedback after sending.

    I get a serial output from the pro mini on start. but no more serial messages when i try to send a message.


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.