Strona 7 z 13

Re: Firmware do rolet dla silniczka krokowego

: śr cze 26, 2019 6:55 am
autor: wojtas567
Czy to jest gotowa binarka z konfiguratorem GUI? :)
tak

Po zalogowaniu wpisz w przeglądarce 192.168.4.1:81 i da się wejść :)

Re: Firmware do rolet dla silniczka krokowego

: śr cze 26, 2019 7:36 am
autor: kris.gie
wojtas567 pisze: śr cze 26, 2019 6:55 am
Czy to jest gotowa binarka z konfiguratorem GUI? :)
tak

Po zalogowaniu wpisz w przeglądarce 192.168.4.1:81 i da się wejść :)
Dzięki Ci, w końcu się udało, teraz działa jak należy :D :D :D

Re: Firmware do rolet dla silniczka krokowego

: pt cze 28, 2019 9:57 pm
autor: QLQ
michael pisze: czw maja 16, 2019 8:25 am Też miałem problemy, konkretnie z DHT22 - wywaliłem i jest OK

Kod: Zaznacz cały

/**
 * Supla.org NodeMCU WiFi minimal example
 * Author: Programistyk - Kamil Kaminski <kamil@programistyk.pl>
 * 
 * This example shows how to configure SuplaDevice for building for NodeMCU within Arduino IDE
 */


#include <srpc.h>
#include <log.h>
#include <eh.h>
#include <proto.h>
#include <IEEE754tools.h>
// We define our own ethernet layer
#define SUPLADEVICE_CPP
#include <SuplaDevice.h>
#include <lck.h>

#include <WiFiClient.h>
#include <ESP8266WiFiType.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiScan.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiServer.h>
#include <ESP8266WiFiGeneric.h>
#include <WiFiClientSecure.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiSTA.h>
#include <WiFiUdp.h>
//#include <DHT.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include "Stepper_28BYJ_48.h"

extern "C" {
#include "user_interface.h"
}

//#define DHTPIN 02    // Pin number
//#define DHTTYPE DHT22

// Setup a DHT instance
//DHT dht(DHTPIN, DHTTYPE);

// Setup a oneWire instance
OneWire oneWire(2);    // Pin number

// Pass oneWire reference to Dallas Temperature
DallasTemperature sensors(&oneWire);

WiFiClient client;
ADC_MODE(ADC_VCC);

int switch_1_pin = 1;                     // sterowanie silnikiem
int switch_2_pin = 3;                     // połączyć zworą z 4 i 5

Stepper_28BYJ_48 stepper(13,12,14,16);    // wyjście silnika

// Setup Supla connection
const char* ssid     = "wifi";
const char* password = "haslo";

// DHT22 Sensor read implementation
//void get_temperature_and_humidity(int channelNumber, double *temp, double *humidity) {

//    *temp = dht.readTemperature();
//    *humidity = dht.readHumidity();

//    if ( isnan(*temp) || isnan(*humidity) ) {
//      *temp = -275;
//      *humidity = -1;
//    }

//}

// DS18B20 Sensor read implementation
double get_temperature(int channelNumber, double last_val) {

    double t = -275;
    
      switch(channelNumber) {
        
        case 1:
               t = WiFi.RSSI();
               break;
        case 2: 
               t = ESP.getVcc() / 100.0;
               break;
       };

    return t;  
}

