Basically the idea is to store the LastState of a relay in the EEPROM , incase if power failure or reboot , it will have the laststate stored in the EEPROM and acts accordingly. But the problem here is NodeMcu has certain gpio sequence to boot up properly. Will the EEPROM make any difference in the boot up process ?
Actually NO! Once power cuts off or the device reboots , the relay comes into life even though it was in OFF condition. (For info : Am running local server). What ever the state was before the reboot will not remain the same after the reboot. So am planning to write the state to EEPROM and later read the state from it and act accordingly.
Any alternate way of getting this ?
EEPROM is initialized after boot sequence, so it still has no use because certain pins will go high/low or the other way around when the MCU boots. So it will always switch according to the state of pins during the boot.
And even if you run a local server, the state of the pin is saved on the server, you just have to use Blynk.Sync() to retrieve it.
If you want to escape all boot sequences or pin changes during that proces I think you need to look at a hardware solution. But I donât know how to do that. I think it can be done using a transistor and a big capacitor.
So as per your saying EEPROM doesnt help in retrieving the last state ! ??
What if the Local server (RPi3) reboots ? will it still remember the last state ?
That is hell of a kind to deal . It introduces other problems and PCB needs to be modified.(Tedious Job)
Can you please provide me with a example sketch for Blynk.sync(); ? I went through the community, but i was not able to understand and inject that to my code.
Iâm pretty sure it will not help. There are probably certain pins which stay low during boot and you should be able to use those with values stored in EEPROM, but Iâve always found the result to be sketchy at best (see what I did thereâŚ).
Yes, it will remember the pin state, even if it reboots. Amazing
Blynk.Sync is described in the docs. Basically itâs just Blynk.syncVirtual(pinnumber). So hence, it only syncs virtual pins, but thatâs not really an issue, you want to work with vPins anyway instead of actual physical pins due to their flexibility
will this sync with the hardware or with the app ? From the blynk.docs i came up with this.
Should i provide a new virtual pin or the existing the virtual pin used in the code ? After reading the Blynk docs i am confused (Should i give two virtual pins for sync and write ?)
So in your original sketch you chose to connect your relay to D0, which is GPIO 16.
Thatâs not a good choice of pin, as itâs one of those âspecialâ pins. See this post:
NdeMCU EEPROM has a limited life - the manufacturers say that each memory location should be good for around 100,000 write operations.
Your original code writes to EEPROM every 100 milliseconds (or 10 times per seconds) so after less than three hours of running this code you will have exceeded the probable life of the memory location youâre using.
As @Lichtsignaal says, the data is stored o the Blynk server anyway, so use of EEPROM in this situation gains you nothing.
I also find this a bit oddâŚ
So, on startup youâre reading the value from EEPROM and writing the value to the relay pin, then 10 milliseconds later overriding it by forcing it LOW. Why?
When people give you pointers to possible solutions, itâs time to take those suggestions and do a bit of experimenting, rather than asking âwill this workâ.
Yeah am aware of it. After so much of research am able to get it working. For boot up sequence there are some pins that have to be untouched or external resistors to pullup .
After @Lichtsignaal insisted not to use EEPROM, now am trying to use Blynk.sync .
Of course i am experimenting and trying out different options to get this working. âWill this workâ doesnt mean am totally depending on others ! its just can i move on with this or any better way of getting things simpler, Here we have many Awesome brains to guide us with innovative ways. Anyways sorry for that.
Thank you for the link. But thats not required. As @Lichtsignaal said i used Blynk.syncvirtual and got it working well⌠we need to try and play with the code, because adding an external converter module will just make the product more bulkier. And if proceeding with mass production, we cannot depend on these sought of modules.
@PeteKnight True. i had not thought of that .and thanks for the link about Gpioâs .
If youâre planning on doing that then you should sign-up to a Blynk plan and youâll get support with producing your firmware and app. https://www.blynk.io/plans/
The free version of Blynk isnât meant for commercial use.
Well, It depends on purpose! Sometimes it is just not allowed to trigger the pins during boot. For light controller it shouldnât matter. Although⌠If it had to trigger switch for a whole street lighting, then this short pulse could ruin thingsâŚ
And yes, syncing with server for non commercial purposes (or those commercial non critical) is fairly enough.
With this module >
Do we have the control to delay the triggering during the boot up process ? (5 sec of delay) . Ex: If it takes the device 5-6sec to boot completely and then sync up with the server, can we have the control to adjust the delay so that after everything boots up the relays or output devices start to respond .
Itâs just an example, but yes - it is possible. One of the features this chip has is the OE (output enable) pin, which controls all its outputs. It can disable the outputs (turn them into high impedance state). This input can then be controlled by either MCU (with carefully chosen GPIO) or an integrating RC circuit (preferably with Schmidt trigger on input)
Thatâs actually smart way. But in nodemcu we already have way too less gpoi to work with . And even that has limitations. By reserving pin for OE we will loose a pin .
But the module your are referring is best if dont want false triggers
Then there are I/O expanders Or ESP32. ALSO with RC integrator we are not loosing any pin ⌠EtcâŚ
Electronics is an art of engineering. I was always impressed how far it allows us to reachâŚ
@sourav this is a year old topic⌠and aside form the side trails, the general consensus seemed to simply use Blynk and its sync commands to ârememberâ a last known vPin state.
If you do have working code for saving and retrieving GPIO pin states from EEPROM upon boot, that can coexist with Blynk, then I recommend you great a new topic under the Projects made with Blynk category and include lots of details.
Better then reopening old topics that already have diverging subject matter.