So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Tisa
#62535 Hi guys, I need a hand with receiving an image as the title says.

Basically, I have one of the Axis cameras and I'm trying to get it to send me an image. I've been using the Adafruit HUZZAH ESP8266 to send requests to it to pan, tilt, zoom and display general info about the camera and those functions have been working out just fine, but I seem to have hit a brick wall when it comes to receiving images.

I'm using Arduino IDE and this library: https://github.com/esp8266/Arduino

I've been trying to work on a solution based on this snippet from the example code:
Code: Select all// Read all the lines of the reply from server and print them to Serial
  while(client.available()){
    String line = client.readStringUntil('\r');
    Serial.print(line);
  }


I've managed to read and display everything the camera sends as a response but only because it was a string. I have no clue what to do with the actual file that it gives me while I request a snapshot. Is there a way to save it to the card? Or maybe an SD card? Regardless, I haven't found any answers in the ESP8266 documentation on github.

Any and all help would be appreciated, thanks in advance!
User avatar
By gdsports
#62634 The following example shows how to receive a stream of binary bytes from an HTTP server. The binary stream could be JPEG image data. Open a file in SPIFFS or in SD, write the binary data, then close the file when the stream closes.

https://github.com/esp8266/Arduino/blob ... Client.ino

SPIFFS docs. ESP12 usually come with 4 Mbytes of Flash with 3 MBytes allocated to SPIFFS. Image data can easily use up all 3 MBytes.

http://esp8266.github.io/Arduino/versio ... ystem.html

Example: SPIFFS with webserver interface to upload/download files.

https://github.com/esp8266/Arduino/blob ... rowser.ino

Using an SD card gives your program access to gigabytes of storage. See Arduino SD library docs.

Example: SD with webserver interface to upload/download files.

https://github.com/esp8266/Arduino/blob ... Server.ino