Unable to connect to micropython esp32 single_thing

I have been unable to connect the example single_thing in the webthing-upy repo. I have a thing gateway on a rpi that I know works. It it as version 0.7. I was able to see an arduino led thing pretty easily.

Now I have a webthing-upy running atop lobo micropython running on an adafruit huzzah32 esp32. My main.py simply just imports ‘start’ and runs ‘start.single()’. I made sure the configure ‘config.py’ with my wifi creds. I copied all of the webthing-upy webthing/.py, upy/.py, and example/*.py into their respective folders onto the device. When I reset the thing device, it boots up and runs main without issue that I can tell.

This is the tail end of the boot/main run:

I (1091) MicroPython: [=== MicroPython FreeRTOS task started (sp=3ffc5c10) ===]

Internal FS (SPIFFS): Mounted on partition ‘internalfs’ [size: 1048576; Flash address: 0x200000]

Filesystem size: 956416 B
Used: 115456 B
Free: 840960 B

I (1851) phy: phy_version: 3960, 5211945, Jul 18 2018, 10:40:07, 0, 0
Connecting…

ifconfig = (‘192.168.86.250’, ‘255.255.255.0’, ‘192.168.86.1’, ‘192.168.86.1’)
Syncing to NTP…
waiting for time sync…
Time: 2019-02-25 03:44:56
importing single_thing…
Starting single_thing server…
INFO:single_thing:run_server
INFO:server:Registering a single thing
INFO:single_thing:starting the server
INFO:server:Starting Web Server on port 80
MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on ESP32 board with ESP32
Type “help()” for more information.

I made sure that the WebThing Add-on has been enabled. I can see that the ThingURLAdapter is listed in Adapters.

When I try to add the thing, scanning does not discover anything. When I try to add my thing’s URL, http://192.168.xxx.xxx/, it results in “web thing not found”.

Here is a snippet of what I see in the developer’s log:

2019-02-25 04:18:12.897 INFO : About to call startPairing on ThingURLAdapter
2019-02-25 04:18:12.911 INFO : Opened a new things socket
2019-02-25 04:18:46.165 INFO : thing-url: Failed to parse description at http://esp32-upy-f1efc0.local:80: SyntaxError: Unexpected token < in JSON at position 8
2019-02-25 04:19:12.906 INFO : Pairing timeout
2019-02-25 04:19:12.909 ERROR : Thing was not added
2019-02-25 04:19:12.910 ERROR : addNewThing cancelled
2019-02-25 04:19:12.914 INFO : thing-url: Adapter: ThingURLAdapter id thing-url-adapter pairing cancelled
2019-02-25 04:19:41.139 INFO : Tunnel domain found. Tunnel name is: mysubdomain and tunnel domain is: mozilla-iot.org
2019-02-25 04:19:41.144 INFO : Tunnel name is set to: https://mysubdomain.mozilla-iot.org
2019-02-25 04:19:41.145 INFO : Local mDNS Service Domain Name is: gateway
2019-02-25 04:19:49.525 INFO : About to call startPairing on ThingURLAdapter
2019-02-25 04:19:49.857 INFO : thing-url: Failed to parse description at http://esp32-upy-f1efc0.local:80: SyntaxError: Unexpected token < in JSON at position 8
2019-02-25 04:19:49.866 INFO : Opened a new things socket
2019-02-25 04:20:49.533 INFO : Pairing timeout
2019-02-25 04:20:49.536 ERROR : Thing was not added
2019-02-25 04:20:49.539 ERROR : addNewThing cancelled
2019-02-25 04:20:49.543 INFO : thing-url: Adapter: ThingURLAdapter id thing-url-adapter pairing cancelled

I see the JSON parse error above. I am not sure what description it is looking at. I examined the ‘description’ properties in single_thing.py and they all looked like valid JSON.

I installed zeroconf and ran the code to browse for a webthing service. Here’s what I got:

browser = ServiceBrowser(zeroconf, ‘_webthing._tcp.local.’, listener)
Service esp32-upy-f1efc0._webthing._tcp.local. added, service info ServiceInfo(type=’_webthing._tcp.local.’, name=‘esp32-upy-f1efc0._webthing._tcp.local.’, address=b’\xc0\xa8V\xfa’, port=80, weight=0, priority=0, server=‘esp32-upy-f1efc0.local.’, properties={b’board’: b’ESP32’, b’path’: b’/’})

I’m guessing that the mDNS logic in webthing/server.py is working as designed given the output above.

Any ideas what I might be doing wrong here?

Thanks
Gary

Are you able to access your thing in the browser, either at http://192.168.xxx.yyy or http://esp32-upy-f1efc0.local?

Here is what I can see:

browse ip addr: 403 forbidden – authorization will not help
curl: same response
ping: I get a reply in ms
telnet: connection establishes, then closes

browse esp32 local hostname: site cannot be reached
curl: could not resolve host …
ping: same error
telnet: same error

Which port of MicroPython for ESP32 are you using. The upy examples were all written to work with the Loboris port: https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo

And it also needs some changes which I made in a local fork: https://github.com/dhylands/MicroPython_ESP32_psRAM_LoBo/tree/rest-improvements

I’m using Lobo. Here’s what the firmware spits out:

MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on ESP32 board with ESP32

As for using your (dhylands) local fork, I know that I have not tried this. I will try this tonight.

I am also in the process of trying the SparkFun ESP32 Thing since that thing was specifically called out in the git readme. I am not sure there will be a difference, but I readily have it so I can try it.

I am finally back at trying to get this to work. I just tried the dhylands’ version of the lobo firmware on an Adafruit ESP32 Feather Huzzah. Network connectivity is good since it can reach out to the time server. But after uploading all of the webthing-upy/* files and browsing the IP, I still got the same result: 403 auth error. I then tried a SparkFun ESP32 Thing. I got the exact same results.

Either I am doing something incorrect during the setup, my expectations are incorrect, or there is an issue w/ the code.

Here are my steps:

  1. erase the flash
  2. flash the device w/ this, the dhylands version of lobo’s esp32 all
  3. verified that it can reach out to the internet time server
  4. uploaded the upy/, webthing/, and example/* files into their respective folders into the /flash directory on the device.
  5. putty’d into the device
  6. imported ‘start’ and ran ‘start.single()’

MicroPython ESP32_LoBo_v3.2.15 - 2018-05-10 on ESP32 board with ESP32
Type “help()” for more information.

import start
I (21984) phy: phy_version: 386.0, 67c798f, Mar 14 2018, 16:34:06, 1, 0
Connecting…

ifconfig = (‘192.168.86.27’, ‘255.255.255.0’, ‘192.168.86.1’, ‘192.168.86.1’)
Syncing to NTP…
waiting for time sync…
Time: 2019-04-01 16:52:07

start.single()
importing single_thing…
Starting single_thing server…
INFO:single_thing:run_server
INFO:server:Registering a single thing
INFO:single_thing:starting the server
INFO:serv Starting Web Server on port 80

  1. ran curl on the http://192.168.86.27 which results in a 403 authorization error

Is this 403 an expected result? Am I supposed to provide a bearer token or something in a header? Or am I supposed to provide creds in a different way.

I’ve been scouring the web to find in detail how someone has setup their esp32 thing. I see stuff running, but I don’t see step by step instructions anywhere.

All help is appreciated.

Something is definitely broken. I’m able to reproduce your error and can’t seem to otherwise make it work.

Thanks for confirming. I’ll try stepping down versions of webthing upy to see what I can see.