Five module limit?

8 years 9 months ago #1875 by Sunspot
Five module limit? was created by Sunspot
I have combined the 4 relay sketch and the humidity temperature sketch as a test for later adding lots of I2C devices.
There seems to be a 5 module limit for one node.

with this code -
//  Serial.println("present S_HUM");
  esp.present(CHILD_ID_HUM, S_HUM);

//  Serial.println("present S_TEMP");
  esp.present(CHILD_ID_TEMP, S_TEMP);

          esp.present(1, S_DIGITAL_OUTPUT);
          esp.present(2, S_DIGITAL_OUTPUT);
          esp.present(3, S_DIGITAL_OUTPUT);
          esp.present(4, S_DIGITAL_OUTPUT);

The 5th present, Relay 4, does not create a module
When I put the H and T after the relays then the last module, Temperature, was ignored. In each case just 5 modules.

With the code above I can see the H and T and control 3 of the 4 relays perfectly.

The full sketch is
/*
 V2.0 - small fix
 
 Created by Igor Jarc <admin@iot-playground.com>
 See http://iot-playground.com for details
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.
 */
#include <Esp8266EasyIoT.h>
#include <SoftwareSerial.h> 
#include <DHT.h>  

#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define HUMIDITY_SENSOR_DIGITAL_PIN 2

#define SEND_INTERVAL  1000 * 30 // 30S  

        #define RELAY_1  6  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
        #define RELAY_ON 1  // GPIO value to write to turn on attached relay
        #define RELAY_OFF 0 // GPIO value to write to turn off attached relay

Esp8266EasyIoT esp; 

SoftwareSerial serialEsp(10, 11);


DHT dht;
float lastTemp;
float lastHum;

Esp8266EasyIoTMsg msgHum(CHILD_ID_HUM, V_HUM);
Esp8266EasyIoTMsg msgTemp(CHILD_ID_TEMP, V_TEMP);

unsigned long startTime;

void setup()
{
  serialEsp.begin(9600);
  Serial.begin(115200);  

  Serial.println("EasyIoTEsp init");

  //esp.begin(NULL, 3, &serialEsp, &Serial);
         esp.begin(incomingMessage, 3, &serialEsp, &Serial);

        
  //esp.begin(NULL, &serialEsp);
  dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 

  pinMode(13, OUTPUT);

          pinMode(RELAY_1, OUTPUT);
          pinMode(RELAY_1 + 1, OUTPUT);
          pinMode(RELAY_1 + 2, OUTPUT);
          pinMode(RELAY_1 + 3, OUTPUT);

          
//  Serial.println("present S_HUM");
  esp.present(CHILD_ID_HUM, S_HUM);

//  Serial.println("present S_TEMP");
  esp.present(CHILD_ID_TEMP, S_TEMP);

          esp.present(1, S_DIGITAL_OUTPUT);
          esp.present(2, S_DIGITAL_OUTPUT);
          esp.present(3, S_DIGITAL_OUTPUT);
          esp.present(4, S_DIGITAL_OUTPUT);

  startTime = millis()+SEND_INTERVAL;
}

void loop()
{  
            esp.process(); 
  while(!esp.process());

  if (IsTimeout())
  {
    startTime = millis();

    float temperature = dht.getTemperature();
    if (isnan(temperature)) {
      Serial.println("Failed reading temperature from DHT");
    } 
    else if (temperature != lastTemp) 
    {
      lastTemp = temperature;
      esp.send(msgTemp.set(temperature, 1));
      Serial.print("T: ");
      Serial.println(temperature);
    }
  
    while(!esp.process());
  
    float humidity = dht.getHumidity();
    if (isnan(humidity)) {
      Serial.println("Failed reading humidity from DHT");
    } 
    else if (humidity != lastHum) 
    {
      lastHum = humidity;
      esp.send(msgHum.set(humidity, 1));
      Serial.print("H: ");
      Serial.println(humidity);
    }
  }
}

boolean IsTimeout()
{
  unsigned long now = millis();
  if (startTime <= now)
  {
    if ( (unsigned long)(now - startTime )  < SEND_INTERVAL ) 
      return false;
  }
  else
  {
    if ( (unsigned long)(startTime - now) < SEND_INTERVAL ) 
      return false;
  }

  return true;
}

// below from 4 relays
void incomingMessage(const Esp8266EasyIoTMsg &message) {
  // We only expect one type of message from controller. But we better check anyway.

  Serial.println("New message");
  if (message.type==V_DIGITAL_VALUE) {
    // Change relay state
    digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);

    Serial.print("Incoming change for sensor:");
    Serial.print(message.sensor);
    Serial.print(", New status: ");
    Serial.println(message.getBool());
  } 
}

Should I RTFM? (where please?)

Please Log in or Create an account to join the conversation.

8 years 9 months ago - 8 years 9 months ago #1889 by Sunspot
Replied by Sunspot on topic Five module limit?
Surely someone has got more than 5 nodes on a single ESP/Arduino sketch !?

The cheap Chinese 8 relay board would do a great job

Knock Knock . . . .

(and with I2C on an ESP-01 you could get 20 or more sensors/controllers)

Please Log in or Create an account to join the conversation.

8 years 9 months ago #1890 by Sunspot
Replied by Sunspot on topic Five module limit?
I added 2 more relays making 6 and there is also one temperature and one humidity node.
8 nodes in all.

I moved the ESP etc close to the WiFi modem - a "5 bar" signal

After 4 or 5 30 second tries to find the settings it got just 2 and ignored 6.
I tried again for several 30 second waits and it eventually got 7 of the 8 (one relay ignored).

It does seem very hit and miss with more than a few nodes in one sketch.

Might it be possible to add the node by hand somehow?
Perhaps also with a fixed IP address for the ESP?

Does anyone else share this experience - it dampens my initial enthusiasm a bit :(

Please Log in or Create an account to join the conversation.

8 years 9 months ago #1891 by Sunspot
Replied by Sunspot on topic Five module limit?
I assume the node details found by the automatic scan are stored in the Pi somewhere?
(then perhaps I can tweak the data to add the missing relays?)

I am looking with ftp as root but can't see where the nodes are stored.

(I cant even see the index.html - usually in /var/www/???)

I would love to understand the web page creation process!
Is there any documentation?

Please Log in or Create an account to join the conversation.

8 years 9 months ago #1905 by EasyIoT
Replied by EasyIoT on topic Five module limit?

Sunspot wrote: I assume the node details found by the automatic scan are stored in the Pi somewhere?
(then perhaps I can tweak the data to add the missing relays?)

I am looking with ftp as root but can't see where the nodes are stored.

(I cant even see the index.html - usually in /var/www/???)

I would love to understand the web page creation process!
Is there any documentation?


Configuration is in config folder under easyiot. Web pages are build dynamically.

Please Log in or Create an account to join the conversation.

8 years 9 months ago - 8 years 9 months ago #1927 by piman
Replied by piman on topic Five module limit?
Has anyone come up with an answer for More then five nodes?

Please Log in or Create an account to join the conversation.

Time to create page: 0.264 seconds

Forum latest

  • No posts to display.