Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. simonszu
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    simonszu

    @simonszu

    1
    Reputation
    13
    Posts
    398
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    simonszu Follow

    Best posts made by simonszu

    • Lots of errors when trying to compile example sketch

      Hi,

      i have wired a gateway node with an NRF2401+ radio and a W5100 ethernet module and an Arduino nano. Pretty much like the tutorial.
      So now i want to flash the arduino. I have downloaded the 2.0.0 library and imported the zipfile as a library in the Arduino software. I have copy&pasted the example sketch for this type of gateway, and tried to compile it. But i get LOTS of errors according to code in the library itself. Let me show you:

      In file included from /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.cpp:23:0,
                       from /Users/simonszu/Documents/Arduino/libraries/MySensors-master/MySensors.h:261,
                       from /Volumes/simonszu's home/MySensors/gateway/gateway.ino:117:
      /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.h:34:31: error: 'SPI_MODE0' was not declared in this scope
       #define MY_RF24_SPI_DATA_MODE SPI_MODE0
                                     ^
      /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.h:38:76: note: in expansion of macro 'MY_RF24_SPI_DATA_MODE'
         SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;
                                                                                  ^
      /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.h:38:97: error: template argument 4 is invalid
         SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;
                                                                                                       ^
      /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.h:38:103: error: invalid type in declaration before ';' token
         SoftSPI<MY_SOFT_SPI_MISO_PIN, MY_SOFT_SPI_MOSI_PIN, MY_SOFT_SPI_SCK_PIN, MY_RF24_SPI_DATA_MODE> _SPI;
                                                                                                             ^
      In file included from /Users/simonszu/Documents/Arduino/libraries/MySensors-master/MySensors.h:261:0,
                       from /Volumes/simonszu's home/MySensors/gateway/gateway.ino:117:
      /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.cpp: In function 'uint8_t RF24_spiMultiByteTransfer(uint8_t, uint8_t*, uint8_t, bool)':
      /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.cpp:44:24: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'
        uint8_t status = _SPI.transfer( cmd );
                              ^
      /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.cpp:47:18: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'
          status = _SPI.transfer( NOP );
                        ^
      /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.cpp:49:24: error: request for member 'transfer' in '_SPI', which is of non-class type 'int'
         } else status = _SPI.transfer(*current++);
                              ^
      /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.cpp: In function 'bool RF24_initialize()':
      /Users/simonszu/Documents/Arduino/libraries/MySensors-master/drivers/RF24/RF24.cpp:261:7: error: request for member 'begin' in '_SPI', which is of non-class type 'int'
        _SPI.begin();
             ^
      exit status 1
      Error compiling for board Arduino Nano.
      

      So my question is now: How can i resolve these issues? I am quite sure that you didn't commit faulty code, so it's somehow an error on my side...but where am i wrong?

      posted in Development
      simonszu
      simonszu

    Latest posts made by simonszu

    • RE: DHT22 - switched sensor types?

      Ah. Yeah. Thanks. Sometimes one can be really blind when debugging own code. 😄

      posted in Development
      simonszu
      simonszu
    • DHT22 - switched sensor types?

      Hi,

      i am trying to set up a DHT22 node. This is my first step with mysensors ever. After figuring out some hardware issues, all connection is working, at least for a distance of around 1 meters.

      However, i'd like to ask how big can a temperature offset of a DHT22 sensor be? I have a room temperature of around 22°C, however, this sensor shows around 28°C - and a humiditiy of 23%. So, either the measurement tolerance is quite big, or i have somehow switched both readings.

      This is the code i have flashed on the node: https://pastebin.com/E2XWu3F3
      And this is how it appears in Home Assistant: https://pastebin.com/rLWn91ws

      Is my code correct? I think i have some weird errors, e.g. only increasing temperature is registered, when decreasing temperature, the value isn't decreasing as well.

      posted in Development
      simonszu
      simonszu
    • RE: Cannot add node to HA

      I knew that they are marked. But I didn't know the polarity. It could have been possible that Cap- goes to VCC on the radio, since in a full capacitor, there is a lack of electrons on Cap+, and very much electrons on Cap-, and also a lack of electrons on VCC, and very much electrons on GND, and the many electrons on the negative side should match the lack of electrons on the matching side of the other device - you see my point? So I was unsure.
      But Cap- to GND is clear and explicit, yeah.

      posted in Home Assistant
      simonszu
      simonszu
    • RE: Cannot add node to HA

      I checked with a multimeter. Turns out, the ceramic capacitors had 47pF 😄
      I ordered a set of assorted electrolytic capacitors. Should take some time, they're dispatched directly from China.
      However, i am unsure about the polarity of the capacitors. Should Cap+ go to VCC or GND of the radio?

      posted in Home Assistant
      simonszu
      simonszu
    • RE: Cannot add node to HA

      I'm afraid, i don't. But i won't hesitate ordering some from ebay. Any recommendation which capacity i should choose? Is 47 uF okay?

      posted in Home Assistant
      simonszu
      simonszu
    • RE: Cannot add node to HA

      I'm sorry, it was late last night. I did post wrong facts. I did not solder the capacitor parallel to the VCC and GND pins of the arduino, but parallel to the VCC and GND pins of the radio.
      Here's a photo of the capacitor on the sensor node: https://goo.gl/photos/REYnXMsLvLeKNKpf6
      And here's a photo of the capacitor on the gateway: https://goo.gl/photos/TNVNkJN7ZawcF5qg7

      I am not really sure about the capacity. On the capacitor, there is a 47 printed on it, with a line underneath it. I remember reading an article, explaining this kind of notation, and saying that this means 4.7 uF, but i don't find it any more and am unsure about the line underneath it. Maybe this means 47uF?

      If you say i should clearly try another capacity, i'll try.

      posted in Home Assistant
      simonszu
      simonszu
    • RE: Cannot add node to HA

      Okay, this sounds reasonable.
      But... How? The troubleshooting says, reduce range and add a capacitor. I added a capacitor (or should I add one to the vcc and gnd pin of the radio module as well?). I don't want to reduce range, since around 1 meter is quite close, and I don't want to cover my flat with repeater nodes - if I had to, MySensors would be no great use for me.

      posted in Home Assistant
      simonszu
      simonszu
    • RE: Cannot add node to HA

      I did 😉
      The complete log from startup to switch to switching off the sensor node after an unsuccessful test is posted as a pastebin link in the initial post from Thursday, and the log from the gateway captured at the same time is added as a pastebin link in my post from a few minutes ago. 🙂

      posted in Home Assistant
      simonszu
      simonszu
    • RE: Cannot add node to HA

      @martinhjelmare Thanks for helping. Unfortunately, i already have added a capacitor between the VCC and GND pin of the arduinos on the gateway and the sensor node. They are ceramic capacitors with 4.7 uF which should be enough in my experience. I also don't think it is a range problem, both devices are lying on my table, they have around 110cm distance between them.
      Since @gohan said that i should post more lines of my logs - yeah, sorry, my fault. This is the serial output of the gateway at the same time the node outputs the log i have pasted above: http://pastebin.com/y916idtc

      You see: After some time, the communication between the node and the gateway succeeds, however, Home Assistant shows nothing. With full respect, but i doubt i have physical issues. The presence of the capacitor and the small range should not be the reason for any errors - and the successful message exchange at the bottom of both log files (for which i didn't change anything from the situation at the top of the file) somehow make me suspicious about any physical issues. Or maybe somehow the laws of physics change magically at my desk, who knows 😉

      Of course i have checked all the wirings and solder points on both devices with my multimeter, they are correct.

      Also, let me say that if i hardcode the node ID into the node, there is a reaction from Home Assistant after 2-3 seconds after i start the sensor node that the node ID is unknown. So the physical radio connection between both devices is capable in working from startup of the sensor node - but somehow the communication between the gateway and home assistant fails?

      So, i ask explicitly: Is the sensor node sketch basically correct, regarding the initial value transmitting and stuff? Is the home assistant component definiton correct? I was unsure regarding the initial value transfer...

      posted in Home Assistant
      simonszu
      simonszu
    • Cannot add node to HA

      Hi,
      i am trying to get my first sensor node running. The GW is a 5100 based ethernet GW and works fine.
      The node is a DHT22-Sensor. This is my current sketch:

      // Enable and select radio type attached 
      #define MY_RADIO_NRF24
      
      // Enable debugging
      #define MY_DEBUG
      
      //#define MY_NODE_ID 1
      
      #include <DHT.h>
      #include <DHT_U.h>
      #include <MySensors.h>
      
      // Set this to the pin you connected the DHT's data pin to
      #define DHT_DATA_PIN 3
      
      // We're using a DHT22
      #define DHTTYPE DHT22
      
      // Set a child sensor id
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      
      
      
      DHT_Unified dht(DHT_DATA_PIN, DHTTYPE);
      
      uint32_t delayMS;
      float humidity;
      float temperature;
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      
      bool initialValueSent = false;
      
      
      void setup()
      {
        dht.begin();
        sensor_t sensor;
        // Set delay between sensor readings based on sensor details.
        delayMS = sensor.min_delay / 1000;
      }
      
      void presentation()
      {
        sendSketchInfo("DHT22 Sensor", "0.1");
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_TEMP, S_TEMP);
      }
      
      
      void loop()      
      {  
        if(!initialValueSent) {
          send(msgTemp.set(0));
          send(msgTemp.set(0));
          request(CHILD_ID_HUM, V_HUM);
          wait(1000);
        }
        // Read stuff from the DHT sensor
        sensors_event_t event;
        dht.temperature().getEvent(&event);
          if (isnan(event.temperature)) {
            Serial.println("Error reading temperature.");
            temperature = 0;
        }
        else {
          temperature = event.temperature;
      
        }
        // Get humidity event and print its value.
        dht.humidity().getEvent(&event);
        if (isnan(event.relative_humidity)) {
          Serial.println("Error reading humidity!");
          humidity = 0;
        }
        else {
          humidity = event.relative_humidity;
        }
        send(msgHum.set(temperature, 1));
        #ifdef My_DEBUG
        Serial.print("T: ")
        Serial.println(temperature);
        #endif
        send(msgTemp.set(humidity, 1));
        #ifdef My_DEBUG
        Serial.print("H: ")
        Serial.println(humidity);
        #endif
        
        // Delay between measurements.
        delay(delayMS);
      }
      
      void receive(const MyMessage &message)
      {
        if (message.isAck()) {
           Serial.println("This is an ack from gateway");
        }
        if (message.type == V_HUM) {
          if (!initialValueSent) {
            Serial.println("Receiving initial value from controller");
            initialValueSent = true;
          }
        }
      }
      

      Please note the commented MY_NODE_ID at the top of the sketch. When i uncomment it, i get lots of errors from HA that the node isn't known (yet). So, physically the communication between node, gateway and controller is working.
      However, if i run the sketch with the NODE_ID commented out, i get no feedback from HA, and this output in the serial console of the node: http://pastebin.com/2KqWDZN0

      I see at the bottom of the file that there is some kind of perhaps successful connection to HA, however, i don't see anything in the log of HA, nor a new device on the dev-state section of HA. Can anyone see where's the error?
      What unclear for me as well is the fact that there are lots of messages like

      166507 TSM:FPAR
      166544 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      168551 !TSM:FPAR:NO REPLY
      

      This is the serial output of the gateway: http://pastebin.com/C7CyLW6K It looks like the gateway is indeed receiving the messages from the node, but HA isn't reacting.
      This is my HA config:

      gateways:
        - device: '192.168.1.233'
          persistence_file: 'mysensors.json'
      debug: true
      version: 2.0
      

      And this is the content of mysensors.json

      {"0": {"sketch_name": null, "type": 18, "battery_level": 0, "sketch_version": null, "sensor_id": 0, "children": {}, "protocol_version": "2.1.1"}, "1": {"sketch_name": null, "type": 17, "battery_level": 0, "sketch_version": "0.1", "sensor_id": 1, "children": {"0": {"description": "", "values": {"1": "23.0"}, "type": 7, "id": 0}, "1": {"description": "", "values": {"0": "30.7"}, "type": 6, "id": 1}}, "protocol_version": "2.1.1"}}
      
      

      Please note that the json has 2 sensors added. I cannot explain to myself why. Also: sensor 1 has the proper sketch_version, but no sketch_name, although defined in the sketch.

      So, has anyone an idea what's wrong here?

      And, on a unrelated side note: I see every sketch in this section around here having this initialValueSent Stuff from the HA component description. I understand that the switch(?) in the component description should have an initial value to it from HA, but just simple sensor nodes like temperature or light don't. So, could it be possible to ease the process up and just start the loop after presenting the sensor type to HA? After starting the loop, the sensor should start begin sending out values, and the first value is taken as the initialValue then. Could this be possible?

      posted in Home Assistant
      simonszu
      simonszu