BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Doubts to flash NodeMCU + Garden Project

You shouldn’t need to be soldering anything to the chip, just soldering-in the FTDI headers and finding the correct location to pull GPIO0 to earth while you’re powering it up.
If you hadn’t done it correctly from a hardware point of view then it wouldn’t flash to 100%.

What’s more likely is that you’ve chosen the wrong settings in the Arduino IDE.

I’ve asked twice, but I don’t see any info about the flash settings you used in the Arduino IDE, whether it’s connecting to Blynk or what output you’re getting in the Arduino IDE serial monitor, but don’t worry, I wont bother asking again.

In which case you’ll need to modify the sketch, and use SoftwareSerial to connect your Arduino and Wi-Fi modem.

Good luck.

Pete.

Hi Pete.

Finally I am not able to flash sonoff. Something happened at hardware level because now I cannot connect it again to my computer. No lights on. I think it died.

Then now I will go for Arduino which is easier to flash. I read your link about boards and due to my inexperience soldering, i am thinking to buy following board. What do you think?

My idea is to use the sketch from this link

From Hagay or Arizona users. Hagay used sonoff then I supposed I will need to change something in the sketch.

I will read more to make less questions.

Thks a lot for your support and sorry for bordering you.

It’s overpriced, but a much better choice than the Arduino Uno.

Pete.

Thks a lot Pete. I know but it is in my house in 1 day.

Which board I should select in Arduino IDE?

Thks again.

From the Amazon.es screenshot, it looks like a NodeMCU 1.0

Pete.

1 Like

Yes it seems

Already flashed and running well. It connects to internet and I can manage. The only doubt is how to change the time to Madrid one. Also when lights are on means the relay is closed and then the spark will be irrigating?

RTC widget.

Not quite sure what “spark” means, but it depends on whether your relays are active HIGH or active LOW.

Pete.

1 Like

In the code I have LOW. Maybe the problem is that the relays need 5V and the board only gives 3.3V. Here you have instructions

  • This relay module is 5V active low. Relay output maximum contact is AC250V 10A and DC30V 10A.
  • Standard interface can be directly connected with microcontrollers.
  • Working status indicator lights are conducive to the safe use
  • 4-channel relay interface board, which can be controlled directly by a wide range of microcontrollers such as Arduino, AVR, PIC, ARM, PLC, etc. It is also able to control various appliances and other equipments with large current.
  • Widely used for all MCU control, industrial sector, PLC control, smart home control.

4-channel relay output modules, relay output contacts 250A 10A.
Input IN1, IN2, IN3, IN4, the signal line LOW effective.
VCC, GND power input, can relay a separate power supply relay power input of JD-VCC.

It is possible to give it 5.5V using below pins but I am not sure how to do it.

If someone can help me.

How are you powering the relay board?

What pins on the NodeMCU are you using to connect to pins 1,2,3 and 4 on the relay board (refer to the pins by the D letters printed on the NodeMCU).

What pins have you specified in the code, and how have you referenced them in the code (by D number or by GPIO number)?

How are you powering the NodeMCU, and what are you doing with the ground connections?

Pete.

´´´
How are you powering the relay board?
´´´
I’m using the NodeMCU board power as explained below. Then as relay needs 5V I need to use 5V power adaptor to the Relay board using above picture pins.

‘’’
What pins on the NodeMCU are you using to connect to pins 1,2,3 and 4 on the relay board (refer to the pins by the D letters printed on the NodeMCU).
What pins have you specified in the code, and how have you referenced them in the code (by D number or by GPIO number)?
‘’’
I connected adapting the GPIO pins to NodeMCU, for example if in the code was used the ping 14 and 12, then I used the NodeMCU pins D5 and D6. Each time I click buttons in the blynk app the relay is working. I also connected the GND from the relay board to the GND in the NodeMCU board close to D5 pin. also I connected the VCC from the relay board to the 3.3V close to the pin D4.

‘’’
How are you powering the NodeMCU, and what are you doing with the ground connections?
‘’’
For the NodeMCU board I was using a 5V mobile power adaptor but I will need to change to a 3.3V in order to don’t damage the board which is 3.3V

