In this tutorial, we’ve seen how it’s easy to get started and run a simple Python script on the 4zerobox, an industrial board based on ESP32 designed to bring Industrial applications into the IoT and Industry 4.0 revolution.
As you can see on the Kickstarter campaign page, 4zerobox provides connectivity through:
- native Bluetooth Low Energy and WiFi (both Station and AP mode are supported) thanks to its on-board ESP32 module;
- Ethernet (thanks to an on-board Microchip LAN8710A transceiver).
- RS-485, RS-232 and CAN (based on Microchip MCP2515T controller integrated with transceiver);
In addition, since the 4zerobox has two mikroBUS™ sockets, you can get the following connectivity click boards™:
- LoRa click, that carries Microchip’s RN2483 fully certified LoRa Sub-GHz, 433/868 MHz European R&TTE Directive Assessed Radio Modem.
- GSM 4 click, that features the u-blox SARA-G3 series 2.5G GSM/GPRS cellular quad-band module.
- GPS 4 click, that carries the L70 compact GPS module from Quectel.
All these connectivity options are supported on the software side by dedicated Zerynth libraries. Zerynth also provides ready-to-use connectivity modules for IoT cloud services like Amazon Web Services and Google IoT Cloud.
You can find more info about Zerynth and its support for 4zerobox (and for ESP32) in its Kickstarter campaign page: https://bit.ly/get-4zerobox
Web server connection testLet’s see a sneak peek of the connectivity capabilities of 4zerobox. The following example shows how to connect 4zerobox via WiFi to an HTTP Request & Response Service to get the current UTC time.
NOTE: This video shows the v0 prototype of 4zerobox, that uses an ESP32 mounted on an ESP32-DevKitC. The final version will include an ESP32-wroom module directly on-board.
Following a piece of the related code.
# let's try to connect to http://now.httpbin.org/ to get the current UTC time
for i in range(3):
try:
print("Trying to connect...")
# we need to impersonate a web browser: as easy as setting the http user-agent header
user_agent = {"user-agent":"Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405"}
# go get that time!
# url resolution and http protocol handling are hidden inside the requests module
response = requests.get("http://now.httpbin.org/")
# let's check the http response status: if different than 200, something went wrong
print("Http Status:",response.status)
# if we get here, there has been no exception, exit the loop
break
except Exception as e:
print(e)
try:
# check status and print the result
print("Success!!")
print("-------------")
print("And the result is:",response.content)
print("-------------")
js = json.loads(response.content)
print("Date:",js["now"]["rfc2822"][:16])
print("Time:",js["now"]["rfc2822"][17:])
except Exception as e:
print("ooops, something very wrong! :(",e)
This is a very basic example of the capabilities of 4zerobox. Take a look at the campaign page for more video examples about RS232 and RS485 communications, LoRa, AWS and Google Cloud IoT connections!
Comments
Please log in or sign up to comment.