Jan 15, 2015 Tag: Arduino
Ongoing attempt to collect know how about the Arduino. Will be updated as needed.
Updated on Nov 24, 2018
Overview:
And: FTDI-Adapter
Download from: https://www.micropython.org/download#esp8266
esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash \
--flash_size=detect 0 esp8266-20180511-v1.9.4.bin
Nodemcu:
esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash \
--flash_size=detect -fm dio 0 esp8266-20180511-v1.9.4.bin
2018-11-17, Andreas Spiess, YouTube: Time to Say Goodbye to Arduino and Go On to Micropython / Adafruit Circuitpython?
2018-08-24, Damien George, PyCon Australia: Writing fast and efficient MicroPython
2017-11-27, Python Ireland, YouTube: Steve Holden: Pycon Ireland 2017: MicroPython: The Next Step to World Domination
2017-08-04, PyCon Australia, Anna Gerber (blog): Program all the things - How to develop IoT devices using MicroPython
Boards: Adafruit Feather HUZZAH ESP8266, WeMos D1 mini, Nodemcu
Hit ctrl+e to enter paste mode, leave with ctrl+d
Use Adafruit’s ampy to upload or manage python program files on the board: https://github.com/adafruit/ampy
ampy --port /dev/ttyUSB0 put demo.py
Start WebREPL: https://youtu.be/8Uw1UW0_nHE?t=769 | https://micropython.org/webrepl/
https://docs.micropython.org/en/latest/esp8266/quickref.html
2017-08-04, PyCon Australia, Damien George: Using MicroPython in the wild
2017-07-16, rdagger68, YouTube: ESP32 MicroPython Tutorial with Raspberry Pi
2016-09-20, GOTO Conferences, YouTube: Damien George: MicroPython & the Internet of Things
2016-06-01, PyCon 2016: Lightning Talks - 2016-05-31PM
2016-04-18, Adafruit Industries: MicroPython on Feather ESP8266 pt. 2 with Tony D! @adafruit #LIVE <https://www.youtube.com/watch?v=gBumLl6Phsc>
2016-04-11, Adafruit Industries: MicroPython on Feather ESP8266 with Tony D! @adafruit #LIVE
Required: Nodemcu with MicroPython, laptop, mosquitto (sudo apt install mosquitto mosquitto-clients)
Power up the Nodemcu. Do not connect usb cable. We want to work “over the air” only. We have enabled the Webrepl before and gave it a password.
The Nodemcu will open up a WiFi network named MicroPython-nnnnnn. Pick your laptop and connect to that network. The WiFi WPA2 password is: micropythoN - note the capital ‘N’.
Verify the network is working on your laptop and find the ip and watch out for the ip. Usually it would be 192.168.4.2:
➜ route
should show a line with a route to 192.168.4.0
➜ hostname -I
192.168.1.207 192.168.4.2 172.18.0.1 172.17.0.1
Our laptop will work as server and mqtt broker. Start the mqtt broker in a terminal window:
➜ mosquitto -p 11883 -v
In a second terminal window on the laptop run an mqtt client and subscribe to the house topic:
➜ mosquitto_sub -h 192.168.4.2 -p 11883 -t "house/#" -v
➜ # or
➜ mosquitto_sub -h 127.0.0.1 -p 11883 -t "house/#" -v
In a third terminal window on the laptop now publish some mqtt messages:
➜ mosquitto_pub -h 192.168.4.2 -p 11883 -t house/s1 -m "a msg from s1"
➜ mosquitto_pub -h 192.168.4.2 -p 11883 -t house/s2 -m "a msg from s2"
Now let’s connect to the webrepl of the Nodemcu. Go to http://micropython.org/webrepl/ (NO https - just http!), or, if you have that installed before on your machine, go to a local copy of webrepl at http://localhost/webrepl/webrepl.html
Click ‘Connect’ and use the password you have set when enabling webrepl.
And ‘bingo’, you should be on the command line (Python repl) of your ESP8266:
>>> 2 + 2
4
Firewall? If you have that on your laptop, make sure that connections from the Nodemcu are allowed.
Publish a message from you ESP8266 Nodemcu over the air to the broker and let the broker do its job:
from umqtt.simple import MQTTClient
c = MQTTClient("umqtt_client", '192.168.4.2', port=11883)
c.connect()
c.publish('house/nodemcu', b'Ich bin da.')
#