Giter VIP home page Giter VIP logo

Comments (21)

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Thanks! For now there is no way, but I added that to the features to add list. I am also considering adding the possibility to return several measurement variables at once.

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

I've made this modification for testing :

  // Analog selected
   if (command == "analog") {
     if (state == 'r'){

       // Read analog value
       value = analogRead(pin);

       // Send feedback to client
       if (LIGHTWEIGHT){serial.print(value);}
       else {
        serial.print(F("{\"return_value\": "));
        serial.print(value);
        serial.print(F(", "));
       }
   }

   // [ADDED] 
     else if (state == 'a'){
       // Send feedback to client   

        serial.print("{");
        for (int i=1;i<9;i++)
        {
        // Read analog value
        value = analogRead(i);
        serial.print("\"pin");
        serial.print(i);
        serial.print(F("\": "));
        serial.print(value);
        serial.print(F(", "));


       }
   }

Starting like this :
{"pin1": 297, "pin2": 359, "pin3": 334, "pin4": 419, "pin5": 315, "pin6": 340,
then it cash the board... each time :(

any idea (i'm using wifi shield) ?

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

I tryed that :

   // [ADDED] GLA
     else if (state == 'a'){

       // Send feedback to client

        String stringOne = "{";
        for (int i=1;i<8;i++)
        {       
        // Read analog value
        value = analogRead(i);
        stringOne += "\"pin" + String(i) + "\":" + String(value) + ",";
       }

       serial.print(stringOne);

   }

It improve a lot, now i can print 8 pin values, but if i try more it crash the board.

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Hello,

Thanks for the suggested code. I think it crashes because you are creating new Strings which is not efficient. Also there are only 6 analog pins on the Uno board, so it doesn't really make sense to read more :) I pushed a new version of the library that integrates the functionality with /analog/a and it seems to work fine, I tested it with WiFi and Serial. Let me know what you think!

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

Hi,

I'm using a MEGA and i've sensors on all Analog pins. Sorry for the poor code, i'm a beginner :)
I'll test the new version right now !

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

On a MEGA i've the same problem, got :

{"A0": 256, "A1": 262, "A2": 260, "A3": 249, "A4": 263, "A5": 250, "id": "001", "name"

Then the board crash... the only way is a power cycling. I've tried 2 different mega boards and i've the same issue. I'll Try with a UNO board to see...

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

Changed the board for Arduino Uno and i've also changed the CC3000 by an other one (Just in case).
Same result :
{"A0": 533, "A1": 448, "A2": 363, "A3": 345, "A4"
Then the board crash...

I'll try this evening with an Ethernet module to compare.

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Hum, interesting. Just to be sure you are using an Adafruit CC3000 WiFi module right ? I am using this module and I have no problem. I will try with a MEGA board as well to be sure.

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Just tested again with a MEGA 2560, works fine as well.

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Also just tested with all analog inputs by modifying the code, works well too.

screen shot 2014-08-08 at 14 35 30

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

Strange... Yes I'm using the adafruit shield version of the cc3000. Code is 100% yours... I'll try to change the access point, do you have any other idea ?

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Sure, what is your browser ? I am using Chrome 36 on OS X. Do you have problems with any other commands ?

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

So, i've made a few tests :

I've used an other (third) C3000 adafruit sheild. Flashed with last firmware.
We are using a band new Arduino MEGA bought from Arduino.cc (not a chinese clone).

So hardware should be ok.

On this hardware it works and i've got all the sensors values, BUT, if i reload the web page a bit fast (around every second) the arduino board crash after 3 reload.

So i did the same on 1 sensor (/analog/1/r), it is the same, if i reload a bit fast the page, it crash too...

(I'm using chrome 35 on win64, but same issue on firefox)

Can you try on your side ?

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

I've made more test, whatever the client (wget under bash, linux...) It crash after 3 to 5 http queries if it is too fast the only way is to delay the query to 10 sec. Even with 10 sec, after a few hours the board cash :(

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Sure thing, I tried again and I confirm I have the same as you (except for the 10 seconds delay). We have to keep in mind that handling the CC3000 chip is at the limit of what the Arduino can do, and from my measurement it takes about 700 ms (for simple requests) to 1500 ms (for the /analog/a command) to process a request & send the result. So if you reload the page quickly it might crash indeed.

To avoid to have crashed board, I added a bunch of code that uses the watchdog to make sure that whatever happens, the board will restart automatically.

Concerning the initial issue, do you also want a function to read all digital pins ? Also, I'll try to include an auto-detection of the board (Uno or Mega) so it reads the correct number of ports.

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

Hi, thx a lot for all, i have a problem witht he last version of the lib:

In file included from Ethernet.ino:12:
C:\Users\3ds\Desktop\Dropbox\arduino-1.0.3\arduino-1.0.3\libraries\aRESTmaster/aREST.h: In member function 'void aREST::handle_proto(T&, bool)':
C:\Users\3ds\Desktop\Dropbox\arduino-1.0.3\arduino-1.0.3\libraries\aRESTmaster/aREST.h:289: error: 'class String' has no member named 'c_str'

Same with Wifi.

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Thanks for reporting the issue, compiles fine for me. Can you try updating to the latest version of the IDE (1.0.5) ?

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

You're right ! i was compiling with 1.0.3. It is working fine with 1.0.5-r2
Thx !

from arest.

superguigui3 avatar superguigui3 commented on July 30, 2024

This version is much better, unable to crash it with an ethernet shield. Great job :)

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Great to hear! Can I close the issue ?

from arest.

marcoschwartz avatar marcoschwartz commented on July 30, 2024

Closing the issue as it now works fine.

from arest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.