Oled and Led on an esp01

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
modulusmath
Posts: 30
Joined: Thu Jun 30, 2022 3:21 am

Oled and Led on an esp01

Post by modulusmath » Tue Jul 26, 2022 3:40 am

Good day!

I have successfully loaded uP 1.19 on an esp01 and can get it to write text to an OLED and blink and LED if I bread board them separately:

Code: Select all


Esp-01 to OLED on bread board
https://www.instructables.com/I2C-With-the-ESP8266-01-Exploring-ESP8266Part-1/

Connect USB / FTDI programmer to esp-01 and then to OLED:

esp01 OLED
IO2   sda
IO0   scl

esp-01 pin map
https://www.theengineeringprojects.com/wp-content/uploads/2019/03/introduction-to-esp-01.jpg

and

Code: Select all


Esp-01 to LED on bread board
https://learn.adafruit.com/micropython-basics-blink-a-led/blink-led
(resistor not esp01 pic)


1. Use an FTDI USB  programmer on the esp01
2. Connect "IO0" via  female to male jumper to led on the  bread board
3. Connect Led to 2k resistor
4. Connect Resistor to "IO2"

esp-01 pin map
https://www.theengineeringprojects.com/wp-content/uploads/2019/03/introduction-to-esp-01.jpg
https://www.aliexpress.com/item/3256801133502533.html?gatewayAdapt=4itemAdapt


Both the above work beautifully. Separately. I can also connect to the 'net no problem. My goal is to turn on an led if temp is > 80 given the weather data I am pulling off the net.

So now, I try to combine - I guess the first question -- is that a fool's errand? I *seem* to be pretty close.


How I tried set it up:

I connect the LED to TX (pin 2 of the esp01) to the anode, or longer leg, of the LED. The cathode, or shorter leg, of the LED is connected to one side of a 2k resistor. The other side of the resistor is connected to the board's ground or GND pin.

So esp (Tx) ==> short leg LED => longer leg LED => 2k R => GRND. GRND is also connected to GRND of the OLED.
Basically following https://learn.adafruit.com/micropython- ... d/hardware

In my mind the TX should be the 'driver' that turns the led on/off and I believe it is Pin 2, based on the esp01 pin mapping above.
On boot the LED is ON, won't turn off, but when I attempt to blink:

myled = machine.Pin(X, machine.Pin.OUT)

X:
1 Lights up the led but HANGS the repl
Both 0, 4 and 5 flickers led
3 hangs Thonny entirely
6, 7, and 8 all given "ValueError: invalid pin

I don't think this means much b/c if I just hit enter in thonny , the led flickers. So really I'm just trying things b/c I don't really know what resource I should trust. Hence I tried a bunch of things, and the board only cost like 2 bucks..

I can still write to the OLED and access the 'net. Am I close or is it like I'm way off?

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Oled and Led on an esp01

Post by davef » Tue Jul 26, 2022 4:08 am

It has been a year or so since I was used a ESP-01, but isn't GPIO2 used for booting the device.

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Oled and Led on an esp01

Post by scruss » Tue Jul 26, 2022 2:40 pm

modulusmath wrote:
Tue Jul 26, 2022 3:40 am
I can still write to the OLED and access the 'net. Am I close or is it like I'm way off?
I honestly believe there aren't enough pins on an ESP-01 to do this.

How about rendering the OLED display in inverse video if it's over your warning temperature? It's kind of a big LED, after all ...

modulusmath
Posts: 30
Joined: Thu Jun 30, 2022 3:21 am

Re: Oled and Led on an esp01

Post by modulusmath » Tue Jul 26, 2022 9:30 pm

davef wrote:
Tue Jul 26, 2022 4:08 am
It has been a year or so since I was used a ESP-01, but isn't GPIO2 used for booting the device.
I think so. I have not taken any steps to actively make it work like setting it high, apart from following online guides.

modulusmath
Posts: 30
Joined: Thu Jun 30, 2022 3:21 am

Re: Oled and Led on an esp01

Post by modulusmath » Tue Jul 26, 2022 9:34 pm

scruss wrote:
Tue Jul 26, 2022 2:40 pm
modulusmath wrote:
Tue Jul 26, 2022 3:40 am
I can still write to the OLED and access the 'net. Am I close or is it like I'm way off?
I honestly believe there aren't enough pins on an ESP-01 to do this.

How about rendering the OLED display in inverse video if it's over your warning temperature? It's kind of a big LED, after all ...
Actually, that makes me feel better. It seemed like a good way to push my learning forward, but if it's just not going to work, I'm glad I know now.... Thanks for the reply! I definitely see there are 8 pins so in my mind, I gave it a shot.

I like your idea about the OLED, a great thought...thanks!

I imagine it's a breeze on a different board but there's something very fun about that tiny esp01...

Thanks again