void setup() {
  Serial.begin(115200);
  delay(10);
  SuplaDevice.setName("Roleta");              // zmiana nazwy mdułu w supla
  pinMode(switch_1_pin,INPUT_PULLUP);
  pinMode(switch_2_pin,INPUT_PULLUP);

  // Init DHT library 
//  dht.begin(); 
  
  // Set temperature/humidity callback
//  SuplaDevice.setTemperatureHumidityCallback(&get_temperature_and_humidity);

  // Init DS18B20 library 
  sensors.begin();
  
  // Set temperature callback
  SuplaDevice.setTemperatureCallback(&get_temperature);
 
  // Replace the falowing GUID
  uint8_t mac[WL_MAC_ADDR_LENGTH];
  WiFi.macAddress(mac);
  char GUID[SUPLA_GUID_SIZE] = {0x20,0x19,0x05,0x10, 
                                        mac[WL_MAC_ADDR_LENGTH - 6], 
                                        mac[WL_MAC_ADDR_LENGTH - 5], 
                                        mac[WL_MAC_ADDR_LENGTH - 4], 
                                        mac[WL_MAC_ADDR_LENGTH - 3], 
                                        mac[WL_MAC_ADDR_LENGTH - 2], 
                                        mac[WL_MAC_ADDR_LENGTH - 1],
                                        0x01,0x12,0x34,0x56,0x78,0x90};

  // lub pobieramy identyfikator urządzenia ze strony https://www.supla.org/arduino/get-guid i wprowadzamy wiersz wyżej

  /*
   * Having your device already registered at cloud.supla.org,
   * you want to change CHANNEL sequence or remove any of them,
   * then you must also remove the device itself from cloud.supla.org.
   * Otherwise you will get "Channel conflict!" error.
   */
    
  // CHANNEL0 - DHT22 Sensor
//  SuplaDevice.addDHT22();

  // CHANNEL1,2 - DS (lub inne dane)
  SuplaDevice.addDS18B20Thermometer();
  SuplaDevice.addDS18B20Thermometer();

  // CHANNEL3 - TWO RELAYS (Roller shutter operation)
  SuplaDevice.addRollerShutterRelays(4,     // 46 - Pin number where the 1st relay is connected   
                                     5, true);    // 47 - Pin number where the 2nd relay is connected  

   //SuplaDevice.setRollerShutterButtons(3,    // 0 - Channel Number
   //                                   20,   // 20 - Pin where the 1st button is connected
   //                                   21);  // 21 - Pin where the 2nd button is connected

  // CHANNEL4 - Opening sensor (Normal Open)
 SuplaDevice.addSensorNO(2); // A0 - Pin number where the sensor is connected
                               // Call SuplaDevice.addSensorNO(A0, true) with an extra "true" parameter
                               // to enable the internal pull-up resistor


  SuplaDevice.begin(GUID,              // Global Unique Identifier
                    mac,               // Ethernet MAC address
                    "svr1.supla.org",  // SUPLA server address
                    1234,                 // Location ID
                    "haslo");               // Location Password



  Serial.println();
  Serial.println("Booting Sketch...");
  WiFi.mode(WIFI_AP_STA);
  WiFi.begin(ssid, password);
  WiFi.softAPdisconnect(true);                               // wyłączenie rozgłaszania sieci ESP
  wifi_station_set_hostname("E_Supla_roleta");       // zmiana zazwy ESP w sieci lokalnej

  while(WiFi.waitForConnectResult() != WL_CONNECTED){
    WiFi.begin(ssid, password);
    Serial.println("WiFi failed, retrying.");
  }

}


void loop() {
  SuplaDevice.iterate();
//  SuplaDevice.setTemperatureHumidityCallback(&get_temperature_and_humidity);
  Roletka();
}

// Supla.org ethernet layer
    int supla_arduino_tcp_read(void *buf, int count) {
        _supla_int_t size = client.available();
       
        if ( size > 0 ) {
            if ( size > count ) size = count;
            return client.read((uint8_t *)buf, size);
        };
    
        return -1;
    };
    
    int supla_arduino_tcp_write(void *buf, int count) {
        return client.write((const uint8_t *)buf, count);
    };
    
    bool supla_arduino_svr_connect(const char *server, int port) {
          return client.connect(server, 2015);
    }
    
    bool supla_arduino_svr_connected(void) {
          return client.connected();
    }
    
    void supla_arduino_svr_disconnect(void) {
         client.stop();
    }
    
    void supla_arduino_eth_setup(uint8_t mac[6], IPAddress *ip) {

       // Serial.println("WiFi init");
        WiFi.begin(ssid, password);

        while (WiFi.status() != WL_CONNECTED) {
            delay(500);
        //    Serial.print(".");
        }

        Serial.print("\nlocalIP: ");
        Serial.println(WiFi.localIP());
        Serial.print("subnetMask: ");
        Serial.println(WiFi.subnetMask());
        Serial.print("gatewayIP: ");
        Serial.println(WiFi.gatewayIP());
    }

SuplaDeviceCallbacks supla_arduino_get_callbacks(void) {
          SuplaDeviceCallbacks cb;
          
          cb.tcp_read = &supla_arduino_tcp_read;
          cb.tcp_write = &supla_arduino_tcp_write;
          cb.eth_setup = &supla_arduino_eth_setup;
          cb.svr_connected = &supla_arduino_svr_connected;
          cb.svr_connect = &supla_arduino_svr_connect;
          cb.svr_disconnect = &supla_arduino_svr_disconnect;
          cb.get_temperature = &get_temperature;
//          cb.get_temperature_and_humidity = get_temperature_and_humidity;
          cb.get_rgbw_value = NULL;
          cb.set_rgbw_value = NULL;
          
          return cb;
}

void Roletka() {
  
      if ( digitalRead(switch_1_pin) == LOW ) {
                stepper.step(-1);
        }

      if ( digitalRead(switch_2_pin) == LOW ) {
                stepper.step(1);
        }
 }
 
u mnie na Arduino poszło od "strzała" tylko #include "Stepper_28BYJ_48.h" musiałem pobrać