Okay, the NodeMCU has an on board voltage regulator that takes the 5v supplied via either the USB socket or the Vin (sometimes labelled 5v) pin and converts it to the 3.3v needed by the NodeMCU, so you won’t damage it by putting 5V onto either of these pins.

However, if you try to power too many other devices, especially ones that draw a reasonable amount of current, from the 3.3v pins then you can burn-out the on board regulator.

The relay board will require a fairly large amount of current to pull the contacts on the relays closed - obviously twice as much for 2 relays at the same time, four times as much fir all 4 relays at the same time. This current peaks as the relay is activated, so if you ever activate all 4 relays at the same time you’ll get the peak current draw at that point.
The relays need a beefy 5v supply to cope with this. It can be the same power supply that powers the NodeMCU, provided it can deliver sufficient peak power, but the output from the PSU should be split into two, one branch going to the relay, the other going to the Vin/5v pin on the NodeMCU, and the negative wire also needs to be split - one to the GND on the relay board and the other to one of the GND pins on the NodeMCU.

Which pins you use for driving the NodeMCU is important. With the Sonoff, these are dictated by what the manufacturer has chosen to do, ad in some cases they use pins that aren’t recommended for normal use, but they get around this by designing the Sonoff circuit to cope with this. You may have to change your choice of pins to work with the relay circuitry that you have.
You should read this thread for more info:

I’d assumed from your earlier question that the relays weren’t working, but you’ve said:

so I’m a bit confused about where you are with your project.

Pete.

1 Like

Dear Pete. Thks a lot for your info. I’m trying to make a irrigation system, means only one relay will be operative each time because I have the garden divided in 3 sectors. I assume and I will test that with the power of the NodeMCU will be enough. If not I will follow relay fabricant instructions:


As shown in the attached picture, you could take off the jumper cap, then refer to the followings to connect NodeMCU, Relay and 5V External Power:

NodeMCU 3.3V — Relay VCC
NodeMCU GND — Relay GND
External power 5V — Relay JD-VCC
External power GND — NodeMCU GND

As I have a power adaptor of 5V for supplying electricity to the electro valves I will also use it to power the relay as described.

What I don’t know is if the relay with LOW is contact close (then irrigation will run) or not. But I will test.

About pins, don’t worry they are ok, I’m following a NodeMCU sketch, then they are ok.

Many thks for your patience and for sharing your info with people like me, I learned a lot reading you and the forum. I will try to read more and to improve Arizona’s app.

You certainly shouldn’t be doing that, for the reasons I described earlier.

You’ve said that the relays are Active LOW, which means that the relay will be energised (and the contacts made, irrigation running) when a LOW signal is applied - i.e when relay pin 1 is connected to ground, relay 1 is energised. When it’s connected to 3.3v to 5v then the relay contacts are open, irrigation not running.

Pete.

1 Like

I used below pins

byte switch_pins[] = {14 , 12 , 16 , 13}; // number of gpio to be used as switch/relay control

b

1. List item

ool switch_default[] = {LOW,LOW,LOW,LOW}; // switches that use reverse polarity should be set to HIGH here

As per link they are safe to be used.

For GND and 3.3V I used following pins

I don’t understand how to supply electricity to both NodeMCU and Relay Board. I use the USB to supply to NodeMCU. I have an external 5V power source that can be used for supplying relay board and as per manufacturer it should be done as discribed above.

NodeMCU 3.3V — Relay VCC
NodeMCU GND — Relay GND
External power 5V — Relay JD-VCC
External power GND — NodeMCU GND

I am a little bit lost.

Thks in advance.
Brgds
Miguel

These relays have the ability to be used in a variety of different ways, to make them suitable for various situations. This includes the ability to (allegedly) provide full opto isolation between the supply to the relay and the pins labelled IN1 to 4.
Having studied the schematics for some of these devices in the past, I have my doubts about the isolation, but for me that’s irrelevant as I never use them in that mode. The relay board you have may be different to the ones I’ve studied before.

When I’m using similar boards I connect an external 5v supply to both the relay board and the VIN pin on the NodeMCU, so that the same supply, with shared ground, is used to power both devices without burning-out the voltage regulator on the NodeMCU.
If you want to take the same approach then do so at your own risk.

