What is the maximum number of sensors can be attached to the device?


#1

What is the maximum number of sensors can be attached to the device? When I drove one led, everything worked. In a new sketch I wanted control 7 LEDs, and can’t add any dashboard widget. The wheel is spinning, but LEDs are not added. Similarly, I cannot see the sensors. Sensors attached too 7 pieces. Arduino UnO + Ethernet shield W5100

physically there is nothing connected to the inputs, only LEDs are connected to the outputs.

https://docs.google.com/document/d/1pDTjA8SP0FCrZw1xG2vt7WWJTy-4EvJ1a7vO1KyLbxQ/edit?usp=sharing


#2

It works only when the reduced number of inputs to 4 and outputs to 4.
Is there a paid account so that you can work with 10 inputs and 10 outputs?


#3

Hello @scratch_book !

Answering to your question, there is no any limit about the number of sensors or controls of one device in thinger.io, you can create every resources you want but, I’m afraid that your code have a little mistake. The resources definitions shoud be placed on setup() routine, not in loop(). Now your code is creating the resources on each loop execution, and it shouldn’t works fine… may be with 4 o 5 elements it’s possible but, with more resources the RAM breaks

try with this:

#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
#include <SPI.h>
#include <Ethernet.h>
#include <ThingerEthernet.h>

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
void ON_alarm_centr();
void OFF_alarm_centr();
void ON_floodlight();
void OFF_floodlight();
void OFF_pump();
void ON_pump();
void ON_alarm_stern();
void OFF_alarm_stern();
void ON_alarm_bow();
void OFF_alarm_bow();
void ON_heating();
void OFF_heating();
void ON_lighting();
void OFF_lighting();
double Water;
double Light;
double Gaz;
double Temperature;
double Movement;
double Distance;
double Fire;
float getDistance(int trig,int echo){
    pinMode(trig,OUTPUT);
    digitalWrite(trig,LOW);
    delayMicroseconds(2);
    digitalWrite(trig,HIGH);
    delayMicroseconds(10);
    pinMode(echo, INPUT);
    return pulseIn(echo,HIGH,30000)/58.0;
}
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // Мак адрес платы W5100
byte ip[] = { 192, 168, 0, 121 };                    // IP адрес платы W5100
ThingerEthernet thing("scratch_book", "W5100", "12345678");


void setup(){
    pinMode(6,OUTPUT);
    pinMode(4,OUTPUT);
    pinMode(13,OUTPUT);
    pinMode(8,OUTPUT);
    pinMode(10,OUTPUT);
    pinMode(11,OUTPUT);
    pinMode(3,OUTPUT);
    pinMode(A0+0,INPUT);
    pinMode(A0+1,INPUT);
    pinMode(A0+2,INPUT);
    pinMode(A0+3,INPUT);
    pinMode(2,INPUT);
    pinMode(12,INPUT);
    Ethernet.begin(mac, ip);

    thing["Water"] >> [](pson& out){
out = Water;   // Отправляем значение переменной Water на сайт thinger.io
};

thing["Light"] >> [](pson& out){
out = Light;   // Отправляем значение переменной Light на сайт thinger.io
};

thing["Gaz"] >> [](pson& out){
out = Gaz;   // Отправляем значение переменной Gaz на сайт thinger.io
};

thing["Temperature"] >> [](pson& out){
out = Temperature;   // Отправляем значение Temperature на сайт thinger.io
};

thing["Movement"] >> [](pson& out){
out = Movement;    // Отправляем значение Movement на сайт thinger.io
};

thing["Distance"] >> [](pson& out){
out = Distance;    // Отправляем значение Distance на сайт thinger.io
};

thing["Fire"] >> [](pson& out){
out = Fire;    // Отправляем значение переменной Fire на сайт thinger.io
};

  thing["Alarm_centr"] << [](pson& in){   //Управление тревогой в центре
    if(in.is_empty()){
        in = (bool) digitalRead(6);
    }
    else{
        digitalWrite(6, in ? HIGH : LOW);
    }
};

  thing["floodlight"] << [](pson& in){    //Управление прожектором
    if(in.is_empty()){
        in = (bool) digitalRead(4);
    }
    else{
        digitalWrite(4, in ? HIGH : LOW);
    }
};

  thing["pump"] << [](pson& in){      //Управление насосом
    if(in.is_empty()){
        in = (bool) digitalRead(13);
    }
    else{
        digitalWrite(13, in ? HIGH : LOW);
    }
};

  thing["alarm_stern"] << [](pson& in){   //Управление тревогой на корме
    if(in.is_empty()){
        in = (bool) digitalRead(8);
    }
    else{
        digitalWrite(8, in ? HIGH : LOW);
    }
};

  thing["alarm_bow"] << [](pson& in){   //Управление тревогой на носу
    if(in.is_empty()){
        in = (bool) digitalRead(10);
    }
    else{
        digitalWrite(10, in ? HIGH : LOW);
    }
};

  thing["heating"] << [](pson& in){   //Управление обогревом
    if(in.is_empty()){
        in = (bool) digitalRead(11);
    }
    else{
        digitalWrite(11, in ? HIGH : LOW);
    }
};

  thing["lighting"] << [](pson& in){    //Управление освещением в отсеках
    if(in.is_empty()){
        in = (bool) digitalRead(3);
    }
    else{
        digitalWrite(3, in ? HIGH : LOW);
    }
};
}

