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. |
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.htmlThat 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. |
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. |
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 |
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 ![]() 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 ![]() Aug 12, 2019 at 6:51pm retrodaredevil said: ![]() 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. |
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. |
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) |
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. |
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. |
Thread Summary
Posted by playersz28
Aug 15, 2019 at 12:16pm
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 docPosted 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
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
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
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
Aug 24, 2019 at 10:19am retrodaredevil said:
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
Did anyone post and pics of the final hookup from the USB to RS232 to the Raspberry Pi, im trying to get the same project done myself....any help would be highly appreciated.
I have a USB to serial and a serial dim board....if the USB will not drop down to the 3.3 volts needed for the Pi do I need to use a converter?
Thanks!
It's not that you can't get the voltage of the RS232 signal to drop down to 3.3V for the pi to read, it's that an RS232 signal uses positive and negative voltages to represent 0s and 1s. You will need something that explicitly says it can convert an RS232 signal to something the Pi can read. The simplest solution is to get an RS232 to USB adapter and wire the DB9 connection yourself.
I don't have pictures, but you can use a multimeter to make sure the voltages are correct.
Thanks Joshua, I have just put together the same setup that you are using with the RS232 to USB adapter and wire the DB9 connection.....I have everything plugged in but cannot find the files to run.....when I click on the links above it says that they have been removed from https://github.com?
Can you please send me a new link or send me what ever files you are running that will allow me to collect my data from the controller? I'm running a Wanderer 10amp PWN.
Thanks for any help!
Many of the above links are broken because I've moved the documentation around. You can still see my solarthing project here: https://github.com/wildmountainfarms/solarthing
Right now, most of the info on how to set it up is on the quickstart here: https://github.com/wildmountainfarms/solarthing/blob/master/other/docs/quickstart.md
Those links may change in the future, but https://github.com/wildmountainfarms/solarthing should stay the same. There, you should always be able to find the quickstart.
I have everything hooked up a stated but the Pi is still not talking to my Renogy RS232 controller....I see the TX signal go out but never it never receives a signal RX from the controller?
What are you using to convert the RS232 signal? Are you using the USB to RS232 DB9 cable and a breakout like I am?
There are many reasons it may not be working. The most likely is that you have RX hooked to RX and TX hooked to TX. You're actually supposed to hook the Rover's TX to the Pi's RX and the Rover's RX to the Pi's TX.
Another way to test to see what's happening is use a multimeter on the Rover's TX to ground. You should get a negative or positive voltage around 5.6. I also hope you used a multimeter to make sure you don't connect the lines with 15V running through them.
Im using the same hookup as you have and do have the RX and TX crossed...not sure if they are going the exact direction as you are stating but I will check....I thought as long as they were crossed?
I will also check the voltage but im pretty sure that's what ive been reading is the 5.6v?
I'm also assuming you have both grounds connected to each other. Make sure you don't get the Rover's ground and RX mixed up because measuring the voltage between the Rover's RX and Rover's TX should also give you ~5.6V, making them easy to get confused. Once you know which one TX is, you can use the TX/RX/GND/GND/+/+ layout to know that RX is next to TX, which is next to GND.
Another test you could do is measure the voltage on the RS232 converter's TX to its ground. That should also be a positive or negative voltage. It probably won't be 5.6. I don't know what it is, but it should probably be >4. This check just makes sure your converter is working as expected.