Re: Firmware do rolet dla silniczka krokowego

: pt cze 28, 2019 10:01 pm
autor: QLQ
Espablo pisze: czw maja 16, 2019 10:38 pm Ja u siebie mam zamiar wykorzystać zwykłe serwo tylko przerobione, żeby się kręciły do okoła. Sterowanie takim silnikiem jest tak jak przy zwykłych roletach. Plan mam taki, żeby zapiąć to do zwykłego łańcuszka bo bardzo mi się podobał projekt jaki widziałem już w internecie tego typu. Zaprojektowałem sobie już kółko do napędu ale niestety czasu brakło na kontynuację.
Moja drukarka 3D wypluła coś takiego
IMG_20190516_235500.jpg
Od razu uprzedzam, że nie testowałem tego serwa i nie wiem czy uciągnie te rolety, ale mam jeszcze kilka większych z mojego hexapoda i mogę je przetestować.
Też mi się wydaje to prostsze i łatwejsze bo serwo można podpiąć chyba bez tego "sterowniczka" bezpośrednio pod Np WeMos. Coś kolega z kodem zdziałał ?

Re: Firmware do rolet dla silniczka krokowego

: sob cze 29, 2019 9:49 am
autor: QLQ
Trochę się pobawiłem i przerobiłem (jeszcze nie w pełni) kod aby działał z esp8266 i serwem - tu akurat MG90S. Tak jak kolega @espablo pisła powyżej.
Proszę kod. Podpowiedzcie proszę jak zrobić aby kod sterował serwem nie w zakresie 0-180st tylko cały czas się kręciło np w prawo albo lewo w zależności od przycisku w apce lub fizycznego.


https://youtu.be/LkIUjIszsS0

Podłączenie:
.
IMG_20190629_115859.jpg
IMG_20190629_115859.jpg (156.92 KiB) Przejrzano 3575 razy

Kod: Zaznacz cały

/**
 * Supla.org NodeMCU WiFi minimal example
 * Author: Programistyk - Kamil Kaminski <kamil@programistyk.pl>
 * 
 * This example shows how to configure SuplaDevice for building for NodeMCU within Arduino IDE
 */


#include <srpc.h>
#include <log.h>
#include <eh.h>
#include <proto.h>
#include <IEEE754tools.h>
// We define our own ethernet layer
#define SUPLADEVICE_CPP
#include <SuplaDevice.h>
#include <lck.h>

#include <WiFiClient.h>
#include <ESP8266WiFiType.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiScan.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiServer.h>
#include <ESP8266WiFiGeneric.h>
#include <WiFiClientSecure.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiSTA.h>
#include <WiFiUdp.h>
#include "Stepper_28BYJ_48.h"
#include <Servo.h>

Servo myservo;
extern "C" {
#include "user_interface.h"
}

WiFiClient client;
ADC_MODE(ADC_VCC);
int pos;

// Setup Supla connection
const char* ssid     = "ssid";
const char* password = "k34345xxx9";


void setup() {
    
  Serial.begin(115200);

  pinMode(2,INPUT_PULLUP);
  pinMode(3,INPUT_PULLUP);

  myservo.attach(4); // pin sterujacy serwem
  myservo.write(0);
  Serial.println(pos);
  delay(10);
  
  
  SuplaDevice.setName("Roleta_R@F");                       // zmiana nazwy mdułu w supla
//  wifi_station_set_hostname("Roleta");                 // lub tak jeżeli górna nie zadziała
  WiFi.softAPdisconnect(true);                         // wyłączenie rozgłaszania sieci ESP
//  WiFi.setOutputPower(10);                             //Ograniczanie mocy wyjściowej (0 - 20.5)

  
   // Replace the falowing GUID
  uint8_t mac[WL_MAC_ADDR_LENGTH];
  WiFi.macAddress(mac);
  char GUID[SUPLA_GUID_SIZE] = {0x20,0x19,0x05,0x10, 
                                        mac[WL_MAC_ADDR_LENGTH - 6], 
                                        mac[WL_MAC_ADDR_LENGTH - 5], 
                                        mac[WL_MAC_ADDR_LENGTH - 4], 
                                        mac[WL_MAC_ADDR_LENGTH - 3], 
                                        mac[WL_MAC_ADDR_LENGTH - 2], 
                                        mac[WL_MAC_ADDR_LENGTH - 1],
                                        0x02,0x12,0x34,0x56,0x78,0x90};

  // lub pobieramy identyfikator urządzenia ze strony https://www.supla.org/arduino/get-guid i wprowadzamy wiersz wyżej

  /*
   * Having your device already registered at cloud.supla.org,
   * you want to change CHANNEL sequence or remove any of them,
   * then you must also remove the device itself from cloud.supla.org.
   * Otherwise you will get "Channel conflict!" error.
   */
    

  SuplaDevice.addRollerShutterRelays(1,         // 0 roleta dwa przekaźniki  
                                     3, true);  //  
  SuplaDevice.addSensorNO(2);                   // 1 czujnik krańcowy  Call SuplaDevice.addSensorNO(A0, true)
 

  SuplaDevice.begin(GUID,                       // Global Unique Identifier
                    mac,                        // Ethernet MAC address
                    "svr5.supla.org",           // SUPLA server address
                    34324,                       // Location ID
                    "3540");                    // Location Password

  SuplaDevice.setName("roleta R@F");          // zmiana nazwy mdułu w supla

}


