Arduino Mega i pamięć FRAM
-
Maniek913
- Posts: 594
- Joined: Thu Feb 22, 2018 9:46 pm
- Been thanked: 3 times
Mam problem z kompilacją dla płytki mega (biblioteki) i druga sprawa: jak dodać kolejne rolety?
mój kod:
mój kod:
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.
*/
#include <SPI.h>
#include <SuplaDevice.h>
#include <supla/control/roller_shutter.h>
#include <supla/control/button.h>
#include <supla/storage/fram_spi.h>
// #include <supla/storage/eeprom.h>
#define SUPLA_STORAGE_OFFSET 0
#define FRAM_CS 53 // pin for FRAM CS
Supla::FramSpi fram(FRAM_CS, SUPLA_STORAGE_OFFSET);
Supla::FramSpi fram(52, 50, 51, FRAM_CS, SUPLA_STORAGE_OFFSET); // <- sofrware spi, piny (SCK, MISO, MOSI, CS)
// Supla::Eeprom fram(SUPLA_STORAGE_OFFSET);
// Choose proper network interface for your card:
Arduino Mega with EthernetShield W5100:
#include <supla/network/ethernet_shield.h>
// Ethernet MAC address
uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
Supla::EthernetShield ethernet(mac);
//
// ESP8266 based board:
// #include <supla/network/esp_wifi.h>
// Supla::ESPWifi wifi("your_wifi_ssid", "your_wifi_password");
//
void setup() {
Serial.begin(115200);
// Replace the falowing GUID with value that you can retrieve from https://www.supla.org/arduino/get-guid
char GUID[SUPLA_GUID_SIZE] = {mój guid};
// Replace the following AUTHKEY with value that you can retrieve from: https://www.supla.org/arduino/get-authkey
char AUTHKEY[SUPLA_AUTHKEY_SIZE] = {mój klucz};
Supla::Control::RollerShutter *rs = new Supla::Control::RollerShutter(22, 23, false);
Supla::Control::Button *buttonOpen = new Supla::Control::Button(11, true, true);
Supla::Control::Button *buttonClose = new Supla::Control::Button(12, true, true);
buttonOpen->willTrigger(*rs, Supla::ON_PRESS, Supla::OPEN_OR_STOP);
buttonClose->willTrigger(*rs, Supla::ON_PRESS, Supla::CLOSE_OR_STOP);
SuplaDevice.begin(GUID, // Global Unique Identifier
"svrx.supla.org", // SUPLA server address
"mój mail", // Email address used to login to Supla Cloud
AUTHKEY); // Authorization key
}
void loop() {
SuplaDevice.iterate();Code: Select all
Arduino:1.8.13 (Windows Store 1.8.42.0) (Windows 10), Płytka:"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
Rolety2:33:2: error: 'Arduino' does not name a type; did you mean 'Arduino_h'?
Arduino Mega with EthernetShield W5100:
^~~~~~~
Arduino_h
In file included from C:\Users\damia\Documents\Arduino\libraries\SuplaDevice\src/supla/network/ethernet_shield.h:21:0,
from C:\Users\damia\Desktop\Rolety na arduinoMega\Rolety2\Rolety2.ino:34:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\Ethernet\src/Ethernet.h:214:38: error: expected class-name before '{' token
class EthernetClient : public Client {
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\Ethernet\src/Ethernet.h:245:15: error: type 'Print' is not a base type for type 'EthernetClient'
using Print::write;
exit status 1
'Arduino' does not name a type; did you mean 'Arduino_h'?-
lukfud
- Posts: 2480
- Joined: Thu Nov 23, 2017 11:33 pm
- Location: Warszawa
- Has thanked: 13 times
- Been thanked: 11 times
Zakomentuj tą linię:
Code: Select all
Arduino Mega with EthernetShield W5100:https://www.facebook.com/groups/supladiy
https://www.facebook.com/groups/suplazamel
https://www.facebook.com/groups/suplaauraton
https://smartnerzeczy.pl
https://www.facebook.com/groups/suplazamel
https://www.facebook.com/groups/suplaauraton
https://smartnerzeczy.pl
-
Maniek913
- Posts: 594
- Joined: Thu Feb 22, 2018 9:46 pm
- Been thanked: 3 times
WielkiedDzięki za szybką pomoc - działa !!
Testuję dalej, na razie przekaźniki pracują w odwrotnej logice i nie wiem jak dopisać pozostałe rolety.
Nie działa również pamięć pozycji rolety i kalibracji :
Testuję dalej, na razie przekaźniki pracują w odwrotnej logice i nie wiem jak dopisać pozostałe rolety.
Nie działa również pamięć pozycji rolety i kalibracji :
Code: Select all
10:33:20.630 -> Supla - starting initialization
10:33:20.630 -> Storage: FRAM found
10:33:20.630 -> Storage initialization
10:33:20.665 -> readStorage: 8; Read: [53 55 50 4C 41 1 0 0 ]
10:33:20.665 -> Storage: Number of sections 0
10:33:20.665 -> Connecting to network...
10:33:26.179 -> DHCP connection result: 1
10:33:26.179 -> localIP: 192.168.1.131
10:33:26.179 -> subnetMask: 255.255.255.0
10:33:26.179 -> gatewayIP: 192.168.1.1
10:33:26.179 -> dnsServerIP: 91.192.144.15
10:33:26.179 -> Using Supla protocol version 12
10:33:26.179 -> Warning! Attempt to read state outside of section size
10:33:26.179 -> Current status: [7] SuplaDevice initialized
10:33:26.179 -> Initialization of elementStateOffset: 8
10:33:26.179 -> Update Storage preamble
10:33:26.213 -> Wrote 8 bytes to storage
10:33:26.213 -> Wrote 9 bytes to storage
10:33:26.213 -> Wrote 7 bytes to storage
10:33:26.213 -> Current status: [9] Not connected to Supla server
10:33:26.213 -> Establishing connection with: svr9.supla.org (port: 2015)
10:33:26.281 -> Connected to Supla Server
10:33:26.281 -> Current status: [10] Register in progress
10:33:26.281 -> Sending: [53 55 50 4C 41 C 1 0 0 0 45 0 0 0 61 2 0 0 64 61 6D 69 61 6E 32 30 33 40 6F 32 2E 70 6C 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 54 B 0 0 10 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ]
10:33:26.419 -> Sending: [53 55 50 4C 41 ]
10:33:26.454 -> Received: [53 55 50 4C 41 C 1 0 0 0 46 0 0 0 7 0 0 0 3 0 0 0 78 C 1 53 55 50 4C 41 ]
10:33:26.454 -> Device registered (activity timeout 120 s, server version: 12, server min version: 1)
10:33:26.454 -> Current status: [17] Registered and ready.
10:33:26.454 -> Changing activity timeout to 30
10:33:26.454 -> Sending: [53 55 50 4C 41 C 2 0 0 0 D2 0 0 0 1 0 0 0 1E ]
10:33:26.454 -> Sending: [53 55 50 4C 41 ]
10:33:26.488 -> Received: [53 55 50 4C 41 C 2 0 0 0 DC 0 0 0 3 0 0 0 1E A F0 53 55 50 4C 41 ]
10:33:26.488 -> Activity timeout set to 30 s
10:33:27.215 -> Wrote 9 bytes to storage
10:33:27.215 -> Wrote 7 bytes to storage
10:33:28.219 -> Wrote 9 bytes to storage
10:33:28.219 -> Wrote 7 bytes to storage
10:33:29.223 -> Wrote 9 bytes to storage
10:33:29.223 -> Wrote 7 bytes to storage
10:33:30.222 -> Wrote 9 bytes to storage
10:33:30.256 -> Wrote 7 bytes to storage
10:33:31.254 -> Wrote 9 bytes to storage
........
po restarcie:
10:39:36.417 -> Wrote 7 bytes to storage
10:39:37.281 -> Received: [53 55 50 4C 41 C 3 0 0 0 6E 0 0 0 11 0 0 0 72 13 0 0 0 32 0 32 0 6E 0 0 0 0 ]
10:39:37.281 -> Received: [0 0 0 53 55 50 4C 41 ]
10:39:37.281 -> RollerShutter[0] new time settings received. Opening time: 5000 ms; closing time: 5000 ms. Starting calibration...
10:39:37.281 -> RollerShutter[0] new value from server: 100
10:39:37.316 -> Calibration: closing
10:39:37.316 -> Calibration time: 5500
10:39:37.316 -> Channel(0) value changed to -1
10:39:37.316 -> Sending: [53 55 50 4C 41 C 3 0 0 0 64 0 0 0 9 0 0 0 0 FF FF 0 0 0 0 0 0 ]
10:39:37.316 -> Sending: [53 55 50 4C 41 ]
10:39:37.419 -> Wrote 9 bytes to storage
Last edited by Maniek913 on Wed Sep 09, 2020 8:48 am, edited 1 time in total.
-
lukfud
- Posts: 2480
- Joined: Thu Nov 23, 2017 11:33 pm
- Location: Warszawa
- Has thanked: 13 times
- Been thanked: 11 times
Powielasz poniższe linie zmieniając gpio i nazwy wskaźników *rs, *buttonOpen i *buttonClose, z "_0" na np. "_1"":
Logikę przekaźnika zmienisz usuwając "false"
Code: Select all
Supla::Control::RollerShutter *rs_0 = new Supla::Control::RollerShutter(22, 23, false);
Supla::Control::Button *buttonOpen_0 = new Supla::Control::Button(11, true, true);
Supla::Control::Button *buttonClose_0 = new Supla::Control::Button(12, true, true);
buttonOpen_0->willTrigger(*rs_0, Supla::ON_PRESS, Supla::OPEN_OR_STOP);
buttonClose_0->willTrigger(*rs_0, Supla::ON_PRESS, Supla::CLOSE_OR_STOP);Code: Select all
Supla::Control::RollerShutter *rs_0 = new Supla::Control::RollerShutter(22, 23, false)https://www.facebook.com/groups/supladiy
https://www.facebook.com/groups/suplazamel
https://www.facebook.com/groups/suplaauraton
https://smartnerzeczy.pl
https://www.facebook.com/groups/suplazamel
https://www.facebook.com/groups/suplaauraton
https://smartnerzeczy.pl
-
klew
- Posts: 13911
- Joined: Thu Jun 27, 2019 12:16 pm
- Location: Wrocław
- Has thanked: 136 times
- Been thanked: 137 times
Ogólnie jeśli w logach będziesz widział powtarzające się "wrote X bytes", to znaczy, że coś nie działa zapis/odczyt. Te logi powinny się pojawić tylko po zmianie danych do zapisania i potem cisza.
Natomiast przed resetem też musisz wykonać jakąś operację z apki na rolecie, aby otrzymała czasy i zrobiła kalibrację. Dopiero po tym można robić reset i patrzeć na to co się dzieje. Ale u Ciebie ewidentnie coś się nie zapisuje poprawnie. Jeśli po usunięciu tej drugiej instancji "fram" ze SW SPI, problem będzie nadal występował to zmień tutaj (https://github.com/klew/arduino/blob/39 ... e.cpp#L269 ) "false" na "true" i wyślij do mnie logi z pierwszych 20-30 s działania urządzenia
Najlepsze suple dla Twojego domu 
-
lukfud
- Posts: 2480
- Joined: Thu Nov 23, 2017 11:33 pm
- Location: Warszawa
- Has thanked: 13 times
- Been thanked: 11 times
@klew, jeśli używam 320 bajtów to offset ustawiam na 321?
Code: Select all
#define SUPLA_STORAGE_OFFSET 321
Supla::Eeprom fram(SUPLA_STORAGE_OFFSET);https://www.facebook.com/groups/supladiy
https://www.facebook.com/groups/suplazamel
https://www.facebook.com/groups/suplaauraton
https://smartnerzeczy.pl
https://www.facebook.com/groups/suplazamel
https://www.facebook.com/groups/suplaauraton
https://smartnerzeczy.pl
