I had been using Arduino IDE from Raspbian to test simple GPIO write() to turn on and off an led. Then I found pymata_express that creates a communication framework on the Arduino device. The catch was how to test it? Best fun is to use CLI. Here is a sample code that established the communication:
pi@raspberrypi:~/MicroPython_ESP8266 $ python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>>
>>> import asyncio
>>> from pymata_express.pymata_express import PymataExpress
>>> board = PymataExpress()
Pymata Express Version 1.6
Copyright (c) 2018-2019 Alan Yorinks All rights reserved.
Opening all potential serial ports…
/dev/ttyUSB0
Waiting 4 seconds(arduino_wait) for Arduino devices to reset…
Searching for an Arduino configured with an arduino_instance = 1
Arduino found and connected to /dev/ttyUSB0
Retrieving Arduino Firmware ID…
Arduino Firmware ID: 2.5 FirmataExpress.ino
Auto-discovery complete. Found 18 Digital Pins and 1 Analog Pins
>>>
That response on the last line gave me the confidence to download the sample code from https://github.com/MrYsLab/pymata-express/blob/master/examples/digital_output.py
To match the requirement of my Wemos D1 Mini, I just modified code on line 51:
loop.run_until_complete(blink(board, 9))
to:
loop.run_until_complete(blink(board, 2))
That shows the LED on board and also my external led was connected to GPIO 2 or D4. (check that in Wemos docs)
Now run the sample code:
pi@raspberrypi:~/MicroPython_ESP8266 $ python3 pymata_test_blibk.py
Pymata Express Version 1.6
Copyright (c) 2018-2019 Alan Yorinks All rights reserved.
Opening all potential serial ports…
/dev/ttyUSB0
Waiting 4 seconds(arduino_wait) for Arduino devices to reset…
Searching for an Arduino configured with an arduino_instance = 1
Arduino found and connected to /dev/ttyUSB0
Retrieving Arduino Firmware ID…
Arduino Firmware ID: 2.5 FirmataExpress.ino
Auto-discovery complete. Found 18 Digital Pins and 1 Analog Pins
ON
OFF
ON
OFF
ON
OFF
ON
OFF
pi@raspberrypi:~/MicroPython_ESP8266 $
Now I am ready for some Robotics using ESP8266!!
Here are the goodies:
1. You are using the new Python 3 I have Python 3.7.3
2. pymata_express uses ZMQ and associated libraries, which will be good for learning.
3. Need to learn how to accomplish this using WiFi (I have not yet tried)
Recent Comments