Respondido

Using an RJ12 cable to connect to a Raspberry Pi 2 GPIO

Thread Summary

Posted by retrodaredevil

Jul 18, 2019 at 2:02pm

Please read the next few posts to fully understand the RJ12 port. I was successful in creating a DIY cable. Just read the next few posts.


Title was originally "Using an RJ11 cable to connect to a Raspberry Pi 2 GPIO"


Yesterday I received a Renogy Rover PG 40A charge controller and I was given the task of collecting data from it using a Raspberry Pi.


I was pretty angry, but not discouraged, to find that it didn't come with the RS232 to USB cable that was promised. So, I found an RJ11 cable with the 4 center wires/pins and soldered some connectors to it. The connections I made were solid and I tested they worked. I then tried to follow www.rototron.info/raspberry-pi-solar-serial-rest-api-tutorial/ that tutorial. Even though it was an RJ45 cable, I just ignored the first two and last two pins and treated it like a RJ11 cable since it was just 3 pins in the middle that were being used.


Once I did that it was too late. I measured the voltage on what I had actually connected and I realized I had sent 15V through the pi's GPIO. That part was pretty much my fault. I should have looked for a more up to date guide on how to connect it to a raspberry pi.


Does anyone have a wiring diagram that I can use to wire this to my pi. This: renogy-store.boards.net/thread/561/rs232-port mentions that it's TX/RX/GND/GND/+/+.

Is that correct? Can someone tell me the pins from left to right if I were looking at the controller mounted on a wall? Am I able to use an RJ11 (4 pins) instead of an RJ12 (6 pins) to get data, or do I need the two extra pins on the end?


Also, if there's a cable on amazon that someone has tested and uses that acts just like the cable that was SUPPOSED to come with the charge controller, I'd really appreciate a link.


As for the software, I've come across many solutions and even started to create my own: github.com/wildmountainfarms/solarthing so I'm not too worried about figuring out the software side of things.

Posted by retrodaredevil

Jul 25, 2019 at 9:28am

Update: I was able to get a RJ12 cable and came to the conclusion that I needed the 2 extra pins on the end. The pin out is something like "TX/RX/GND/GND/+/+". If you're using this for future reference, make sure to test it with a multimeter because it could be flipped.

When I measure the voltage from TX to Ground, it's 5.66 Volts. TX to RX is the same thing. I'm pretty sure that this means the serial communication uses a 5 volt "logic level". Because of that, I think that was the reason that I was unsuccessful in getting communication through my Raspberry Pi to work. The pi uses a 3.3V logic level so I think I would need a converter of some sort.

Right now I've ordered a USB to serial cable that hopefully supports the 5V logic level.

If anyone has any suggestions or experience with communication without the USB to RS232 cable, I'd really appreciate any tips or suggestions before the USB adapter arrives. Also if there are any modbus/renogy quirks I should be aware of that would also be helpful. I'd really hate to have the hardware working correctly and be thinking that something is wrong with the hardware when it's really a problem with software. I have to connect the Rover RX to the adapter TX and vice versa, correct?

Posted by retrodaredevil

Jul 25, 2019 at 8:48pm

Second update: I did some research on Raspberry Pi and Arduino communication with the RS232 serial protocol. This page helped me understand it more: raspberrypi.tomasgreno.cz/uart-to-rs-232.html

That page basically says that without some sort of conversion, you cannot hook it up directly to your pi. So I bought: www.amazon.com/dp/B074Z55GPN/ref=cm_sw_r_wa_apa_i_RrFoDbWQ8NTV3 and www.amazon.com/dp/B00425S1H8/ref=cm_sw_r_wa_apa_i_KsFoDbMJNT050 . I will post an update in the next couple of days. I do not recommend getting an RJ12 to USB cable because I'm pretty sure that the pin out on the RJ12 cable is proprietary. I wish Renogy would stop pushing people towards their Bluetooth module and bring back the cable, but that's just me.

I got an email back from someone at Renogy today and it was confirmed that the RS232 to USB cable was discontinued. I just hope they end up updating their manual and Amazon listing so no one else gets confused like I did.




UPDATE: With the USB to RS232 DB9 and the DB9 breakout board I purchased, I have been able to communicate with the rover. I hooked TX to RX and RX to TX and GND to GND. If anyone has any questions on how I did this I'd be happy to answer.

