Search code examples
pythonlcdmicropythonseven-segment-display

ESP8266 rshell repl freezes


I wanted to define some pin variables before experimenting with a seven-segment 4-digit display which is connected to my ESP8266. On the interpreter, the following lines of code work fine, and they do not raise any errors:

from machine import Pin
OUT = Pin.OUT

Whenever I try to define a pin variable using the machine.Pin class, the entire repl freezes:

a = Pin(1, OUT)

It would just hang there:

Screenshot

I have tried this on two separate ESP8266 boards, so it is unlikely that the problem has to do with the board being poorly soldered...

This is my current setup:

Photo 1 Photo 2

These are the variables and pin numbers that I intend to use:

from machine import Pin
OUT = Pin.OUT

a = Pin(1, OUT)
b = Pin(3, OUT)
c = Pin(15, OUT)
d = Pin(13, OUT)
e = Pin(12, OUT)
f = Pin(14, OUT)
g = Pin(2, OUT)
dec = Pin(0, OUT)

digit1 = Pin(4, OUT)
digit2 = Pin(5, OUT)
digit3 = Pin(16, OUT)
digit4 = Pin(10, OUT)

I have searched around and have not found anything that matches my case. Perhaps both of the boards that I have tried have bad soldering?

My setup is inspired by this video. Something that I found odd about his setup was that every single pin was configured for digital output. Are ground pins unnecessary with this setup?

UPDATE (Yes, while writing this post): I have changed my code to the following:

from machine import Pin
OUT = Pin.OUT

digit1 = Pin(4, OUT)
digit1.on()

digit2 = Pin(5, OUT)
digit2.on()

digit3 = Pin(16, OUT)
digit3.on()

digit4 = Pin(10, OUT)
digit4.on()

Digits 1 to 3 seem to load fine, but when I get to digit4, I get the following output:


 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x40100000, len 31088, room 16
tail 0
chksum 0x44
load 0x3ffe8000, len 1028, room 8
tail 12
chksum 0x1e
ho 0 tail 12 room 4
load 0x3ffe8410, len 824, room 12
tail 12
chksum 0x89
csum 0x89
���2�n��s��N|�$l$l`c��|{��l�N��N�d ��r�l�l2�$`��s�p��l�l`��{�p���� l`rl���c ���c#��c|l#���B|����l$b��N�2Nn� �$N� ��$�� $l����l`�n� ����Bll����2"��l�crls$r�o�� � ��o����"�����#��
MicroPython v1.12 on 2019-12-20; ESP module with ESP8266
Type "help()" for more information.
>>>

Solution

  • As noted in the comments, pins 1 & 3 are tx0, rx0 used for serial communication, so not usable during serial transmission. Pins 6-11 are used for flash communication so are not usable at all. See the pin allocation table here... https://tttapa.github.io/ESP8266/Chap04%20-%20Microcontroller.html