Rozwój biblioteki dla arduino

Masz pomysł na funkcjonalność lub koncepcję na rozwój projektu. Opisz wszystko tutaj.
arturkmat
Posts: 40
Joined: Wed Jul 05, 2017 9:45 pm
Location: Ostrzeszów

Post

Z Arduino to akurat wiem ale z poziomu aplikacji supla
User avatar
pzygmunt
Posts: 20302
Joined: Tue Jan 19, 2016 9:26 am
Location: Paczków
Been thanked: 59 times

Post

Rozumiem, że chcesz kontrolować każdy led z osobna. Być może kiedyś takie rozwiązanie wprowadzimy. Kwestia pomysłu na UI.
SUPLA.... Nareszcie w domu.
arturkmat
Posts: 40
Joined: Wed Jul 05, 2017 9:45 pm
Location: Ostrzeszów

Post

Tak zgadza się tutaj akurat znalazłem gotowe pomysły już:
- https://www.youtube.com/watch?v=faIIC5cTiiQ
- https://www.youtube.com/watch?v=rc6QVHKAXBs
User avatar
pzygmunt
Posts: 20302
Joined: Tue Jan 19, 2016 9:26 am
Location: Paczków
Been thanked: 59 times

Post

No to praktycznie mamy wszystko tylko kwestia przesłania przez urządzenie deklaracji jakie efekty potrafi robić i w UI wyświetlać listę do wyboru.
SUPLA.... Nareszcie w domu.
Ryrzy
Posts: 148
Joined: Tue Nov 07, 2017 10:40 am

Post

trzeba przyznać ze obsługa tych ledów byłaby super, na pewno w UI musiała by być opcja wpisania ilości ledów na taśmie/płytce :)
arturkmat
Posts: 40
Joined: Wed Jul 05, 2017 9:45 pm
Location: Ostrzeszów

Post

Co do efektów to efekt tęczy i płynnego przełaczania koloru powinien wystarczyć a gdyby ktos chciał jakoś inaczej steować to mozna zrobić skrypt ;-)
User avatar
shimano73
Posts: 2174
Joined: Sun Feb 28, 2016 12:27 pm
Location: Orzesze
Been thanked: 1 time

Post

A kiedy moznaby sie spodziewać aktualizacji biblioteki dla arduino ?
W elektronice jak nie wiadomo o co chodzi to zwykle chodzi o zasilanie

Wezmę udział w Supla Offline Party 2024 :)
arturkmat
Posts: 40
Joined: Wed Jul 05, 2017 9:45 pm
Location: Ostrzeszów

Post

Próbowałem dodać obsługę przycisku do tej biblioteki tylko powstał mały problem po wgraniu tego kodu działa sterowanie pinem tylko poprzez przycisk z poziomu aplikacji tylko raz mignie :-/
Wgrywałem tego sketcha do ESP8266. Jak przerobić tego sketcha aby mógł sterować przyciskiem i suplą jednocześnie?

Code: Select all

/**
 * Supla.org NodeMCU WiFi minimal example
 * Author: Programistyk - Kamil Kaminski <[email protected]>
 * 
 * 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 <DHT.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>

#define DHTPIN 16
#define DHTTYPE DHT11
 
// Setup a DHT instance
DHT dht(DHTPIN, DHTTYPE);


// DS18B20 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;
    }

}

WiFiClient client;

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

void setup() {
  Serial.begin(115200);
  delay(10);
  dht.begin(); 
  pinMode(15,INPUT);
  pinMode(2,INPUT_PULLUP);
  pinMode(12,INPUT_PULLUP);

  SuplaDevice.setTemperatureHumidityCallback(&get_temperature_and_humidity);

  // Replace the falowing GUID
  char GUID[SUPLA_GUID_SIZE] = {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx};
  // with GUID that you can retrieve from https://www.supla.org/arduino/get-guid

  // Ethernet MAC address
  uint8_t mac[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

  /*
   * 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.
   */
    
  // Przekaźniki
  SuplaDevice.addRelay(5);           // 44 - Pin number where the relay is connected      
  SuplaDevice.addRelay(4);
  SuplaDevice.addRelay(14);
  SuplaDevice.addRelay(13);
  SuplaDevice.addRelay(15);

  SuplaDevice.addSensorNO(A0, true);
  
  // Rolety
  //SuplaDevice.addRollerShutterRelays(46,   
//                                     47, true); 

                               // Call SuplaDevice.addSensorNO(A0, true) with an extra "true" parameter
                               // to enable the internal pull-up resistor


  // Sensor normalnie-otwarty
//SuplaDevice.addSensorNO(A1); // A1 - Pin number where the sensor is connected


  // czujnik temp/wilg
 SuplaDevice.addDHT11();
  // SuplaDevice.addAM2302();
  // SuplaDevice.addDHT22();

  SuplaDevice.begin(GUID,              // Global Unique Identifier 
                    mac,               // Ethernet MAC address
                    "xxxx",  // SUPLA server address
                    xxxx,                 // Location ID 
                    "xxxx");               // Location Password

}

void loop() {
  SuplaDevice.iterate();
if(digitalRead(15)==HIGH){
TSD_SuplaChannelNewValue value;
value.SenderID = 0;
value.ChannelNumber = 2892; // należy wskazać numer kanału na którym jest przekaźnik
value.DurationMS = 0; 
value.value[0] = 1; // Załączony = 1, Wyłączony = 0
SuplaDevice.channelSetValue(&value);
}
 int przycisk = digitalRead(16); //odczytujemy stan przycisku
  if(przycisk == HIGH) { //jesli przycisk nie jest wcisniety
    digitalWrite(13, LOW); //dioda ma byc zgaszona
  }
  else //w przeciwnym wypadku
  {
    digitalWrite(13, HIGH); //dioda ma sie swiecic
  }
}

// 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 = NULL;
          cb.get_temperature_and_humidity = NULL;
          cb.get_rgbw_value = NULL;
          cb.set_rgbw_value = NULL;
          
          return cb;
}
Last edited by arturkmat on Mon Nov 13, 2017 6:38 pm, edited 1 time in total.
User avatar
shimano73
Posts: 2174
Joined: Sun Feb 28, 2016 12:27 pm
Location: Orzesze
Been thanked: 1 time

Post

Dlaczego masz value.ChannelNumber = 2892, używasz tyle kanałów ?
Wg mnie powinno być 4 jeśli bez czujnika temperatury .
Używasz czujnika temperatury ?
Masz zdefiniowany pin 16 jaki 1-wire, a pętli loop odczytujesz stan PINu 16
W elektronice jak nie wiadomo o co chodzi to zwykle chodzi o zasilanie

Wezmę udział w Supla Offline Party 2024 :)
User avatar
shimano73
Posts: 2174
Joined: Sun Feb 28, 2016 12:27 pm
Location: Orzesze
Been thanked: 1 time

Post

A i jak wstaniesz kod wygumuj swoje dane ssid, hasło bo jeszcze lotos dla ja..j będzie sterował twoja siecią 😁
W elektronice jak nie wiadomo o co chodzi to zwykle chodzi o zasilanie

Wezmę udział w Supla Offline Party 2024 :)

Return to “Pomysły i koncepcje”