Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON string not returned #19

Closed
fynixtech opened this issue Sep 7, 2014 · 6 comments
Closed

JSON string not returned #19

fynixtech opened this issue Sep 7, 2014 · 6 comments

Comments

@fynixtech
Copy link

I seem to be having a problem with rest variables. I have an arduino mega 2560 set up with a DHT22 sensor. I am having some problems with the JSON string not been returned or incomplete when I call the variable like 192.168.x.x/temperature or 192.168.x.x/humidity. I am using an iPhone with the safari browser. I know the request worked because the connection completed but the screen is blank or sometimes a partial string is returned. I added a delay of 100ms after the variables get the value from the DHT sensor and that helps slightly but still the same problem. I seem to be only able to request the temperature or humidity like once every 15s and the JSON string will be complete.

void setup(){
...  
  rest.variable("temperature",&temperature);
  rest.variable("humidity",&humidity);
  rest.variable("heat_index",&heatIndex);
...
}


void loop() {
  // Handle REST calls
  temperature =dht.readTemperature(1);
  humidity=dht.readHumidity();
  heatIndex = dht.computeHeatIndex(temperature, humidity);

  //fanRpm=rpm();
  //current=currentSense();
  mdns.update();
  Adafruit_CC3000_ClientRef client = restServer.available();
  rest.handle(client);
  delay(5);
  u8g.firstPage();  
  do {
    draw();
  } 
  while( u8g.nextPage() );
  restartWifi();
}
@marcoschwartz
Copy link
Owner

You're correct, I am having the same problem with Safari on my iPhone. However it only happens with Safari, with Chrome or a cURL app it works fine. Safari on my Macbook also works fine.

I solved it by using the IP of the board and not the DNS redirection (arduino.local). Could you test that with your code as well?

@fynixtech
Copy link
Author

I actually use the IP address in my case as I can't get the mDNS to work at all at this point. It is not a big deal at this point anyway as we are writing server code to run on a raspberry pi. The pi will run a webserver that can be accessed by any device with a web browser and will control the arduinos.

@fynixtech
Copy link
Author

I am wondering if it has something to do with how much time it takes the DHT to send its data, because it seems to work fine if the variable is set to a specific value

@marcoschwartz
Copy link
Owner

I tested with & without the DHT sensor and it is the same result for me. I will close the issue as it is something related to the CC3000_MDNS library and not to aREST :)

@fynixtech
Copy link
Author

Yeah, I think its the CC3000. I took my set up to Maker Faire new york and nothing worked even though the CC3000 showed it was connected to the router and I wasn't even using mDNS. I think it was all the noise from all the other routers in the area. I switched to the ethernet shield and everything came back on. I am done with the CC3000, it is way too much hassle to work with. Thanks.

@marcoschwartz
Copy link
Owner

I think it was indeed the number of other WiFi devices around that caused the problem, especially if you are using the breakout board with the onboard antenna. I also plan to extend the aREST library to the CC3100 & CC3200 chips in the future, which should work much better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants