Comments (21)
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.
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.
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.
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.
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.
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.
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.
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.
Just tested again with a MEGA 2560, works fine as well.
from arest.
Also just tested with all analog inputs by modifying the code, works well too.
from arest.
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.
Sure, what is your browser ? I am using Chrome 36 on OS X. Do you have problems with any other commands ?
from arest.
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.
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.
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.
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.
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.
You're right ! i was compiling with 1.0.3. It is working fine with 1.0.5-r2
Thx !
from arest.
This version is much better, unable to crash it with an ethernet shield. Great job :)
from arest.
Great to hear! Can I close the issue ?
from arest.
Closing the issue as it now works fine.
from arest.
Related Issues (20)
- arest.io problem HOT 3
- output pin set to low at startup
- Issue with multiple Custom functions
- Unable to create a new account HOT 2
- Request example sketch for local use of API key HOT 1
- function name gets confused after 6 characters HOT 1
- 'class aREST' has no member named 'get_topic' HOT 3
- Limitations HOT 1
- ethernet_cloud sketch don't run HOT 2
- https://dashboard.arest.io/devices is not providing any way to add devices HOT 1
- Why is support for text and float variables restricted?
- aREST using UIPEthernet stack failed HOT 1
- Multiple warnings ISO C++ forbids converting a string constant to 'char*' [-Write-strings]
- To support Ethernet2.h library, this should be "ethernet_h"
- Does aREST support the Arduino Uno WiFi r2 Board ? HOT 4
- ESP8266WiFi.h: No such file or directory compilation terminated.
- rest.function() bug: command is improperly passed to function
- How to force send a HTTP 200 command in a rest.function
- CONTROLLINO MAXI AUTOMATION WITH AREST
- Freezes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arest.