I think that maybe you’re starting to realise that the Sonoff 4Ch Pro was actually a very good solution, as all of these issues had been considered in detail when the board was designed and manufactured. Plus, the whole thing is in a nice self contained case and is certified to CE standards.
Can you see now why I was encouraging you to explain more about the issues you were having with your Sonoff so that we could help you to get that device working?

Pete.

1 Like

Hello to all again.

I have 2 issues with this code made for NodeMCU. I cannot set Time Processor to my time (GMT +1 / Madrid). In the Input Timers I can select it.

As you can see when I connect board+relay,

When I connect NodeMCU+Relay the board lights are ON, then I tested one light bulb and it was ON. I can solve this issue just changing in the relay NC i/o NO and it works ok. My worry is if my electricity goes down, then sprinklers will keep ON wasting water, the only thing is as I fixed 3 min. maximum ON in the iOS app I won’t waste too much water, but I prefer to do in the contrary, when electricity is down the relay in not connected then, no problem.

iOS app is OFF:

This is the Arduino IDE Monitor, they are OFF (same than app as per above picture):

About SOnoff board, I saw physical damage then it was not possible to use again. I will try to lear more about NodeMCU + relay in order to use it. But it’s true that sonoff is nice but you have to know how to flash, and it’s not easy for very junior people like me.

About external 5V supply. I saw 5V VIN (yellow) in the NodeMCU board. With your schema I no need to supply energy via USB, isn’t it? I will do via direct 5V connection from the 5V supply to the NodeMCU and JD-VCC in the Relay. Then I keep the GND from 5V supply to the NodeMCU board and from NodeMCU to Relay. From 3.3 to VCC in the relay I think will keep. If I’m wrong tell me the schema, please.

My brain is burning hahahahaha, but will get my goal.

Thks a lot.

I’ve already explained that you do in the RTC widget in the app.

If the relays are ON when they should be off, then you have these settings wrong.
If you mean that you want a relay that is only energised when a HIGH signal is applied to it by the NodeMCU then you’ve bought the wrong type of relay.
However, ask yourself this question - If the power fails, will your sprinkler continue to operate? (the answer depends on your sprinkler hardware, but if it’s a sprinkler that requires a water valve to have power applied to it to allow water to flow, then the valve will close when the power is disconnected anyway.

Correct, the USB connection is NOT used in this situation, the 5V for the NodeMCU comes from the VIN pin rather than via the USB connector.

I don’t follow what you’re asking here, but some of what you’ve said is certainly wrong.

The JD-VCC and VCC pins are not connectors, they are a jumper. The jumper should be in place so that the two pins are shorted out, as shown in the photo you posted in post #28.

I would then wire it as follows (if you wish to do this then you do so at your own risk, I don’t have access to your hardware to check that it works how I think it does):

5V Positive (+) from PSU connects to:

  • VIN pin on NodeMCU (sometimes labelled 5v)
  • VCC pin on relay board

5V Negative(-) from PSU connects to:

  • GND Pin on relay board
  • GND Pin on NodeMCU (any GND pin will do).

The 3v3 pin on the NodeMCU IS NOT CONNECTED TO ANYTHING

Pete.

1 Like

Hello,

I so happy because changing to HIGH is working ok. Thks. I tested to schedule and it is working. Also I was able to fix my Time in the WidgetRTC which it was hidden. Now all is ok.

Now I have to decide how to supply both. If I follow your last post I don’t understand how NodeMCU open or close electricity to the relay board if the apply is supplying directly to both boards.

5V Positive (+) from PSU connects to:

  • VIN pin on NodeMCU (sometimes labelled 5v)
  • VCC pin on relay board

5V Negative(-) from PSU connects to:

  • GND Pin on relay board
  • GND Pin on NodeMCU (any GND pin will do).

In any case, if I keep like I have it today and as I will have only one sprinkler each time I think I won’t have serious problems. If I am wrong tell me and I will try your recommendation.

Again, thks a lot four your fantastic support.

The relay pins IN1, IN2, IN3 and IN4 are pulled low by 14, 12, 16 and 13 to actuate relays 1,2, 3 & 4.

The power from the PSU powers the NodeMCU and provides the current to power the electronics on the relay board and actuate the coils that close the relay contacts.

I believe that if you leave it as it is then you’ll damage your NodeMCU.

Pete.

1 Like