Jibun no kage
Posts: 144
Joined: Mon Jul 25, 2022 9:45 pm

Re: Oled and Led on an esp01

Post by Jibun no kage » Fri Aug 05, 2022 12:48 am

@modulusmath,

Could you share how you got MicroPython working on an ESP01? I have been trying to get it working as well, but I can't seem to get to the REPL at all after what I believe is successful flash?

Here is what I have tried:

# esptool.py --chip esp8266 --port /dev/ttyUSB0 flash_id

# esptool.py --chip esp8266 --port /dev/ttyUSB0 erase_flash

# esptool.py --chip esp8266 --port /dev/ttyUSB0 write_flash --flash_size=detect 0 ./esp8266-20220802-unstable-v1.19.1-229-g579f33050.bin

# esptool.py --chip esp8266 --port /dev/ttyUSB0 verify_flash --flash_size=detect 0 ./esp8266-20220802-unstable-v1.19.1-229-g579f33050.bin

# screen /dev/ttyUSB0 115200

But using screen, or Thonny or anything else so far, no active connection to REPL? I think you may have figured out the step that I have not to get REPL working? I have tried all the supported flash modes, but maybe I missed something that you did that worked?

EmilyPearson
Posts: 10
Joined: Sat Aug 06, 2022 1:44 am
Location: Austin, TX

Re: Oled and Led on an esp01

Post by EmilyPearson » Wed Aug 10, 2022 10:46 pm

Hi!

I recently successfully flashed two ESP-01s using esptool.py hosted on a MacBook Pro.

My connection to the ESP-01 was through a Sparkfun serial breakout but probably any breakout will work. I’ve attached a schematic of my hookup that might help. Ignore the connection for the OLED display. The line labeled “Boot” should be grounded while you power up the board. Release the ground on “Boot” after you apply power. Make sure your serial breakout supplies 3.3V to power the ESP.

I then ran:

Code: Select all

 esptool.py --port /dev/cu.usbserial-1410 erase_flash
You should replace the port with whatever yours is. There will be some text generated by esptool that will tell you if erasing the ESP was successful. Don’t proceed to the next step if this is not successful.

After a successful flash, i went through the procedure of grounding and ungrounding “Boot” again while powering the board. I don’t know if that is strictly necessary but doesn’t hurt. I then ran:

Code: Select all

 esptool.py --port <your port> --baud 115200 write_flash --flash_size=detect 0 <path to your esp8266 binary>
Edit the command line to reflect your port and binary path. Again, you will get lots of text from esptool indicating its progress. If this is successful you can load Thonny and power cycle the ESP and you should see that Thonny has loaded the esp8266 interpreter. It’s possible you will have to load it manually although my install recognizes the chipset automatically.





test jig sch.jpeg
test jig sch.jpeg (9.8 KiB) Viewed 26347 times

modulusmath
Posts: 30
Joined: Thu Jun 30, 2022 3:21 am

Re: Oled and Led on an esp01

Post by modulusmath » Tue Aug 16, 2022 4:17 pm

Jibun no kage wrote:
Fri Aug 05, 2022 12:48 am
@modulusmath,

Could you share how you got MicroPython working on an ESP01? I have been trying to get it working as well, but I can't seem to get to the REPL at all after what I believe is successful flash?

Here is what I have tried:

# esptool.py --chip esp8266 --port /dev/ttyUSB0 flash_id

# esptool.py --chip esp8266 --port /dev/ttyUSB0 erase_flash

# esptool.py --chip esp8266 --port /dev/ttyUSB0 write_flash --flash_size=detect 0 ./esp8266-20220802-unstable-v1.19.1-229-g579f33050.bin

# esptool.py --chip esp8266 --port /dev/ttyUSB0 verify_flash --flash_size=detect 0 ./esp8266-20220802-unstable-v1.19.1-229-g579f33050.bin

# screen /dev/ttyUSB0 115200

But using screen, or Thonny or anything else so far, no active connection to REPL? I think you may have figured out the step that I have not to get REPL working? I have tried all the supported flash modes, but maybe I missed something that you did that worked?
Sure - I used this little genius device:

https://www.amazon.com/gp/product/B08QMMGZLB/

I don't recall any issue once it was hooked up correctly and used Thonny to flash it

Jibun no kage
Posts: 144
Joined: Mon Jul 25, 2022 9:45 pm

Re: Oled and Led on an esp01

Post by Jibun no kage » Tue Aug 16, 2022 6:57 pm

Yeah, in my case the following worked:

1) Full erase before flash
2) Flash either 512K or 1M MP image with mode as DOUT
3) Of course you have to make sure ESP01 is on 'flash' mode/programming mode

For some reason the ESP01s I had required DOUT mode. None of my ESP32 or ESP8266 (MCU, etc.) variants needed explicitly DOUT mode.

Post Reply