Navigation

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

    Best posts made by qobouky

    • RE: Cannot add Nodes trough RS 485

      Of course it was issue on my side. My understanding was that GW baud rate in mycontroller should be baud rate of RS485. When I changed baud rate to correct value everything works well. Nod is added automatically.

      But I would like to kindly ask you for next suggestion.

      I plan to use one Arduino to monitor Temp, Hum and CO2. Those sensors are presented in MyController as static now.

      Additionally script should control 3 relays. I added relay script from My sensors but I have no idea where I should see those relays in MyController and how to control them manually

      // 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
      
      #define MY_NODE_ID 20
      
      #include <MySensors.h>
      
      static const uint64_t UPDATE_INTERVAL = 10000;
      
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      #define CHILD_ID_CO2 2
      
      #define RELAY_PIN 10  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 3 // Total number of attached relays
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgCo2(CHILD_ID_CO2, V_LEVEL);
      MyMessage msgCo2b(CHILD_ID_CO2, V_UNIT_PREFIX);
      
      // ----------------------------------------------------------------------------
      
      void before()
      {
          for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
              // Then set relay pins in output mode
              pinMode(pin, OUTPUT);
              // Set relay to last known state (using eeprom storage)
              digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
          }
      }
      
      void presentation()  
      { 
        // Send the sketch version information to the gateway
        sendSketchInfo("Lihen", "1.0");
        
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_TEMP, S_TEMP);
        present(CHILD_ID_CO2, S_AIR_QUALITY);
        send(msgCo2b.set("ppm"));
      
        for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          present(sensor, S_BINARY);
        }
      }
      
      // ----------------------------------------------------------------------------
      void setup()
      {
        Serial.println( F("Arduino MySensors RS485 Node test") );    // Fonction F() permet de placer la chaine dans la mémoire eprogramme (Arduino IDE 1.0).
        analogReference(INTERNAL);
        delay(1000);
      }
      
      
      void loop()
      {
          Serial.println( F("Loop ...") );
          TempHum();
          readCO2(); 
          // Sleep for a while to save energy
          sleep(UPDATE_INTERVAL); 
      }
      
      void TempHum ()
      {
          int temperature = 30;
          int humidity = 50;
          Serial.print(F("Tmp: "));
          Serial.println(temperature);
          Serial.print(F("Hum: "));
          Serial.println(humidity);
      
          send(msgTemp.set(temperature, 1));
          send(msgHum.set(humidity, 1));
      }
      
      int readCO2()
      {
          int CO2value = 1550;
          Serial.print(F("CO2: "));
          Serial.println(CO2value);
      
          send(msgCo2.set(CO2value)); 
      }
      
      void receive(const MyMessage &message)
      {
          // We only expect one type of message from controller. But we better check anyway.
          if (message.getType()==V_STATUS) {
              // Change relay state
              digitalWrite(message.getSensor()-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
              // Store state in eeprom
              saveState(message.getSensor(), message.getBool());
              // Write some debug info
              Serial.print("Incoming change for sensor:");
              Serial.print(message.getSensor());
              Serial.print(", New status: ");
              Serial.println(message.getBool());
          }
      }
      
      posted in MyController.org
      qobouky
      qobouky
    • RE: WeMos D1 mini and NRF24

      Thank you very much for great explanation!!!

      But is there a way how to connect ESP8266 to Controller. In MySensors are available just ethernet or serial gateway with NRF. Of course I can connect ESP to NRF and then use serial gateway but then there is no difference if I use ESP or nano.

      My idea is that I want to use wireless network for sensors. One of my sensor should be LCD/TFT with touch so I wanted to prevent to use NRF (it occuy SPI)
      https://forum.mysensors.org/topic/9276/home-automation-tft-touch-display

      posted in Development
      qobouky
      qobouky
    • RE: MQ135 with RS485

      I found an root cause.

      In pin definition was

      #define AIQ_SENSOR_ANALOG_PIN 1
      

      but should be

      #define AIQ_SENSOR_ANALOG_PIN A1
      

      I do not know why with first definition it worked with nano but did not work with mini.

      posted in Troubleshooting
      qobouky
      qobouky