I am designing an energy meter based on the ATMEL energy meter chip ATM90E32ASAUR with an ESP32.

The problem I have is that, in the application note of ATM90E32ASAUR, they are grounding the AC neutral with the DC common ground, and also that same ground is connecting with the microcontroller (the ESP32.)

Is it safe to connect this AC neutral with the DC common ground while the ESP32 is connected to a computer for programming and debugging purposes?

What type of safety features I can use to make it safe?

Are there any options for isolating both the AC and DC side to make it safer? Is there any recommendation for a small power supply for this?

I am currently using a HI-LINK HLK5M05 and thinking of using optocouplers on the SPI connections, but then I will have to use two of these HiLink modules and I want to make a small circuit as well.

The circuit I am using with a fuse and a varistor as a safety feature


3 Answers 3


Of course it isnt't safe. Ciruits connected to mains must not be accessible by any external connection, they must stay within an enclosure and never brought outside.

If you want to program or debug, it depends what you need. If you buy an USB isolator then you can have any debugger or serial port behind the isolator, just everything after the USB isolator is deadly and might be best be close to live circuits. You can also build more permanent isolations for UART or SPI but you don't need it after debugging.

  • \$\begingroup\$ Thanks for the help, Yes I agree that's why I am asking if there are any permanent isolation circuits I can use to for the SPI ? can you recommend any circuit ? Is there any USB Isolator you can recommend as well ? \$\endgroup\$
    – msi
    Commented Oct 27, 2023 at 14:11
  • \$\begingroup\$ Asking for product suggestions what to buy is off-topic. Have you put "SPI isolation IC" into your favourite search engine to find one? \$\endgroup\$
    – Justme
    Commented Oct 27, 2023 at 15:00
  • \$\begingroup\$ @msi SPI isolation is pretty common and simple. USB isolation is more difficult, depending on exactly what you need (USB Low Speed and Full Speed are simple, High Speed difficult, Superspeed very difficult). \$\endgroup\$
    – Hearth
    Commented Oct 27, 2023 at 18:34
  • \$\begingroup\$ @Justme Thanks for the reply, Yes I understand buy is off topic, I was not knowing about that, but the SPI Isolation IC was a new thing for me, thanks for showing me the way. \$\endgroup\$
    – msi
    Commented Oct 28, 2023 at 16:49
  • \$\begingroup\$ @Justme one more question, in the SPI Line connection between the ESP32 and the ATM90E32ASAUR will be bi directional correct ? So will need to use 2 Isolation circuits on line (one for sending and other route for receiving) ? In the case of opto-couplers its only one way, and also with these SPI isolation ICs like Ti ISO674x and ADUM3151 are also oneway ? \$\endgroup\$
    – msi
    Commented Oct 28, 2023 at 17:05

For a product it's possible. You put it in a box and the only thing to the outside world is trough isolators. When done correctly this is fine. Most electrical meters do this.

However during development it is not safe.
You can't attach "standard" tools, such as programmers, logic analyzers and scopes.
You need isolated programmers or usb isolators. Careful, USB chassis on the device side it live!
You need to isolate logic analyzers.
You need differential probes, because scope ground is mains earth.
You need to be very aware of what you are doing, plus know where possible unwanted currents might flow and noise be injected.

So from the perspective of the development it becomes a expensive and challenging to do safe.

But, you can test your device using an isolation transformer and tie your transformer neutral to mains earth, and now you can use all the standard tools again. Because neutral isn't dangerous anymore. (live still is though)


It's not safe and it will add parasitic interference to your circuit. It can also be very dangerous if you inadvertently swap Live wire with Neutral... You need a galvanic isolated transmitter or optocouplers.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.