Wifi module data transmission method

I am learning while watching the video below

In the video, there are two ways to transmit data using the Wi-Fi module.

  1. Content-Type: multipart/x-mixed-replace;boundary=openmv\r\n (MJPEG Streaming AP)
  2. Content-Type: application/json\r\n (String data)

Can I send Streaming and string data at the same time in the wifi module?

Yeah, it’s a standard sockets interface. So, you can stream whatever you like.

In the MJPREG_STRAMER_AP(example code), streaming is possible, but string data cannot be transmitted. Are there any additional examples?

You just need to create a new socket and use that. See our urequest module for example to send REST requests.

Is it possible to send streaming and string data using “Content-Type: multipart/x-mixed-replace;boundary=openmv\r\n”?

Yes, see the REST API in urequests.

I added the code below to the MJPEG Streaming AP example code, but it doesn’t work. Can I get some example code?


data = {
“name”: “John”,
“age”: 30
response = urequests.post(“”, json=data)


data = {
“name”: “John Doe”,
“age”: 35
response = urequests.put(“”, json=data)

Hi, what is the error message that’s printed? Can you give some more debug info?

while (True):
    frame = sensor.snapshot()  
    cframe = frame.compressed(quality=35)
    header = "\r\n--openmv\r\n" \
             "Content-Type: image/jpeg\r\n"\



    data = {
    'name': 'John',
    'age': 30
    response = urequests.post('', json=data)

“ValueError: need more than 1 values to unpack”

This error has occurred.

If I configure the code as above, can I send image and string data?

Hi, I don’t see anything wrong with that code in theory. However, I guess you are not getting a response from the remote interface? Have you tried using wirewhark to look at the TCP traffic and seeing if the remote server responded?

It seems that an error has occurred and the connection cannot be made.

“ValueError: need more than 1 values to unpack”

No response to wirewhark


I saw this link. But it doesn’t work. No response in wireshark either.

Can I get a simple sample code to post?

Hi, here’s a website called postman echo: Postman

If you do something like:

response = urequests.get("http://postman-echo.com/get?foo1=bar1&foo2=bar2")

Then you’ll get the result of:

{'headers': {'x-amzn-trace-id': 'Root=1-646c391b-2135fc7f018223172155456c', 'x-forwarded-proto': 'http', 'x-forwarded-port': '80', 'host': 'postman-echo.com'}, 'args': {'foo1': 'bar1', 'foo2': 'bar2'}, 'url': 'http://postman-echo.com/get?foo1=bar1&foo2=bar2'}

Which is similar to what the website says it will return:

    "args": {
        "foo1": "bar1",
        "foo2": "bar2"
    "headers": {
        "x-forwarded-proto": "https",
        "host": "postman-echo.com",
        "accept": "*/*",
        "accept-encoding": "gzip, deflate",
        "cache-control": "no-cache",
        "postman-token": "5c27cd7d-6b16-4e5a-a0ef-191c9a3a275f",
        "user-agent": "PostmanRuntime/7.6.1",
        "x-forwarded-port": "443"
    "url": "https://postman-echo.com/get?foo1=bar1&foo2=bar2"

As for why this doesn’t work:

    data = {
    'name': 'John',
    'age': 30
    response = urequests.post('', json=data)

It’s hard to tell. I don’t know what server you are talking to and what you expect it to return.

For example, if I do:

response = urequests.post("http://postman-echo.com/post")

I get back:

{'files': {}, 'headers': {'x-forwarded-port': '80', 'content-type': 'application/json', 'x-amzn-trace-id': 'Root=1-646c3a52-32c90cfc34128f4b140d5218', 'host': 'postman-echo.com', 'x-forwarded-proto': 'http'}, 'args': {}, 'form': {}, 'data': {}, 'json': None, 'url': 'http://postman-echo.com/post'}

Try playing around with the postman echo service to get the hang of who POST/GET etc. work.