sto cercando di collegare un sensore DHT11 all'esp01 in mio possesso. Carico lo sketch riportato di seguito e nulla funge, nel senso che su soulissApp i valori reading sono NaN.
/ Let the IDE point to the Souliss framework
#include "SoulissFramework.h"
// Configure the framework
#include "bconf/MCU_ESP8266.h" // Load the code directly on the ESP8266
#include "conf/Gateway.h" // The main node is the Gateway, we have just one node
#include "conf/IPBroadcast.h"
// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID "xxxxxxx"
#define WiFi_Password "xxxxxxxxxxx"
// Include framework code and libraries
#include <ESP8266WiFi.h>
#include <EEPROM.h>
/*** All configuration includes should be above this line ***/
#include "Souliss.h"
// Include framework code and libraries
#include <SPI.h>
#include <DHT.h>
// Include sensor libraries (from Adafruit) Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
#define DHTPIN 1 // what digital pin we're connected to
/*** All configuration includes should be above this line ***/
#include "Souliss.h"
#define HUMIDITY 0 // Leave 2 slots for T58
#define TEMP0 2 // Leave 2 slots for T52
// DHT sensor DHT dht(DHTPIN, DHTTYPE); // for ESP8266 use
DHT dht(DHTPIN, DHTTYPE, 11);
void setup()
{
Initialize();
// Get the IP address from DHCP
GetIPAddress();
SetAsGateway(myvNet_dhcp); // Set this node as gateway for SoulissApp
dht.begin(); // initialize temperature sensor
Set_Humidity(HUMIDITY);
Set_Temperature(TEMP0);
}
void loop()
{
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
// Execute the code every 1 time_base_fast
FAST_10ms() {
// Just process communication as fast as the logics
ProcessCommunication();
}
// Process the other Gateway stuffs
FAST_GatewayComms();
}
EXECUTESLOW()
{
UPDATESLOW();
SLOW_10s() {
Logic_Humidity(HUMIDITY);
Logic_Temperature(TEMP0);
}
SLOW_50s() {
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
if (!isnan(humidity) || !isnan(temperature)) {
ImportAnalog(HUMIDITY, &humidity);
ImportAnalog(TEMP0, &temperature);
}
}
}
}