logo elektroda
logo elektroda
X
logo elektroda

NodeMCU and MCP23017: Terrarium control, interference on i2C, pullup resistors, relay module

zipZłoty 993 10
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19219665
    zipZłoty
    Level 10  
    Hi,

    Brief description of the application: terrarium controller, activation of lights according to harmonogran, heating based on sensor readings.

    Hardware .
    The NodeMCU communicates over i2c with the MCP23017. The bus has 4.7k to 3.3V pullup resistors. The expander connects to an eight-channel relay module to which all controlled devices are connected. The relays are powered from a separate 5V source. Diagram attached. NodeMCU and MCP23017: Terrarium control, interference on i2C, pullup resistors, relay moduleschema..jpg Download (95.96 kB) .

    The control box is located in the "ceiling" of the terrarium. Right next to it goes the trough with the wires.

    A PCB has been made based on the schematic. The i2c lines go right next to each other, the total length is about 4 cm.

    Software .
    The circuit works with Blynk. The code will not be needed to analyse the problem.

    Controlled devices .
    1. LED daylight strips.
    2. LED night slats.
    3. Radiant (heating) - mains supply.
    4. Metahalogen and its stator .

    Description of the problem .
    The LED daytime running light comes on at 9. At 10 the metahalogen came on. Unfortunately, sometimes its start-up causes other lights to switch off and the relay module stops responding to manual state changes by Blynk. Other than that, the programme works normally (e.g. sensor readings, etc). I have removed the metahalogen from the system and control it separately (via WiFi socket). However, the problem did not disappear. I therefore put the blame on the MCP23017 and the i2c. The ignition voltage (according to Osram) is 4.5 kV. Unfortunately, it seems to me that this peak is messing with my rail a lot. The driver is now as far away from the lamp and ballast as possible, but this makes little difference. My solution so far is to call at 10:01 ESP.restart(). The solution works, the lights start up normally, but I am not satisfied.

    Meritum .
    And here is my question - what can I do to protect the bus from interference? Was it a mistake to print the paths for the i2c? What is good practice - should I use shielded wires for the i2c instead of paths on the board?
  • ADVERTISEMENT
  • #2 19220015
    khoam
    Level 42  
    zipZłoty wrote:
    The expander connects to an eight-channel relay module to which all controlled devices are connected.
    .
    The first thing I would do is install RC quenchers (quench circuits) on the relay contacts. This problem has been discussed many times on the forum.
    Link (page 18)
  • ADVERTISEMENT
  • #3 19220025
    Ondo
    Level 11  
    It doesn't necessarily have to be interference on I2C, the MCP23017 itself can change the state of the internal interrupts randomly from external interference. But all in all you have already found the cause yourself, you can try:
    - add RC filters to the relay contacts
    - make control on triac
    - use "electronic" relays
  • ADVERTISEMENT
  • #4 19220994
    zipZłoty
    Level 10  
    For the next version, I intend to switch to triacs (at least partially).

    As I understand it, your suggestion is for me to wire the metahalogen back to the controller and to its relay to install a quench circuit. I hadn't actually thought of that, I need to explore the subject further.

    And as for the i2c bus itself - question from the original post - is running it on the pcb ok?
  • #5 19221181
    khoam
    Level 42  
    zipZłoty wrote:
    For the next version I intend to switch to triacs (at least partially).
    .
    Preferably with optoisolation and zero switching if it is to be better than on a relay.

    zipZłoty wrote:
    back plugged the metahalogen into the driver and to its relay fitted the extinguishing circuit
    .
    Exactly, yes.

    zipZłoty wrote:
    As for the i2c bus itself - question from the original post - is running it on the pcb ok?
    .
    You haven't posted a drawing of the pcb, but from the verbal description it seems unlikely to be an I2C bus interference issue.
  • #6 19221751
    zipZłoty
    Level 10  
    khoam wrote:
    zipGold wrote:
    I am going to switch to triacs (at least partially) for the next version.

    Preferably with optoisolation and zero switching if it is to be better than on a relay.
    .

    I am currently using a relay module with opto-isolation . Anyway, I need to educate myself with the extinguisher circuits and how to wire them actually to the lamp.

    khoam wrote:
    zipGold wrote:
    And as for the i2c bus itself - question from the original post - is running it on the pcb ok?

    You didn't post a drawing of the pcb, but from the verbal description it seems unlikely to be an interference problem with the i2C bus.


    I am posting the PCB, just for the sake of things. This was the first version, with no pullup on i2c. Since it's not the bus, are you suggesting that the MCP23017 is the problem? I'd like to know at least the approximate mechanism of what's going on when the tube starts up. The easiest thing I could think of was to induce a very small current on the rail, which naturally interfered with its operation. I still don't know how to protect the circuit from an externally induced disturbance.
  • #7 19221775
    khoam
    Level 42  
    zipZłoty wrote:
    I would like to know at least the approximate mechanism of what happens when the lamp starts up.
    .
    In a nutshell: the sparking of the relay contacts (arcing) generates interference which can transmit to the microcontroller and cause unstable operation. Therefore, RC suppressors are used to nullify this phenomenon. Link .

    zipZłoty wrote:
    I still don't know how I'm supposed to protect the circuit from externally induced interference.

    Well precisely by nullifying this interference created when the relay that controls the lamp is switched on.
  • ADVERTISEMENT
  • #8 19221797
    zipZłoty
    Level 10  
    khoam wrote:
    In a nutshell: the sparking of relay contacts (arcing) generates interference that can transmit to the microcontroller and cause unstable operation. Therefore, RC suppressors are used to nullify this phenomenon. Link
    .

    But, as I wrote, the metahalogen is currently run from a completely separate device - it is plugged into a WiFi socket. The only thing these systems have in common now is that they are in the ceiling of the terrarium. Do you think that sparking in the WiFi socket relay causes interference, which in turn affects the uC?
  • Helpful post
    #9 19221809
    khoam
    Level 42  
    zipZłoty wrote:
    You believe that sparking in the WiFi socket relay causes interference, which in turn affects the uC?
    .
    Yes, I believe. If the interfering circuit is relatively close to the interfering circuit.
  • #10 19221818
    zipZłoty
    Level 10  
    Ok. I imagined the wires from the lamp as antennas, even scrossed them, but as you can see without success. I will try your approach.
  • Helpful post
    #11 19238570
    krzbor
    Level 27  
    It is worth examining another problem - the interference associated with metahalogen start-up. This is quite a complex process where 4.5 kV pulses are generated. The interference must then be really high. The problem is probably not the power supply or the relay, but the ballast itself or the ballast-metahalogen bulb connection. This can be checked by moving the ballast-bulb system away from the ESP.

Topic summary

The discussion revolves around a terrarium control system utilizing NodeMCU and MCP23017 for managing lighting and heating. The user experiences interference issues on the I2C bus, potentially caused by relay contact arcing and the startup of a metahalogen bulb. Suggestions include installing RC quenchers on relay contacts, using optoisolation, and considering triacs for control. The conversation highlights the importance of mitigating interference from nearby devices and the need to investigate the ballast and bulb connection for potential high-voltage pulse generation during startup. The user is advised to relocate components to reduce interference and explore protective measures for the circuit.
Summary generated by the language model.
ADVERTISEMENT