Home/Support/Support Forum/Can you run a web server on XBee3 LTE CAT1 (MicroPython PicoWeb) ?

Can you run a web server on XBee3 LTE CAT1 (MicroPython PicoWeb) ?

0 votes
I'd like to connect a CPU to the XBee3 and have it serve up a web page to the Internet.

I see that PicoWeb is a web server based on MicroPython so I think what I'm asking might be possible.

I'm thinking can create the HTML web page on the CPU, or feed data to the XBee3 and have it create the web page. Haven't got that far yet.

My question at this point is, can the XBee3 LTE be a web server?
asked Mar 13 in XBee3 Cellular by jackson New to the Community (7 points)
edited Mar 13 by jackson

Please log in or register to answer this question.

3 Answers

+1 vote
Unfortunately it looks like PicoWeb depends on a fork of MicroPython that provides asyncio (which XBee MicroPython does not have): https://github.com/pfalcon/picoweb#requirements-and-optional-modules

Also keep in mind that in order to use a device such as an XBee3 Cellular as a web server, you would need to be able to reach the device over the cellular network from the client device. This would require either an expensive SIM card plan with a static IP (which would also mean everybody in the world could access your web server), or some other coordination within the cellular network between the XBee and another client device (such as a phone or computer) so that the client knows what IP address to access.

If using an XBee3 Cellular device to serve up HTML pages like this is still the usecase you want, and you are able to resolve the IP addressing issues that come with it, instead of using MicroPython I would recommend API mode, especially since you will be using an external host processor. You can configure a listening TCP port using the ATIP and ATC0 commands.
answered Mar 13 by tckr Seasoned Professional (154 points)
+1 vote
First, your LTE device needs a static IP.

Simple HTTP server

The following code creates an simple HTTP server which serves a single webpage that contains a table with the state of all the GPIO pins:

import machine
pins = [machine.Pin(i, machine.Pin.IN) for i in (0, 2, 4, 5, 12, 13, 14, 15)]

html = """<!DOCTYPE html>
<html>
<head> <title>ESP8266 Pins</title> </head>
<body> <h1>ESP8266 Pins</h1>
<table border="1"> <tr><th>Pin</th><th>Value</th></tr> %s </table>
</body>
</html>
"""

import socket
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]

s = socket.socket()
s.bind(addr)
s.listen(1)

print('listening on', addr)

while True:
cl, addr = s.accept()
print('client connected from', addr)
cl_file = cl.makefile('rwb', 0)
while True:
line = cl_file.readline()
if not line or line == b'\r\n':
break
rows =
response = html % '\n'.join(rows)
cl.send(response)
cl.close()
answered Mar 14 by Jexx New to the Community (13 points)
Nice! This is very helpful.
0 votes
It looks like the real roadblock might be reaching the Xbee3 from the Internet. Even knowing the IP address of the XBee3, the cellular network might prevent "Mobile Terminated" (Internet initiated) IP connections to the XBee3. I read "...with a regular mobile plan you are unlikely to get a fixed IP. It’s also possible that the ports you require may not be accessible and you may not get a routable IP at all - quite a few providers have now gone to carrier grade NAT or a walled garden approach." Google shows many sellers of fixed IP SIM cards with public IPs, but they are all overseas, lucky them!

Is anyone able to get Internet initiated "Mobile Terminated" IP data to the XBee3 (without an expensive corporate fixed IP plan)? Which carrier/plan?

Or does this mean I need to go the Cloud/subscription route? Was really hoping to avoid that extra complexity.

Head is spining with all the cloud options and methods out there! I'm thinking of pushing the temperature data to the cloud using MQTT (XBee3 in Transparent Mode, MQTT will generated by my CPU and sent to the XBee over UART, barest minimum of Python coding). I'm hoping the cloud-vendor (Digi!) has visualization tools to publish the data to a simple bar-graph graphic that is viewable on a cell phone and/or web browser. or am I dreamin?

Suggestions?
answered Mar 14 by jackson New to the Community (7 points)
You can use your device as a TCP/IP client and use this free service. http://dweet.io/  Push the data to this server instead of trying to run your Digi as a web server.  To dweet from your thing, simply call a URL like: https://dweet.io/dweet/for/my-thing-name?Greetings=Universe
I must have been reading your mind. I ran across Dweet/Freeboard and liked their approach.
Thanks
EDIT: The Dweet/Freeboard solution looks interesting but to get full functionality you have to do a lot of hacking/programming. It doesn't look like new development is happening, and the user community has died down. Plonk

I have a question about dweeting:
I'm guessing that the XBee3 has to be in Transparent mode, and is "Connecting to a TCP/IP address" as on page 46 of the LTE-M/NB-IOT User Guide?
Do you have an example of the string I have to send from my processor to do a simple "for" dweet: https://dweet.io/dweet/for/my-thing-name?hello=world

Or do I have to do a "GET HTTP Request" or "CoAP"?
...