Mam jeszcze pytanie.
Jakie linie kodu trzeba wkleić aby sterować innymi rzeczami?
np. RGB, oświetleniem itp.
jest gdzieś na forum to opisane?
Sterowanie roletami / przekaźnikami - Arduino Mega
-
pzygmunt
- Posts: 20302
- Joined: Tue Jan 19, 2016 9:26 am
- Location: Paczków
- Been thanked: 59 times
-
nowy1
- Posts: 339
- Joined: Fri Jul 01, 2016 11:51 am
- Location: Warszawa
próbowałem dodac dwa kody rgb i sterowanie rolet ale mi nie rozpoznaje urządzenia wtedy
Code: Select all
#include <SPI.h>
#include <Ethernet.h>
#include <SuplaDevice.h>
/*
* SUPLA DEVICE - ARDUINO - ETHERNET SHIELD & RGBW
* Author: Przemyslaw Zygmunt <[email protected]>
* Youtube: https://youtu.be/FE9tqzTjmA4
*/
#define RED_PIN 44
#define GREEN_PIN 45
#define BLUE_PIN 46
#define BRIGHTNESS_PIN 7
#define COLOR_BRIGHTNESS_PIN 8
unsigned char _red = 0;
unsigned char _green = 255;
unsigned char _blue = 0;
unsigned char _color_brightness = 0;
unsigned char _brightness = 0;
void get_rgbw_value(int channelNumber, unsigned char *red, unsigned char *green, unsigned char *blue, unsigned char *color_brightness, unsigned char *brightness) {
*brightness = _brightness;
*color_brightness= _color_brightness;
*red = _red;
*green = _green;
*blue = _blue;
}
void set_rgbw() {
analogWrite(BRIGHTNESS_PIN, (_brightness * 255) / 100);
analogWrite(COLOR_BRIGHTNESS_PIN, (_color_brightness * 255) / 100);
analogWrite(RED_PIN, _red);
analogWrite(GREEN_PIN, _green);
analogWrite(BLUE_PIN, _blue);
}
void set_rgbw_value(int channelNumber, unsigned char red, unsigned char green, unsigned char blue, unsigned char color_brightness, unsigned char brightness) {
_brightness = brightness;
_color_brightness= color_brightness;
_red = red;
_green = green;
_blue = blue;
set_rgbw();
}
void suplaDigitalWrite(int channelNumber, uint8_t pin, uint8_t val) {
digitalWrite(pin, val);
if ( pin == 3 )
digitalWrite(5, val);
}
void setup() {
SuplaDevice.setDigitalWriteFuncImpl(&suplaDigitalWrite);
Serial.begin(9600);
set_rgbw();
// Set RGBW callbacks
SuplaDevice.setRGBWCallbacks(&get_rgbw_value, &set_rgbw_value);
// Replace the falowing GUID
char GUID[SUPLA_GUID_SIZE] = {0000000};
// with GUID that you can retrieve from https://www.supla.org/arduino/get-guid
// Ethernet MAC address
uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
/*
* 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.
*/
// CHANNEL3 - TWO RELAYS (Roller shutter operation)
//SuplaDevice.addRollerShutterRelays(3, // 46 - Pin number where the 1st relay is connected
10); // 47 - Pin number where the 2nd relay is connected
CHANNEL0 - RGB controller and dimmer (RGBW)
SuplaDevice.addRgbControllerAndDimmer();
// SuplaDevice.addRgbController();
// SuplaDevice.addDimmer();
/*
* SuplaDevice Initialization.
* Server address, LocationID and LocationPassword are available at https://cloud.supla.org
* If you do not have an account, you can create it at https://cloud.supla.org/account/create
* SUPLA and SUPLA CLOUD are free of charge
*
*/
SuplaDevice.begin(GUID, // Global Unique Identifier
mac, // Ethernet MAC address
"svr1.supla.org", // SUPLA server address
0, // Location ID
"02"); // Location Password
}
void loop() {
SuplaDevice.iterate();
}-
nowy1
- Posts: 339
- Joined: Fri Jul 01, 2016 11:51 am
- Location: Warszawa
pzygmunt wrote:Co znaczy nie rozpoznaje ? Jaki komunikat w konsoli ?
kompiluje sie normalnie ,ale na Supla Cloud widzi jaku wyłączone urządzenie ,
-
furia
- Posts: 33
- Joined: Sun May 08, 2016 5:59 pm
Zmień GIUD, ID i Hasło i sprobuj tego...
mi się kompiluje - nie sprawdzałem czy widzi na SUPLI
mi się kompiluje - nie sprawdzałem czy widzi na SUPLI
Code: Select all
#include <SPI.h>
#include <Ethernet.h>
#include <SuplaDevice.h>
/*
* SUPLA DEVICE - ARDUINO - ETHERNET SHIELD
* Author: Przemyslaw Zygmunt <[email protected]>
*
*/
#define RED_PIN 44
#define GREEN_PIN 45
#define BLUE_PIN 46
#define BRIGHTNESS_PIN 7
#define COLOR_BRIGHTNESS_PIN 8
unsigned char _red = 0;
unsigned char _green = 255;
unsigned char _blue = 0;
unsigned char _color_brightness = 0;
unsigned char _brightness = 0;
void get_rgbw_value(int channelNumber, unsigned char *red, unsigned char *green, unsigned char *blue, unsigned char *color_brightness, unsigned char *brightness) {
*brightness = _brightness;
*color_brightness= _color_brightness;
*red = _red;
*green = _green;
*blue = _blue;
}
void set_rgbw() {
analogWrite(BRIGHTNESS_PIN, (_brightness * 255) / 100);
analogWrite(COLOR_BRIGHTNESS_PIN, (_color_brightness * 255) / 100);
analogWrite(RED_PIN, _red);
analogWrite(GREEN_PIN, _green);
analogWrite(BLUE_PIN, _blue);
}
void set_rgbw_value(int channelNumber, unsigned char red, unsigned char green, unsigned char blue, unsigned char color_brightness, unsigned char brightness) {
_brightness = brightness;
_color_brightness= color_brightness;
_red = red;
_green = green;
_blue = blue;
set_rgbw();
}
void setup() {
Serial.begin(9600);
set_rgbw();
// Set RGBW callbacks
SuplaDevice.setRGBWCallbacks(&get_rgbw_value, &set_rgbw_value);
// Replace the falowing GUID
char GUID[SUPLA_GUID_SIZE] = {0000000000000000000000000000000000000000000000000000000000000};
// with GUID that you can retrieve from https://www.supla.org/arduino/get-guid
// Ethernet MAC address
uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
/*
* 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 - RELAY
SuplaDevice.addRgbControllerAndDimmer();
SuplaDevice.addRollerShutterRelays(23, 25, true);
SuplaDevice.addRollerShutterRelays(27, 29, true);
SuplaDevice.addRollerShutterRelays(31, 33, true);
SuplaDevice.addRollerShutterRelays(35, 37, true);
SuplaDevice.addRollerShutterRelays(39, 41, true);
/*
* SuplaDevice Initialization.
* Server address, LocationID and LocationPassword are available at https://cloud.supla.org
* If you do not have an account, you can create it at https://cloud.supla.org/account/create
* SUPLA and SUPLA CLOUD are free of charge
*
*/
SuplaDevice.begin(GUID, // Global Unique Identifier
mac, // Ethernet MAC address
"svr1.supla.org", // SUPLA server address
xxxx, // Location ID - TU WKLEJASZ SWÓJ ID
"xxxx"); // Location Password - W NAWIASIE WKLEJASZ HASŁO
}
void loop() {
SuplaDevice.iterate();
}-
nowy1
- Posts: 339
- Joined: Fri Jul 01, 2016 11:51 am
- Location: Warszawa
furia wrote:Zmień GIUD, ID i Hasło i sprobuj tego...
mi się kompiluje - nie sprawdzałem czy widzi na SUPLICode: Select all
#include <SPI.h> #include <Ethernet.h> #include <SuplaDevice.h> /* * SUPLA DEVICE - ARDUINO - ETHERNET SHIELD * Author: Przemyslaw Zygmunt <[email protected]> * */ #define RED_PIN 44 #define GREEN_PIN 45 #define BLUE_PIN 46 #define BRIGHTNESS_PIN 7 #define COLOR_BRIGHTNESS_PIN 8 unsigned char _red = 0; unsigned char _green = 255; unsigned char _blue = 0; unsigned char _color_brightness = 0; unsigned char _brightness = 0; void get_rgbw_value(int channelNumber, unsigned char *red, unsigned char *green, unsigned char *blue, unsigned char *color_brightness, unsigned char *brightness) { *brightness = _brightness; *color_brightness= _color_brightness; *red = _red; *green = _green; *blue = _blue; } void set_rgbw() { analogWrite(BRIGHTNESS_PIN, (_brightness * 255) / 100); analogWrite(COLOR_BRIGHTNESS_PIN, (_color_brightness * 255) / 100); analogWrite(RED_PIN, _red); analogWrite(GREEN_PIN, _green); analogWrite(BLUE_PIN, _blue); } void set_rgbw_value(int channelNumber, unsigned char red, unsigned char green, unsigned char blue, unsigned char color_brightness, unsigned char brightness) { _brightness = brightness; _color_brightness= color_brightness; _red = red; _green = green; _blue = blue; set_rgbw(); } void setup() { Serial.begin(9600); set_rgbw(); // Set RGBW callbacks SuplaDevice.setRGBWCallbacks(&get_rgbw_value, &set_rgbw_value); // Replace the falowing GUID char GUID[SUPLA_GUID_SIZE] = {0000000000000000000000000000000000000000000000000000000000000}; // with GUID that you can retrieve from https://www.supla.org/arduino/get-guid // Ethernet MAC address uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05}; /* * 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 - RELAY SuplaDevice.addRgbControllerAndDimmer(); SuplaDevice.addRollerShutterRelays(23, 25, true); SuplaDevice.addRollerShutterRelays(27, 29, true); SuplaDevice.addRollerShutterRelays(31, 33, true); SuplaDevice.addRollerShutterRelays(35, 37, true); SuplaDevice.addRollerShutterRelays(39, 41, true); /* * SuplaDevice Initialization. * Server address, LocationID and LocationPassword are available at https://cloud.supla.org * If you do not have an account, you can create it at https://cloud.supla.org/account/create * SUPLA and SUPLA CLOUD are free of charge * */ SuplaDevice.begin(GUID, // Global Unique Identifier mac, // Ethernet MAC address "svr1.supla.org", // SUPLA server address xxxx, // Location ID - TU WKLEJASZ SWÓJ ID "xxxx"); // Location Password - W NAWIASIE WKLEJASZ HASŁO } void loop() { SuplaDevice.iterate(); }
Mi też nawet twój kod sie kompiluje ,po wgrani nie łaczy sie z Suplą cloud
-
furia
- Posts: 33
- Joined: Sun May 08, 2016 5:59 pm
-
nowy1
- Posts: 339
- Joined: Fri Jul 01, 2016 11:51 am
- Location: Warszawa