void loop(){
    
thing.handle();

    Water = analogRead(A0+0);
    Light = analogRead(A0+1);
    Gaz = analogRead(A0+2);
    Temperature = analogRead(A0+3);
    Movement = digitalRead(2);
    Distance = getDistance(7,5);
    Fire = digitalRead(12);
  


}




#4

Thank you!
this limit of 4 devicec only in thinger.io ethernet shield library.


#5

Hi @scratch_book

I have the same problem, I’m trying to send to thinger.io 8 output and 2 input and it doesn’t work but when I do 4 output and 2 input it works fine.
My thing definition is on setup so there is no problem.

When you said it is only for ethernet shield library, have you found a work arround?

Regards,


#6

Hi @maximo80 I did not find a solution to this problem. I reported it to the developers and I’m waiting for them to fix it.


#7

I have optimized a small part of the code, and now I am able to define much more resources. However, the Arduino + Ethernet shield is quite limited in memory. This number of resources would help you?

Best.


#8

Thank you, Alvaro! I do not understand what this table means. Can I now use more than 4 signals with ethernet shield?
Thank you very much for taking care of us!


#9

Hi! this is the API explorer for the Arduino + Ethernet shield with 10 resources defined working properly, but it may vary depending on your code, as this device is quite limited.


#10

Hi, I have updated the Arduino Client Library in the master (not updatable by the Arduino Library Manager yet). If you can test that it works better now, it would be great :slight_smile:

Just download the library from here, and replace the current one in your Arduino folder. However, do not expect more than 10 resources being listed in the API for this kind of setup! Let me know if it works better!


#11

Dear Alvaro!
I’m on a business trip and can not verify it. Maybe my friend @maximo80 can check it.
Great russian SPASIBO (I wish salvation to your soul)

Thinger.io is a very good project. It helps many students learn modern technology.


#12

It works fine thank you Álvaro!!!
Very good job.


#13

Nice! Then I will publish the new library version soon, with some other improvements!

Thanks for testing! :slight_smile:


#14

I managed to get 12 things instead of 10 with a small change to the ThingerClient.h

I changed this:
dynamic_memory_allocator alloc;
//circular_memory_allocator<512> alloc;
memory_allocator& protoson::pool = alloc;
to this:
//dynamic_memory_allocator alloc;
circular_memory_allocator<512> alloc;
memory_allocator& protoson::pool = alloc;

Not the best fix to get an extra 2 things on your device as it will create a non standard library. Perhapse a MEGA or other device with more memory would help