How to switch on a electric bulb with ESP8266 board?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
jimmo
Posts: 309
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: How to switch on a electric bulb with ESP8266 board?

Post by jimmo » Sat Jun 15, 2019 7:39 am

This is quite common, the LED is connected between Vcc and the pin. (Some microcontrollers are capable of doing this at a higher current than the other way around).

RajaRamesh
Posts: 51
Joined: Wed May 08, 2019 10:54 am

Re: How to switch on a electric bulb with ESP8266 board?

Post by RajaRamesh » Sat Jun 15, 2019 12:25 pm

RajaRamesh wrote:
Wed Jun 05, 2019 7:07 am
pythoncoder wrote:
Wed May 29, 2019 8:33 am
Assuming you have the LED working as per the advice of @jimmo, you need something like
The RTC on the ESP8266 is notoriously inaccurate. You might want to use similar logic to call settime() once at (say) 4:00.
Thank you for sharing the details pythoncoder. i will try and get back to you if i face any issues.
Hi pythoncoder, i changed from hour to mins as below and LED blinks with the logic shared by you. is it possible to implement same logic without ntptime function?

for mins,
led_on=False
if t[5]<15 and not led_on:
led_on=True
pin.on()
if t[5]>=15 and led_on:
led_on=False
pin.off()

RajaRamesh
Posts: 51
Joined: Wed May 08, 2019 10:54 am

Re: How to switch on a electric bulb with ESP8266 board?

Post by RajaRamesh » Sat Jun 15, 2019 12:26 pm

jimmo wrote:
Sat Jun 15, 2019 7:39 am
This is quite common, the LED is connected between Vcc and the pin. (Some microcontrollers are capable of doing this at a higher current than the other way around).
ok....jimmo

User avatar
pythoncoder
Posts: 3449
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: How to switch on a electric bulb with ESP8266 board?

Post by pythoncoder » Sun Jun 16, 2019 8:32 am

@RajaRamesh The ntptime module is merely used to initialise the RTC. If you have an internet connection it's the obvious way to do it, but you can set it by any means you wish. Note that the RTC on the ESP8266 is not very accurate and it may need setting at regular intervals.
Peter Hinch

RajaRamesh
Posts: 51
Joined: Wed May 08, 2019 10:54 am

Re: How to switch on a electric bulb with ESP8266 board?

Post by RajaRamesh » Mon Jun 17, 2019 7:41 am

pythoncoder wrote:
Sun Jun 16, 2019 8:32 am
@RajaRamesh The ntptime module is merely used to initialise the RTC. If you have an internet connection it's the obvious way to do it, but you can set it by any means you wish. Note that the RTC on the ESP8266 is not very accurate and it may need setting at regular intervals.
Ok...pythoncoder. is it possible to pass a parameter to ESP8266 externally? like for example, in below code can we send value to ' a ' variable.

a= input('value')
b= 2
print(a+b)

User avatar
pythoncoder
Posts: 3449
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: How to switch on a electric bulb with ESP8266 board?

Post by pythoncoder » Mon Jun 17, 2019 8:07 am

I'm not sure what you're asking. That code would work on an ESP8266.

If you're planning to use that technique to set the RTC manually you could input a time/date string but you'd need to parse it in code and do some validation.

In considering ways to compensate for RTC drift you need to consider the effect on your program of sudden jumps in RTC time. Doing regular updates from internet timeservers is the safest way to keep time on track: update the RTC before it has time to drift far enough to affect your application.
Peter Hinch

RajaRamesh
Posts: 51
Joined: Wed May 08, 2019 10:54 am

Re: How to switch on a electric bulb with ESP8266 board?

Post by RajaRamesh » Mon Jun 17, 2019 1:20 pm

pythoncoder wrote:
Mon Jun 17, 2019 8:07 am
I'm not sure what you're asking. That code would work on an ESP8266.
Hi pythoncoder, below screenshot may give an idea what i am trying to say. is it possible to pass a value from external device at runtime to ESP8266 ?
image.png
image.png (222.98 KiB) Viewed 156 times

User avatar
pythoncoder
Posts: 3449
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: How to switch on a electric bulb with ESP8266 board?

Post by pythoncoder » Mon Jun 17, 2019 5:51 pm

There are many ways to do it, depending on the electronic interface of the device. MicroPython supports various interfaces: UARTs, I2C, SPI, CAN or simply changing Pin inputs. There are also drivers for various devices, some official, some contributed by users. UARTs are somewhat problematic on ESP8266 because the hardware only has one proper UART: this is used for the REPL.
Peter Hinch

RajaRamesh
Posts: 51
Joined: Wed May 08, 2019 10:54 am

Re: How to switch on a electric bulb with ESP8266 board?

Post by RajaRamesh » Tue Jun 18, 2019 9:11 am

pythoncoder wrote:
Mon Jun 17, 2019 5:51 pm
There are many ways to do it, depending on the electronic interface of the device. MicroPython supports various interfaces: UARTs, I2C, SPI, CAN or simply changing Pin inputs. There are also drivers for various devices, some official, some contributed by users. UARTs are somewhat problematic on ESP8266 because the hardware only has one proper UART: this is used for the REPL.
So, could you please share the electronic device names or share the links where i can get an idea. so that i will try to send values to ESP8266 and then display the output on LCD screen.

User avatar
pythoncoder
Posts: 3449
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: How to switch on a electric bulb with ESP8266 board?

Post by pythoncoder » Tue Jun 18, 2019 9:49 am

The Wiki http://wiki.micropython.org/Home has links to drivers for a variety of devices. You can also search this forum.
Peter Hinch

Post Reply