void loop() {
  SuplaDevice.iterate();
  Roletka();
}

// Supla.org ethernet layer
    int supla_arduino_tcp_read(void *buf, int count) {
        _supla_int_t size = client.available();
       
        if ( size > 0 ) {
            if ( size > count ) size = count;
            return client.read((uint8_t *)buf, size);
        };
    
        return -1;
    };
    
    int supla_arduino_tcp_write(void *buf, int count) {
        return client.write((const uint8_t *)buf, count);
    };
    
    bool supla_arduino_svr_connect(const char *server, int port) {
          return client.connect(server, 2015);
    }
    
    bool supla_arduino_svr_connected(void) {
          return client.connected();
    }
    
    void supla_arduino_svr_disconnect(void) {
         client.stop();
    }
    
    void supla_arduino_eth_setup(uint8_t mac[6], IPAddress *ip) {

       // Serial.println("WiFi init");
        WiFi.begin(ssid, password);

        while (WiFi.status() != WL_CONNECTED) {
            delay(500);
        //    Serial.print(".");
        }

        Serial.print("\nlocalIP: ");
        Serial.println(WiFi.localIP());
        Serial.print("subnetMask: ");
        Serial.println(WiFi.subnetMask());
        Serial.print("gatewayIP: ");
        Serial.println(WiFi.gatewayIP());
    }

SuplaDeviceCallbacks supla_arduino_get_callbacks(void) {
          SuplaDeviceCallbacks cb;
          
          cb.tcp_read = &supla_arduino_tcp_read;
          cb.tcp_write = &supla_arduino_tcp_write;
          cb.eth_setup = &supla_arduino_eth_setup;
          cb.svr_connected = &supla_arduino_svr_connected;
          cb.svr_connect = &supla_arduino_svr_connect;
          cb.svr_disconnect = &supla_arduino_svr_disconnect;
//          cb.get_temperature = &get_temperature;
          cb.get_temperature_and_humidity = NULL;
          cb.get_rgbw_value = NULL;
          cb.set_rgbw_value = NULL;
          
          return cb;
}

void Roletka() {

 if(digitalRead(3) == LOW) {
    if (pos <= 190)
    {
      pos++;
      Serial.println(pos);
    }
    myservo.write(pos);
  }
  delay(2);
  
     if (digitalRead(1) == LOW){
    if (pos >= 0) 
    {
      pos--;
      Serial.println(pos);
    }
    myservo.write(pos);
  }
  delay(2);

 
 }

Re: Firmware do rolet dla silniczka krokowego

: sob cze 29, 2019 10:45 am
autor: shimano73
Program to jedno , serwo to drugie - Ono musi mieć możliwość obracania się do okoła, zwykle obraca się o jakiś kąt

Re: Firmware do rolet dla silniczka krokowego

: sob cze 29, 2019 10:51 am
autor: QLQ
shimano73 pisze: sob cze 29, 2019 10:45 am Program to jedno , serwo to drugie - Ono musi mieć możliwość obracania się do okoła, zwykle obraca się o jakiś kąt
No właśnie tam mend@ nie obraca się dookoła.

Re: Firmware do rolet dla silniczka krokowego

: sob cze 29, 2019 11:03 am
autor: shimano73
To trzeba go mechanicznie przerobić , gdzieś w necie były opisy

Re: Firmware do rolet dla silniczka krokowego

: ndz cze 30, 2019 11:18 am
autor: wojtas567
Musisz rozebrać u ściąć blokadę

Re: Firmware do rolet dla silniczka krokowego

: ndz cze 30, 2019 12:21 pm
autor: QLQ
wojtas567 pisze: ndz cze 30, 2019 11:18 am Musisz rozebrać u ściąć blokadę
..
Nie ma blokady. Jest tylko potencjometr w osi. Jak sie to usunie to kręci cały czas. Zmienia tylko kier obrotów jak klikam otwórz/zamknij. Nie nadaje się.