Posted by williamwinters

Jul 30, 2019 at 4:10pm

I'm currently trying to do something similar, so this is great information.

I'm hoping to communicate with my renogy wanderer this weekend. It is part of a remote LTE connected project. I want to be able to track my solar power and battery data and report it along with all the other data that the station is collecting.

I have the Renogy modbus document. I ordered the same USB to RS232 and DB9 breakout board from amazon. I have a few raspberry pi boards lying around.

You are not talking to the void. I'm out here listening and you've provided a big head start. Thanks!

EDIT:

If you could show the pinout of your RJ12 cable to the DB9 breakout, that would be great. You've already done the work, I don't want to mess up such a simple step.

Posted by retrodaredevil

Jul 31, 2019 at 1:24pm

Using the breakout, you will be using pins 2, 3, and 5. Pin 2 is the TX, Pin 3 is the RX and pin 5 is the ground.

So for the RJ12 cable, I can give you a general idea, but I seriously recommend a multimeter just to make sure you don't connect either 15V pins instead of the data pins. Like I said above, the pin out is TX, RX, GND, GND, +, +. You still may want to make sure that's not flipped. If you use a multimeter, you can pretty easily figure out each pin out. TX to RX or GND will give you around 5.66V. RX to GND will be a very low non-zero value if I remember correctly. So you can always be sure that the 2 middle pins are both ground, but make sure to check the outside ones. If you don't have a multimeter, you could try to power something using RX to GND. If you get a lot power there, then you must have it flipped because RX to GND cannot power anything because there's so little power there.

So you will be connecting pin 2 (TX) on the breakout to RX on the RJ12 cable, pin 3 (RX) on the breakout to TX on the RJ12 cable and pin 5 on the breakout to ground.

Here's a few images: imgur.com/a/N3UCdWf
As you can see, I was able to get a nice box that even had a nice little breakout for the RJ12 cable as well, I don't know how hard those are to find since I found one at a store with many recycled things. Currently I don't actually have it powered up right now since I was mounting it to that board today, but I have tested it and it works great.

If you're using Java, this might be useful: github.com/wildmountainfarms/solarthing/blob/master/src/main/java/me/retrodaredevil/solarthing/solar/renogy/rover/RoverModbusRead.java and github.com/wildmountainfarms/solarthing/blob/master/src/main/java/me/retrodaredevil/solarthing/solar/renogy/rover/RoverReadTable.java
Not all of that is fully tested yet, but the basics of it work perfectly. For whatever reason in my program it takes around 4 seconds to get all of the data. Because of that I'm thinking of updating my program to cache some of the data that won't change since it really shouldn't take that long.

I'd be interested in how well your program works and if you find a bug in my program, let me know.

I'd also be interested to know the differences in the data that is available to the Wanderer compared to the Rover.

Posted by williamwinters

Aug 4, 2019 at 12:15pm

Awesome. Thanks. This is very appreciated. I’ll update when I have made some progress. Here is the install site. imgur.com/WVrPNzz

I got a 10amp wanderer to debug at home instead of working on this in the sun where the charger is already deployed.

Posted by playersz28

Aug 12, 2019 at 4:13am

I've had a Pi running and charting my Rover for almost a year now. I use the RJ-USB cable that came with the Rover.

Posted by retrodaredevil

Aug 12, 2019 at 6:51pm

playersz28 Avatar

Aug 12, 2019 at 4:13am playersz28 said:

I've had a Pi running and charting my Rover for almost a year now. I use the RJ-USB cable that came with the Rover.


You're pretty lucky you got a cable with that Rover. The newer ones on Amazon don't come with that cable anymore :/


I've been collecting data continuously for a week and a half now. It seems to be working great. Now I just have to use my program to set a few of the voltage settings. It's not actually hooked up to any solar panels yet, so most of the data is just zeros. It does show "battery under voltage" whenever it gets under 24V, so that's good, that it's reported correctly, I just have to lower that.

Posted by playersz28

Aug 14, 2019 at 5:42am

retrodaredevil Avatar

Aug 12, 2019 at 6:51pm retrodaredevil said:

playersz28 Avatar

Aug 12, 2019 at 4:13am playersz28 said:

I've had a Pi running and charting my Rover for almost a year now. I use the RJ-USB cable that came with the Rover.


