How To Build Internet-Connected Electronics Projects (WKS-IOT1)

This is a placeholder topic for “How To Build Internet-Connected Electronics Projects” comments.



In this workshop, each participant will build an internet-connected project to interact with electronics bits and pieces. We’ll then build a dashboard that is accessible from any smartphone (or PC) to control/view everything.

Read more

Please let me know whenever you start next round.

Thank you

Hi Pejman,

These typically run every six weeks. Keep an eye on the website for when the next ones become bookable!

I am working my way through the Core electronics tutoria
l “How to Build Internet-Connected Electronics Projects

All had gone well till when I get to “06 SEND LIGHT TO ADAFRUIT IO”
I just started again with a fresh download 15/3/2020 from:
https://github.com/CoreElectronics/iot-workshop/archive/master.zip

I unzipped, started a new project on Visual Studio/Platform.io
The board I am using is a FiPy which is not a listed board yet, so I chose LoPy as the closest. COULD THIS BE A PROBLEM?
I pasted the content of “Send Light to Adafruit IO.py” to a new file and named it “Send Light to Adafruit IO.py”
Without any editing, and before running or up loading I got the following error message:

invalid syntax (, line 31) pylint(syntax-error) [31,1]

Line 31 is:
< print("Publishing: {0} to {1} … ".format(str(value_string), feed), end=‘’)>

When I Run the project the output is:

Running c:\Users\vere.nicolson\OneDrive - ardentleisure.com\Documents\PlatformIO\Projects\2ndTryIOT_Tute\src\Send Light to Adafruit IO.py

Traceback (most recent call last):
File “”, line 57, in
NameError: name ‘pycom’ isn’t defined

Pycom MicroPython 1.20.1.r1 [v1.11-e4465eb] on 2019-10-23; FiPy with ESP32
Pybytes Version: 1.1.2
Type “help()” for more information.

When I upload the project the output is:

Uploading project (main folder)…
Not safe booting, disabled in settings

Uploading to /flash…
Reading file status
Deleting 2 files/folders
Removing file src/SimpleTute.py
Removing file lib/umqtt.py
[1/1] Writing file src/Send Light to Adafruit IO.py (3kb)
Upload done, resetting board…
OKets Jun 8 2016 00:22:57

rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff8020,len:8
load:0x3fff8028,len:2164
load:0x4009fa00,len:19944
entry 0x400a05e8
Pycom MicroPython 1.20.1.r1 [v1.11-e4465eb] on 2019-10-23; FiPy with ESP32
Pybytes Version: 1.1.2
Type “help()” for more information.

After upload run again, get output:

Traceback (most recent call last):
File “”, line 7, in
ImportError: no module named ‘umqtt’

Pycom MicroPython 1.20.1.r1 [v1.11-e4465eb] on 2019-10-23; FiPy with ESP32
Pybytes Version: 1.1.2
Type “help()” for more information.

In the tute it says:
" Bummer. Remember I said we would use MQTT to talk to Adafruit IO? Well, our project has the file umqtt.py hidden in the lib folder,
but that file isn’t on the device yet. We need to click Upload.
This will put all the files from our project onto our device. Now. Now hit Run!"

Tried this and it didn’t work. (Because I had not used Atom as the Tute had done, I tried but there was a problem, now forgotten)
Then I copied the contents of umqtt.py from the lib folder into the Platform.io project and tried again.
there were then 4 more errors:
Unable to import ‘usocket’ pylint(import-error) [3, 1]
Unable to import ‘ustruct’ pylint(import-error) [4, 1]
Unable to import ‘ubinascii’ pylint(import-error) [5, 1]
Unable to import ‘ussl’ pylint(import-error) [62, 13]

I have searched extensively for these libraries and have not been able to find them.
Any suggestions what I should try next?

Cheers
Vere Nicolson

1 Like

Hey Vere,

Have you checked to see whether there may be any appropriate substitute libraries? It’d likely require some large scale script editing, but wouldn’t be impossible. Also be sure to follow the tutorial as accurately as possible, as any syntax errors would cause the whole system to fail, be sure to test each individual system if possible. Please let us know how you go!

All the best with it!

Bryce
Core Electronics | Support

All the “unable to import” messages refer to missing microPython libraries. Make sure you have copied them to the device, in the same way as you copied the mqtt library.

Thanks for your responses.
My post was already pretty big and boring so I neglected to add that I can’t find these dependent libraries anywhere. I have googled and looked through several github repositories but can’t find them. I also did another tute;


and ended up lacking the same libraries.
anyone have a suggestion where to download them from?

Cheers
Vere Nicolson

1 Like

Since these missing libraries look like standard libraries for microPython, they should already be on the board. If they are not, then looks like time to reinstall the firmware.

1 Like

Just updated the firmware as suggested.
Still have the same 4 errors originating from umqtt.py
This version of umqtt.py is the one downloaded with the one in the tutorial zip
but I get the same errors the version from Pycom on github;

micropython-lib/umqtt.simple/ umqtt /

I don’t know how to check if the 4 missing libraries ;
usocket, ustruct, ubinascii and ussl
are now on the board as part of the firmware.

Is there a problem with lines 3,4,&5 not saying where to import FROM
like it does in the tutorial code?

I see trouble coming with syntax in line 31 but that seems unrelated and I was going to deal with that in turn

Thanks again for your suggestions.

Any more ideas about these libraries, was there any issue with these when writing the tute?

Cheers
Vere

OK. Assuming that you are using VS Code, and a PyCom board, with the PyMaker correctly installed, then you may need to disable pylint.

Pylint tried to check the source, which isn’t available. These modules are part of the firmware. Refer to the following threads:


Hello Robin57159,
I changed back to using Atom and I have not had the pylint/missing libraries problem however I have hit the next obstacle.
when I upload and run the code I get this output;

Traceback (most recent call last):
File “”, line 57, in
NameError: name ‘pycom’ isn’t defined

Pycom MicroPython 1.20.2.rc6 [v1.11-01f49f7] on 2020-02-28; FiPy with ESP32
Pybytes Version: 1.3.1
Type “help()” for more information.

Where do I find this file “stdin”?
and why does it not define “pycom” as expected?
What should I read to understand and fix this?

Cheers
Vere

Woops, just noticed that line 56
“pycom.heartbeat(False)”
mentions pycom
I am familiar with defining functions in Arduino but thought that was not required in Python.
How do I define this ?function? or should it be done in a library?

Cheers
Vere

Where did you import the pycom module?
Consider the python import function to be analogous to the #include <library.h> of the Arduino sketch.

The pycom module is part of the firmware of the PyCom board, but you still need to import it if you use the functions it provides.

Refer to the documentation here:

https://docs.pycom.io/firmwareapi/pycom/pycom/

2 Likes

I actually got past this point, but had a couple of months off and have now got stuck at the same spot. Although umqtt.py is in the lib folder, and it should be imported, it comes up as “ImportError: no module named ‘umqtt’”

1 Like

I fixed this by taking away the extra directory layer away.
it had been IoT-Workshop/IoT-Workshop-Master/the-useful-files so maybe the lib folder was not where it expected it to be ???

1 Like

Hey Vere,

Yes, when updating relative paths it’s always best to back-check for compatibility, but sometimes that can be convoluted and missed. Glad to hear that fix in the script has worked though.

Bryce
Core Electronics | Support

1 Like