Ile czujników obsłuży Supla?
Czy korzystanie z Arduino IDE w jakiś sposób wpływa na tę ilość?
A teraz problem.
Gdy podłącze 1, góra 2 czujniki program zachowuje się normalnie. Wszystko chodzi.
Gdy podłączę ich więcej 3 czy 5 (a chcę podłączyć 21), program wariuje...
Co chwilę pojawia się Soft WDT Reset lub Exception(0) albo Exception(29) i tak w kółko.
Układ na razie jest na płytce stykowej i zasilany jest z zasilacza laboratoryjnego napięciem 3.3V (pobiera od 6mA do 10mA).
Programik jest prościutki, na razie tylko testuję sobie te czujniki.
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 <OneWire.h>
#include <DallasTemperature.h>
#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>
OneWire oneWire(2);
DallasTemperature sensors(&oneWire);
WiFiClient client;
// Setup Supla connection
const char* ssid = "XXXXXXXX";
const char* password = "********";
// DS18B20 Sensor read implementation
double get_temperature(int channelNumber, double last_val) {
double t = -275;
if ( sensors.getDeviceCount() > 0 )
{
sensors.requestTemperatures();
t = sensors.getTempCByIndex(channelNumber);
};
return t;
}
void setup() {
Serial.begin(74880);
delay(10);
// Replace the falowing GUID
char GUID[SUPLA_GUID_SIZE] = {0xF1,0x9B,0x71,0xC3,0x1C,0xD2,0x4C,0xD7,0x71,0x2E,0x1C,0x01,0xCB,0x19,0x9C,0x80};
// with GUID that you can retrieve from https://www.supla.org/arduino/get-guid
// Ethernet MAC address
uint8_t mac[6] = {0x3c, 0xf4, 0x31, 0x14, 0xfb, 0x17};
/*
* 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.
*/
// Init DS18B20 library
sensors.begin();
// CHANNEL0 - RELAY
//SuplaDevice.addRelay(2, true); // 44 - Pin number where the relay is connected
// Call SuplaDevice.addRelay(44, true) with an extra "true" parameter
// to enable "port value inversion"
// where HIGH == LOW, and LOW == HIGH
// CHANNEL1 - RELAY
// SuplaDevice.addRelay(45, true); // 45 - Pin number where the relay is connected
// CHANNEL3 - TWO RELAYS (Roller shutter operation)
//SuplaDevice.addRollerShutterRelays(46, // 46 - Pin number where the 1st relay is connected
// 47, true); // 47 - Pin number where the 2nd relay is connected
SuplaDevice.addDS18B20Thermometer();
SuplaDevice.addDS18B20Thermometer();
SuplaDevice.addDS18B20Thermometer();
SuplaDevice.addDS18B20Thermometer();
SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// SuplaDevice.addDS18B20Thermometer();
// CHANNEL4 - Opening sensor (Normal Open)
//SuplaDevice.addSensorNO(A0); // 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
// CHANNEL5 - Opening sensor (Normal Open)
//SuplaDevice.addSensorNO(2); // 2 - Pin number where the sensor is connected
// CHANNEL6 - DHT22 Sensor
// SuplaDevice.addDHT11();
// SuplaDevice.addAM2302();
// SuplaDevice.addDHT22();
SuplaDevice.begin(GUID, // Global Unique Identifier
mac, // Ethernet MAC address
"supla.*******", // SUPLA server address
1, // Location ID
"****"); // Location Password
}
void loop() {
SuplaDevice.iterate();
}
// 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;
}
Kod: Zaznacz cały
15:18:30.314 -> localIP: 172.16.144.100
15:18:30.314 -> subnetMask: 255.255.255.0
15:18:30.348 -> gatewayIP: 172.16.144.1 <<<<<<<
15:18:32.606 -> SuplaDevice initialized
15:18:32.606 -> Not connected
15:18:32.641 -> Register in progress
15:18:32.641 -> Registered and ready.
15:18:33.187 -> Value changed
15:18:33.732 -> Value changed
15:18:34.282 -> Value changed
15:18:34.420 ->
15:18:34.420 -> Soft WDT reset
15:18:34.420 ->
15:18:34.420 -> >>>stack>>>
15:18:34.420 ->
15:18:34.420 -> ctx: cont