You're pretty lucky you got a Rover with that cable. The newer ones on Amazon don't come with that cable anymore :/


I've been collecting data continuously for a week and a half now. It seems to be working great. Now I just have to use my program to set a few of the voltage settings. It's not actually hooked up to any solar panels yet, so most of the data is just zeros. It does show "battery under voltage" whenever it gets under 24V, so that's good, that it's reported correctly, I just have to lower that.


Pretty sure I was also running an RS232-USB adapter I hacked up when I needed to run from the trailer in my yard into my office. I'll have to look for it to check.

Posted by RayDas

Aug 14, 2019 at 2:17pm

Very interesting. I am using the 'Solar Station Monitor' program, provided by Renogy. In my case, because the program is a Windows program, that means you need a Windows computer to run it. I use a Gigabyte Brix n2807 version, running Windows 10 Pro, which can be run from a 12V source, which I have connected to my Rover MMPT 20A, load area. Yes, this uses quite a bit of juice when you do a start up, so I was thinking of using a Raspberry Pi.

Since I am not a Java tinkerer, I would like to use Python instead. Any suggestions as to some problems that would come up using Python?

Looking at a .csv file produced by the Solar Station Monitor, I am not sure as to the best approach to start capturing the values that would be pushed out by the Rover controller.

Posted by retrodaredevil

Aug 14, 2019 at 7:37pm

So if you'd like to use python, it looks like there's a library made for this: github.com/corbinbs/solarshed . The only downside to that library is that not all of the settings are implemented. However, now that I look at it, the methods that aren't implemented in that library are completely useless, to me at least. If you look at the Modbus document, almost everything after the battery type is useless. (I haven't found a use for the unimplemented data anyway)

There wouldn't be any problems that come up using Python at all. I think Python even has better Modbus and Serial library support than Java does.

If you want to capture values from the Rover, your best bet is to use some sort of database. For my program, I am using CouchDB. If you ever plan to have CouchDB open to the public, don't use it. Securing it is a nightmare. I think I'm going to eventually look into MongoDB.
TDLR: If you want to store data from the Rover, use a no-sql database that is document based. One that uses JSON to communicate the information is nice too.

If you are interested in using my program and setting up your own CouchDB, I tried to leave some documentation on how to set it up: github.com/wildmountainfarms/solarthing/blob/master/couchdb.md and github.com/wildmountainfarms/solarthing/blob/master/solar/README.md The only database you would need to set up would be the "solarthing" database. The second link is the set up for running the program.

Posted by raydas

Aug 15, 2019 at 6:00am

The reason I am more interested I python is because I have become somewhat familiar with SQLite DB. In fact I have a functional SQLite DB that is collecting data.

Below is a couple of lines from the 'Solar Station Monitor' .csv file:

Date Time,Station Name,Device ID,Array Current(A),Array Voltage(V),Array Power(W),Working State,Battery Voltage(V),Battery Temp.(?),Battery Current(A),Battery SOC(%),Load Current(A),Load Power(W),Load Voltage(V),Load State,Device Temp.(?),Battery State,Charging State,Controller Working State
2019-08-12 08:31:26,sta1,01,0.66,15.1,10,MPPT,12.5,25,0.86,72,1.09,13,11.9,1,29,No,Normal,Normal
2019-08-12 08:32:28,sta1,01,0.69,14.3,10,MPPT,12.6,25,0.81,71,0.89,11,12.4,1,28,No,Normal,Normal



In your experience, is the Rover pushing out the data fields, continuously, as seen in the .csv file or do you have to submit special commands to get the data?

Since my setup is more of an experiment to gather data and then try to do an analysis of the equipment, it seems like most of the data in the .csv file could be used, for my purposes anyway.

In the vicinity, close by, I have a Dell box setup that is running an xubuntu GUI server. So, maybe, have a Raspberry Pi connected to the Rover, that captures the Rover data and then submits it to the SQLite, and some form of data captured gets pushed to the Dell server for whatever?

Posted by retrodaredevil

Aug 15, 2019 at 6:20am

So the Rover doesn't "push" out data. Any data you want, you have to request. That's what Modbus is for. Basically Modbus is a protocol where you can request and set data. Both the solarshed library and my library are a pretty good example of how to get that data.

