ESP8266 issues starting out

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
SEJeff
Posts: 2
Joined: Sun Oct 18, 2015 4:27 pm

ESP8266 issues starting out

Post by SEJeff » Sun Oct 18, 2015 4:54 pm

Being new to hardware, but not to unix, software, or python, I figured I'd give micropython a go on my shiney new ESP8266 board.

I'd like to replicate something like this, but write the various bits as python modules entirely. If it requires a bit of C to get it going, that is fine as well.

I've connected the board to my Fedora laptop and flashed micropython onto it successfully. I'm attempting to follow this tutorial on adafruit to connect to a wifi network using

Code: Select all

esp.connect(SSID, PASSWORD)
, but my esp module doesn't even have a connect function at all. Either that tutorial is outdated or (more likely) I'm using the wrong version of micropython.

Code: Select all

>>> import os
>>> os.uname()
(sysname='ESP8266', nodename='ESP8266', release='\x0e5\t\x1f\rP\x03\x07', version='v1.4.6-104-g7799410 on 2015-10-18', machine='ESP module with ESP8266')
>>> import esp
>>> esp.
__name__        mac             getaddrinfo     wifi_mode
phy_mode        sleep_type      deepsleep       flash_id
socket          MODE_11B        MODE_11G        MODE_11N
SLEEP_NONE      SLEEP_LIGHT     SLEEP_MODEM     STA_MODE
AP_MODE         STA_AP_MODE
>>> esp.connect
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: no such attribute
I'm using the latest micropython git master @ sha 779941095064efa0be8eca339f866311e19d9c0d updated as of ~2 minutes ago. Is there something I'm missing? I followed micropython.git/esp8266/README for instructions on flashing and it all seemingly worked fine.

How does one connect to the wireless using the esp module and what have I done wrong? Thanks!

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: ESP8266 issues starting out

Post by platforma » Sun Oct 18, 2015 8:01 pm

Hey!

There's a module called network, which has functions like connect/disconnect/isconnected. You might also want to look through the code in modnetwork.c and modesp.c to find out more about it. Unfortunately there's not a lot of solid documentation for esp because it changes frequently. Some of the things from the New Hardware API are also relevant, like WLAN functions, but not all are implemented.

mianos
Posts: 84
Joined: Sat Aug 22, 2015 6:42 am

Re: ESP8266 issues starting out

Post by mianos » Sun Oct 18, 2015 9:31 pm

What temperature sensor are you using? The HDC1000 as per that example or a plain old DHT? If you are using a DHT I have most of that example working without the MQTT library (I am just posting JSON).

SEJeff
Posts: 2
Joined: Sun Oct 18, 2015 4:27 pm

Re: ESP8266 issues starting out

Post by SEJeff » Sun Oct 18, 2015 11:35 pm

Perfect thanks! The network module does the trick and I'm all connected.

For temperature / humidity sensors, I've got an HDC1008 from adafruit. POSTing json would work fine as I've got home-assistant running on a raspberry pi, and could write either a small flask mini-app to receive the sensor values, or figure something else.

Mind sharing your code regardless?

Is there a thread where some of the esp8266 development communication is going on, or is it just random people making different changes?

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: ESP8266 issues starting out

Post by platforma » Mon Oct 19, 2015 12:38 pm

SEJeff wrote: Is there a thread where some of the esp8266 development communication is going on, or is it just random people making different changes?
It's pretty much the latter. But people tend to open discussions here on a particular topic and update them as the development goes on. Otherwise, discussions happen in the pull requests of micropython github.

danielm
Posts: 158
Joined: Mon Oct 05, 2015 12:24 pm

Re: ESP8266 issues starting out

Post by danielm » Tue Oct 20, 2015 12:11 pm

Few question related to MicroPython running on ESP8266:
- is it possible to boot from SD-card in SDIO mode and "mount" it to the file system?
- is it possible to use SPI interface?

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: ESP8266 issues starting out

Post by platforma » Tue Oct 20, 2015 10:00 pm

danielm wrote: - is it possible to boot from SD-card in SDIO mode and "mount" it to the file system?
Do you have a module with SD card? I didn't know they exist yet. Short answer is no, you can't. Long answer is, once the fatfs is implemented for the ESP8266 port then you'd be able to use the os.mount function as you would normally in any other micropython project. I have started the port recently but had to postpone it due to my primary job plus the arrival of wipy! See this PR. Whenever I find time to do it, or someone else picks up, there will be more progress.
danielm wrote: - is it possible to use SPI interface?
I don't think this has been implemented yet either.

mianos
Posts: 84
Joined: Sat Aug 22, 2015 6:42 am

Re: ESP8266 issues starting out

Post by mianos » Wed Oct 21, 2015 9:12 am

danielm wrote:Few question related to MicroPython running on ESP8266:
- is it possible to boot from SD-card in SDIO mode and "mount" it to the file system?
- is it possible to use SPI interface?
There is no SD card on mine. I was thinking, considering it has native wifi, I'd rather make it read the python from a web service like filesystem.
Which SPI anyway? The GPIO/SPI (that you could put an arduino SPI micro-sd card on) or the quad rate SPI the flash ROM is on?
The normal SPI can be used but I have not used it much yet. I copied some code from an arduino C driver but it had lots of busylooping and seemed a bit flakey.
You can use the SPI to the flash ROM fine if you only read or write on full word boundaries.

(I have run out of RAM on mine so I'm converting the frozen module to use the SPI FLASH by packing the ascii python into words then unpacking them as ascii into the lexer).

danielm
Posts: 158
Joined: Mon Oct 05, 2015 12:24 pm

Re: ESP8266 issues starting out

Post by danielm » Wed Oct 21, 2015 11:22 am

Looking at this table http://www.esp8266.com/wiki/lib/exe/det ... ctions.png
(from this page http://www.esp8266.com/wiki/doku.php?id ... llocations)
I was thinking to use GPIOs 6-11 for connection to SD card and GPIOs 12-15 for connection of external SPI ICs.

However there is probably no ESP module with GPIOs 6-11 available on breakout connectors.
http://image.slidesharecdn.com/esp8266w ... 1426474255

That means that for prototyping purposes I would probably need to desolder the flash and get GPIOs 6-11 from there, am I right?

This breakout could be used as SD-card slot: http://www.aliexpress.com/item/Micro-SD ... 59433.html

danielm
Posts: 158
Joined: Mon Oct 05, 2015 12:24 pm

Re: ESP8266 issues starting out

Post by danielm » Wed Oct 21, 2015 12:14 pm

ESP8266-12E seems to have those pins broken out:
http://www.esp8266.com/viewtopic.php?f=13&t=3023
http://www.aliexpress.com/store/product ... 61197.html

I guess it should be possible to connect SD-card via those pins if some other Chip-Select/GPIO pin was used than the one that onboard flash is using.

Post Reply