Code Monkey home page Code Monkey logo

Comments (8)

seramonte avatar seramonte commented on July 20, 2024

I'm using XY-017 ttl-rs485 converter: https://www.aliexpress.com/item/32431974521.html

I tried your code on an Arduino Due; it compiles but does nothing, prints nothing. If I comment out:
PZEM017v1 pzem(&Serial3, 0x01);
it at least prints messages to Serial. Seems like something in the .cpp file, but no errors. There is this warning:

PZEM-017-v1-master/PZEM017v1.cpp:123:22: warning: deleting object of abstract class type 'Stream' which has non-virtual destructor will cause undefined behaviour [-Wdelete-non-virtual-dtor]
delete this->_serial;

This occurs on Uno and Due.

from pzem-017-v1.

seramonte avatar seramonte commented on July 20, 2024

I verified my setup with other code base and everything works! But I am curious to get this code to work. I get this error when running the sample PZEMHardSerial.ino:

.arduino15/packages/arduino/hardware/sam/1.6.12/variants/arduino_due_x/variant.h:251:18: error: 'Serial' has a previous declaration as 'UARTClass Serial' extern UARTClass Serial;

If I comment out extern HardwareSerial Serial; in the .cpp file, the code compiles but no lights on rs485, and no debug output on Serial. Nothing.

from pzem-017-v1.

AquaticsLive avatar AquaticsLive commented on July 20, 2024

I would like to know which hardware is working I may need to swap to a different Arduino or rs485 board just haven't figured out the combo that works. I do have it working with the included software just can't get my Arduino to read the data. My guess is that I should use the rs485 that doesn't have those enable pins but wanted to ask. I have a Mega, Uno, and ESP32.

from pzem-017-v1.

AquaticsLive avatar AquaticsLive commented on July 20, 2024

Answering my own issue I read through the code and there is no flow control setup. So I am ordering a 485 adapter with automatic flow control. Makes sense too since each serial transmit maybe a little faster or slower my Arduino boards don't seem to be precise enough for doing flow control trying to time out the enable of transit or receive seems to be a battle that I can't figure out on my scope I see the timing of the edge of the code seems to not be the same between attempts to send. I gave up on trying to adapt the code to work with the MAX485 that doesn't have automatic flow control. I will come back here and add a comment to say how it's going after I get the new boards being more exact for my future self or others this is the title from Amazon "SongHe TTL to RS485 Module 485 to Serial UART Level Mutual Conversion Hardware Automatic Flow Control Module 3.3V 5.0V Power Supply Long Distance Transmission(5pcs)" Aric-AquaticsLive

from pzem-017-v1.

AquaticsLive avatar AquaticsLive commented on July 20, 2024

I got the auto flow control boards today and hooked up and bingo everything works. Also, have to love the TX and RX LEDs on the board. Swapped in each of my different Arduino boards and they all worked. So to help others that are trying to debug things I used an MQTT sketch for the boards that had wifi which is super nice to read serial at least to my Windows PC using MQTT box App without having to use software serial. Now my old Uno board what I did first was have it blink the LED if it received data, then I used a display sketch to read one value. That confirmed to me that it works everywhere and could help others figure out their issue. For me, the auto flow control rs485 adapter was the magic and of course, the super clean code of maxzerker is a perfect combo so much easier to understand what is going on than using the regular Modbus code and the MAX485.

from pzem-017-v1.

maxzerker avatar maxzerker commented on July 20, 2024

image
Sorry for late reply, I'm using above rs485 TTL on this project.

from pzem-017-v1.

AquaticsLive avatar AquaticsLive commented on July 20, 2024

61jsYiEs7xL SL1010

from pzem-017-v1.

AquaticsLive avatar AquaticsLive commented on July 20, 2024

That is the one I am using so pretty much the same just without the holes populated.

from pzem-017-v1.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.