How you want to format that data to put into a database is up to you. Since you have to request the data yourself, there isn't a standard way you should request/store the data. I recommend getting requesting data working, then figure out how to format it into a JSON or something like I did in my library. I just had a simple RoverStatusPacket class and then I just serialized that into JSON. You can do the same thing in Python.

Posted by playersz28

Aug 15, 2019 at 8:37am

My monitor app is based off of EPsolarserver code and runs on a Pi installed in my RV. I also have an ESP8266 reading a shunt via INA219. Still using the ESP because the INA lib is Python and I haven't got around to converting it to C++. I also log RV location by picking up the NEMA data from an old phone.

Posted by raydas

Aug 15, 2019 at 10:12am

I started a quick experiment, I downloaded Tera Term to my Windows 10 computer. In the TT setup it showed that COM3 9600BAUD was connected, which is the connection to the Rover via RS232/USB cable. Now the only problem is the missing command set that allows you to talk to the Rover.

Will Renogy be releasing the command set for communication with the Rover, or is there a download, of the command set, available somewhere. Not sure how many people are using the RS232/USB cable, but it seems that this device is no longer supported by Renogy, maybe a public release of the command set is in order.

While thinking about that, maybe a public release of the command set for the BT module is in order also. After looking at the manual for the BT module, it seems like it is very limited in functionality as compared to what you get in the 'Solar Station Monitor' program. Just my 2 cents.

  • Thread Summary

    Posted by playersz28

    Aug 15, 2019 at 12:16pm

    raydas Avatar

    Aug 15, 2019 at 10:12am raydas said:

    I started a quick experiment, I downloaded Tera Term to my Windows 10 computer. In the TT setup it showed that COM3 9600BAUD was connected, which is the connection to the Rover via RS232/USB cable. Now the only problem is the missing command set that allows you to talk to the Rover.

    Will Renogy be releasing the command set for communication with the Rover, or is there a download, of the command set, available somewhere. Not sure how many people are using the RS232/USB cable, but it seems that this device is no longer supported by Renogy, maybe a public release of the command set is in order.

    While thinking about that, maybe a public release of the command set for the BT module is in order also. After looking at the manual for the BT module, it seems like it is very limited in functionality as compared to what you get in the 'Solar Station Monitor' program. Just my 2 cents.


    I asked for it last year and Admin posted it in this thread Modbus doc

    Posted by raydas

    Aug 15, 2019 at 1:25pm

    Thanks, got it. Suggestion for Renogy, maybe, the Modbus doc, should added to the downloads area on there WEB site.

    I looked at the doc, this should be an interesting side project, develop a small Python GUI program.

    Posted by Admin

    Aug 15, 2019 at 2:54pm

    raydas Avatar

    Aug 15, 2019 at 1:25pm raydas said:

    Thanks, got it. Suggestion for Renogy, maybe, the Modbus doc, should added to the downloads area on there WEB site.

    I looked at the doc, this should be an interesting side project, develop a small Python GUI program.




    Hello, please see here:

    Here: renogy.boards.net/thread/266/rover-modbus

    Posted by playersz28

    Aug 16, 2019 at 7:13am

    raydas Avatar

    Aug 15, 2019 at 1:25pm raydas said:

    Thanks, got it. Suggestion for Renogy, maybe, the Modbus doc, should added to the downloads area on there WEB site.

    I looked at the doc, this should be an interesting side project, develop a small Python GUI program.


    Google for "epsolar modbus python" and you'll find a number of different projects that'll have some stuff to get you started.

    This is an older shot of one of the screens mine generates. I've since modified it a bit for more data.



    Posted by retrodaredevil

    Aug 24, 2019 at 10:19am

    playersz28 Avatar

    Aug 15, 2019 at 8:37am playersz28 said:

    My monitor app is based off of EPsolarserver code and runs on a Pi installed in my RV. I also have an ESP8266 reading a shunt via INA219. Still using the ESP because the INA lib is Python and I haven't got around to converting it to C++. I also log RV location by picking up the NEMA data from an old phone.


    I know you said that we could Google the epsolar modbus, but I was wondering if you had any experience with a specific problem here: renogy.boards.net/thread/559/setting-voltage-values-working-program . I'm trying to set some values. Also, have you come across any inconsistency in the documentation, such as having to divide kWH by 1000 instead of 10000? You don't have to post your code, I'm just trying to understand the data the rover gives as best as possible. I don't exactly trust the documentation 100% right now (explained in the other thread I just created).

    Posted by playersz28

    Aug 26, 2019 at 5:12am

    retrodaredevil Avatar

    Aug 24, 2019 at 10:19am retrodaredevil said:

    playersz28 Avatar

    Aug 15, 2019 at 8:37am playersz28 said:

    My monitor app is based off of EPsolarserver code and runs on a Pi installed in my RV. I also have an ESP8266 reading a shunt via INA219. Still using the ESP because the INA lib is Python and I haven't got around to converting it to C++. I also log RV location by picking up the NEMA data from an old phone.


    I know you said that we could Google the epsolar modbus, but I was wondering if you had any experience with a specific problem here: renogy.boards.net/thread/559/setting-voltage-values-working-program . I'm trying to set some values. Also, have you come across any inconsistency in the documentation, such as having to divide kWH by 1000 instead of 10000? You don't have to post your code, I'm just trying to understand the data the rover gives as best as possible. I don't exactly trust the documentation 100% right now (explained in the other thread I just created).


    I'm not setting anything with my app, just monitoring. I used the desktop app to configure the Rover initially. I would say you're right about the kwh as I doubt my system as generated 19,000+kwh in 78 days as show in that screen shot. The docs aren't all that good, typical of most Chinese products. They can engineer them, just don't know how to write tech docs. I found the most info when searching for epsolar as that's what the Renogy products are.

    Posted by nicola

    Jan 22, 2020 at 7:27am

    So is it possible to buy a RJ12 to USB adapter? And if not, why?

    Posted by retrodaredevil

    Jan 22, 2020 at 12:36pm

    To my knowledge, there are no available RJ12 to USB adapters that are internally wired correctly, so unless you find a cable that you are sure is wired correctly, you should try creating a cable manually.

    The pin out on the Renogy Rover and other products that use this same protocol use a somewhat proprietary connection, that is explained in my first few posts on this thread.

  • Hi Retrodaredevil, 

    Thank you for the informative post. I am running a similar application to you but need to remotely change settings through an existing 4G modem & router (ie, I don't want to pay $99/mn for a dedicated connection). Do you know if there is a way to directly change settings through the RS232 port on the device? 


    Thanks, Trav

  •  Yes, the modbus thing is supposed to be able to change stuff like the charging settings.


    I have some instructions here for using solarthing with my rover-setup program: https://github.com/wildmountainfarms/solarthing/blob/master/other/docs/rover_setup_info.md

    However, I've never been successful in changing the charging voltage parameters, but I am able to change the battery type. So if you use SolarThing or another program to change parameters, I can guarantee you'll be able to change the battery type, but I can't guarantee you'll be able to change the charging voltages. It might work, but I'm not sure.

    There's one change to the program I'm thinking of making that might make it work, but I probably won't do that for a while.

    Also, if you need to do a one time setup, using the bluetooth module and an Android phone would be cheaper than their remote monitoring stuff.

  • Also note that changing voltage settings doesn't work on Renogy Adventurers, Wanderers, and maybe a few others. It only works on the Renogy Rover.

    That's explained here: https://support.renogy.com/en/support/discussions/topics/35000015801

    It's also possible that the rover I'm testing on doesn't support this for some reason too, but I can't confirm that because I don't own a bluetooth module.

  •  Would anyone here be willing to sell or make a cable?   Can be home made and I'd make it worth your while if it works with my PI 3.

  • Hi,


    regarding to the battery settings:


    I opened a different thread about this problem. I believe that this is a bug. In fact you can set and read the E004 register, but  you can not change the values afterwards. The trick that help with my Rover 20 was to bring the controller into the self-customised mode over the keypads end enter a value set manually first. Afterwards I was also able to change the values over the modbus. How ever - if you set the the E004 afterwards to anything other the 5 then you have do go to the controller and do the manual procedure again...


    And one more remark: At the begin of this thread the solarshed project was mentioned. This was a really good starting point because you can easily modify the driver and use it for your own needs. They are using this very good documented python library: 


    https://minimalmodbus.readthedocs.io/en/stable/ 


    If you like to use code from the project you need to modify it anyway, but it may save you a lot of time if you just update the driver to the actual MinimalModbus syntax of the actual version 1.0.2

Iniciar sesión o registrarse para publicar un comentario