Firmware do rolet dla silniczka krokowego

radzik_r
Posts: 468
Joined: Sun Aug 11, 2019 5:32 pm
Has thanked: 1 time
Been thanked: 2 times

Post

zbylcio wrote: Mon Mar 04, 2024 8:29 am
po co łączysz z RX i TX? nie ma takiej potrzeby.
Ponieważ po podłączeniu nie było oznak życia, sprawdziłem czy jest sygnał sterowania jak w poprzednim projekcie, i ten sygnał jest, diody na sterowniku się zapalają.
sprawdź swoje połączenia przycisków,
Tak jak pisałem przyciski jak wyzwalam ręcznie na nodemcu działają tylko wirtualnie w aplikacji tzn. roleta podnosi się i opada,
niestety brak reakcji silniczka :(
to chyba będzie coś z
ROLLER_SHUTTER_UP_RELAY_GPIO_VIRTUAL: Numer pinu wirtualnego przekaźnika do podnoszenia rolety
ROLLER_SHUTTER_DOWN_RELAY_GPIO_VIRTUAL: Numer pinu wirtualnego przekaźnika do opuszczania rolety
Napisz do mnie na WhatsApp 505661721
Pietras81
Posts: 2409
Joined: Sun Feb 17, 2019 6:56 am
Location: Osielsko
Been thanked: 1 time

Post

radzik_r wrote: Sun Mar 03, 2024 8:44 pm Dla jednego silnika podłączonego do WEMOSA pod GPIO 12, 13, 14, 15

viewtopic.php?p=175580#p175580

Testowałem na ESP32. Na Wemosie też powinien działać.
Dziś wgrałem powyższy soft i wszystko działa. Ja wgrywałem na chińskiego wemosa d1 mini więc tańszego modułu już chyba nie ma. Działa zarówno sterowanie z aplikacji jak i sterowanie z przycisków. Korzystałem z gotowej binarki.

Podziękowania do Radka za udostępnienie i kawał dobrej roboty.
https://pietras-81.aqi.eco/
kikan
Posts: 23
Joined: Tue Feb 09, 2021 3:59 pm

Post

radzik_r wrote: Sun Mar 03, 2024 8:44 pm Dla jednego silnika podłączonego do WEMOSA pod GPIO 12, 13, 14, 15

Testowałem na ESP32. Na Wemosie też powinien działać.

Code: Select all

/*
  Copyright (C) AC SOFTWARE SP. Z O.O.

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/* This example shows ESP82xx/ESP32 based device with simple WebInterface
   used to configure Wi-Fi parameters and Supla server connection.
   There is one RollerShutter, one Relay and 3 buttons configured.
   Two buttons are for roller shutter with Action Trigger.
   Third button is for controlling the relay and for switching module to
   config mode.
   After fresh installation, device will be in config mode. It will have its
   own Wi-Fi AP configured. You should connect to it with your mobile phone
   and open http://192.168.4.1 where you can configure the device.
   Status LED is also configured. Please adjust GPIOs to your HW.
*/


#include "Stepper_28BYJ_48.h"

// piny pod które podłączony jest Stepper_28BYJ_48 //
#define PIN1 12
#define PIN2 13
#define PIN3 14
#define PIN4 15


Stepper_28BYJ_48 stepper(PIN1, PIN2, PIN3, PIN4);

#define STATUS_LED_GPIO                        2
#define ROLLER_SHUTTER_UP_RELAY_GPIO_VIRTUAL   0 // pin wirtualny
#define ROLLER_SHUTTER_DOWN_RELAY_GPIO_VIRTUAL 1 // pin wirtualny
#define BUTTON_UP_GPIO                         4
#define BUTTON_DOWN_GPIO                       5
#define BUTTON_CFG_GPIO                        0

#include <SuplaDevice.h>
#include <supla/network/esp_wifi.h>
#include <supla/control/roller_shutter.h>
//#include <supla/control/relay.h>
#include <supla/control/button.h>
//#include <supla/control/action_trigger.h>
#include <supla/device/status_led.h>
#include <supla/storage/littlefs_config.h>
#include <supla/network/esp_web_server.h>
#include <supla/network/html/device_info.h>
#include <supla/network/html/protocol_parameters.h>
#include <supla/network/html/status_led_parameters.h>
#include <supla/network/html/wifi_parameters.h>
#include <supla/device/supla_ca_cert.h>
#include <supla/events.h>
#include <supla/io.h>

// Choose where Supla should store roller shutter data in persistent memory
// We recommend to use external FRAM memory
#include <supla/storage/eeprom.h>
Supla::Eeprom eeprom;
// #include <supla/storage/fram_spi.h>
// Supla::FramSpi fram(STORAGE_OFFSET);

Supla::ESPWifi wifi;
Supla::LittleFsConfig configSupla;

//Supla::Device::StatusLed statusLed(STATUS_LED_GPIO, true); // inverted state
Supla::Device::StatusLed statusLed(STATUS_LED_GPIO, false); // inverted state
Supla::EspWebServer suplaServer;


// HTML www component (they appear in sections according to creation
// sequence)
Supla::Html::DeviceInfo htmlDeviceInfo(&SuplaDevice);
Supla::Html::WifiParameters htmlWifi;
Supla::Html::ProtocolParameters htmlProto;
Supla::Html::StatusLedParameters htmlStatusLed;

Supla::Control::RollerShutter *rs = nullptr;


class VirtualExpander : public Supla::Io {
  public:
    VirtualExpander() : Supla::Io(false) {}
    void customDigitalWrite(int channelNumber, uint8_t pin, uint8_t val) override {
      VIRTUAL_VARIABLE[pin] = val;
    }
    int customDigitalRead(int channelNumber, uint8_t pin) override {
      return VIRTUAL_VARIABLE[pin];
    }
  private:
    bool VIRTUAL_VARIABLE[8];
};


void setup() {

  Serial.begin(115200);

  auto EX_OUTPUT = new VirtualExpander();

  // Channels configuration
  // CH 0 - Roller shutter
  rs = new Supla::Control::RollerShutter(EX_OUTPUT, ROLLER_SHUTTER_UP_RELAY_GPIO_VIRTUAL, ROLLER_SHUTTER_DOWN_RELAY_GPIO_VIRTUAL, true);

  // Buttons configuration
  auto buttonOpen  = new Supla::Control::Button(BUTTON_UP_GPIO,   true, true);
  auto buttonClose = new Supla::Control::Button(BUTTON_DOWN_GPIO, true, true);
  auto buttonCfg   = new Supla::Control::Button(BUTTON_CFG_GPIO,  true, true);

  buttonOpen->addAction(Supla::OPEN_OR_STOP, *rs, Supla::ON_CLICK_1);
  buttonOpen->setHoldTime(1000);
  buttonOpen->setMulticlickTime(300);

  buttonClose->addAction(Supla::CLOSE_OR_STOP, *rs, Supla::ON_CLICK_1);
  buttonClose->setHoldTime(1000);
  buttonClose->setMulticlickTime(300);

  buttonCfg->configureAsConfigButton(&SuplaDevice);

  // configure defualt Supla CA certificate
  SuplaDevice.setSuplaCACert(suplaCACert);
  SuplaDevice.setSupla3rdPartyCACert(supla3rdCACert);

  SuplaDevice.begin();

}

void loop() {
  SuplaDevice.iterate();

  static bool x;
  switch ( rs->getCurrentDirection() ) {
    case  0: // RS STOP
      if (x) {
        digitalWrite(PIN1, LOW); digitalWrite(PIN2, LOW); digitalWrite(PIN3, LOW); digitalWrite(PIN4, LOW);
      }
      break;
    case  1: // RS DOWN
      x = 1;
      stepper.step(-1);
      break;
    case  2: // RS UP
      x = 1;
      stepper.step(1);
      break;
  }
}
Hej
Mam Wemos d1 mini i do tego silniczek 28BYJ-48 5V DC z ULN2003

czy to zadziała na takim zestawie ?

Return to “Pomoc”