Jump to content

PowerForum Solar Data Collection - using a Raspberry Pi 3 :-)


Guest

Recommended Posts

Plonkster have a look at 

dom wrote:If anyone has a B+ board, there is a hidden config option:

By default the USB ports are limited to 600mA.
With the new option, this is increased to 1200mA.

The idea is you only set this option if you know you have a good (e.g. 2A) power supply.


 

CODE: SELECT ALL
safe_mode_gpio=4 

 

CODE: SELECT ALL
max_usb_current=1

Hope it works for you

Link to comment
Share on other sites

Well it something to try. I tried it with my pi and a 2 amp power supply and working on one of my drive hard rive that needed more power. If it does not work for some a usb hub is not that expensive and you have more options then

Link to comment
Share on other sites

Thanks Jaco. This make sence. My lights system that the pi drive through wifi works ok. Did not have any problems with it. But logically it make sence as i don't use the usb. The other pi that i use i use cat cable and usb. Also working great. Hope you going to upload some videos of your new project😀

Sent from my SM-G920F using Tapatalk

Link to comment
Share on other sites

I'm going completely mad here. Murphy is literally ruining my week. At work I have this piece of embedded equipment, basically an Arm Cortex M0, that refuses to talk serial with a Mac. I have literally crashed OSX 6 times this week (there is a horrible bug somewhere in the ftdi drivers). So as if that isn't enough, my Pi refuses to talk to the arduino. It is the weirdest damn thing. I now have the arduino powered by a separate supply, so the pi literally only needs to supply the ftdi chip, nothing beyond that. I plug it all in, leaving only the USB lead unplugged on the Pi, and the red RX light on the rs232/ttl converter starts flashing rhythmically, the bus light goes on on the Victron BlueSolar, all seems happy. Then I plug the usb-serial converter into the Pi and it all goes pear shaped... the red light slows down, flashes 5 times or so then stops... I swear it reduces in intensity as if something is sucking the life blood from this side (although it is separately powered with an isolated supply). Plug the same usb/serial converter into the laptop, and it works perfectly.

It's as if there is something fundamentally wrong with my understanding of how serial comms even work...

Edit: Tried a different usb/serial device as well. The PL2303 based device does the same as the ftdi based device. To be fair, there is an unnecessary conversion in there, which is there only because this is the hardware I had at hand: I go from 5V TTL level serial up to Rs232 (that's +- 12V levels), and then I go back down to lower voltage with a usb-serial converter. So there is an unnecessary RS232 level in the middle. I could just go with a normal TTL->USB module, like the cp2102. What I don't understand at all is why it works on the laptop but fails on the Pi. Even with the stock arduino's onboard ftdi ttl->usb chip it simply doesn't work :-(

Link to comment
Share on other sites

Plonky how did you get Mosquitto on the go on the Pi? I installed the ltest one for Jessie but it seems the process does not start and I get a connection refused. The sub and pub tools work as I can hook intot the Mosquitto test server. 

Link to comment
Share on other sites

2 hours ago, plonkster said:

I'm going completely mad here. Murphy is literally ruining my week. At work I have this piece of embedded equipment, basically an Arm Cortex M0, that refuses to talk serial with a Mac. I have literally crashed OSX 6 times this week (there is a horrible bug somewhere in the ftdi drivers). So as if that isn't enough, my Pi refuses to talk to the arduino. It is the weirdest damn thing. I now have the arduino powered by a separate supply, so the pi literally only needs to supply the ftdi chip, nothing beyond that. I plug it all in, leaving only the USB lead unplugged on the Pi, and the red RX light on the rs232/ttl converter starts flashing rhythmically, the bus light goes on on the Victron BlueSolar, all seems happy. Then I plug the usb-serial converter into the Pi and it all goes pear shaped... the red light slows down, flashes 5 times or so then stops... I swear it reduces in intensity as if something is sucking the life blood from this side (although it is separately powered with an isolated supply). Plug the same usb/serial converter into the laptop, and it works perfectly.

It's as if there is something fundamentally wrong with my understanding of how serial comms even work...

Edit: Tried a different usb/serial device as well. The PL2303 based device does the same as the ftdi based device. To be fair, there is an unnecessary conversion in there, which is there only because this is the hardware I had at hand: I go from 5V TTL level serial up to Rs232 (that's +- 12V levels), and then I go back down to lower voltage with a usb-serial converter. So there is an unnecessary RS232 level in the middle. I could just go with a normal TTL->USB module, like the cp2102. What I don't understand at all is why it works on the laptop but fails on the Pi. Even with the stock arduino's onboard ftdi ttl->usb chip it simply doesn't work :-(

Can you run your sketch and get serial output on a PC? I test and get everything working on the arduino side on a pc and then I pove to the Pi. 

Link to comment
Share on other sites

10 hours ago, jdp said:

Plonky how did you get Mosquitto on the go on the Pi? I installed the ltest one for Jessie but it seems the process does not start and I get a connection refused. The sub and pub tools work as I can hook intot the Mosquitto test server. 

I compiled from source. There is a systemd startup file in my github repo.

 

https://github.com/izak/ib.bluelantern/blob/master/systemd/mosquitto.service

 

The README.md in that repo explains how to get mosquitto going, which is basically just to avoid some build dependencies you won't be using (SRV dns support and documentation). In the end I actually skipped the configuration step where it binds to localhost only. This was partly because I just couldn't get it to start reliably, because for some obscure reason the loopback interface doesn't come up in time and it fails to start. In the end I figured it is better to let it bind to the all interfaces and rather put a firewall on the pi.

Link to comment
Share on other sites

10 hours ago, jdp said:

Can you run your sketch and get serial output on a PC? I test and get everything working on the arduino side on a pc and then I pove to the Pi. 

I have a bit of test code, which basically puts the MCP2515 into loopback mode so you get back your own packets. Loaded that onto my old Duemilanove with the canbus shield on it and plugged it into the Pi. That works perfectly. That's good news at least, it means the problem is likely with the ttl leveler thing. It's a sparkfun product, but it uses charge pumps to get the rs232 levels rather than a proper max232 or similar. That might be the problem. I should probably just junk it and get a cp2102, though a part of me remains curious about the issue.

 

https://www.sparkfun.com/products/449

Link to comment
Share on other sites

And would you look what I just scratched out of the parts bin... you'd swear I remember having such a thing. Its a TTL->rs232 evaulation board, but it has jumpers so you can break out/disable any of the lines. So it should be easy to hook into rx and tx... :-) Why... because I'm the king of recycled electronics :-)

Edit: Darn-it, it's a 3.3V board. It's going to take work to make it work with the 5V system of the rest. Oh well... :-)

ttluart.jpg

Link to comment
Share on other sites

I mentioned in an earlier message that too many ftdi interfaces have the same usb id? As it turns out, this problem has been solved already. Udev creates symlinks in /dev/serial, eg:


 

pi@raspberrypi ~ $ ls -l /dev/serial/by-id/
total 0
lrwxrwxrwx 1 root root 13 Feb 24 22:05 usb-VICTRONENERGY_MK2USB_COM_Interface_FTWADOJM-if00-port0 -> ../../ttyUSB0

So that solves that one. You'll have to use this instead of a direct /dev/ttyUSBx path to ensure that it works regardless of the order it initialises in.

 

Also, on the Rpi image I screwed something up in the firewall setup (for those who downloaded that or want to download it). I thought "client all accept" should be sufficient to allow dhcp, but it appears that conntrack can't track the dhcp response if you don't tie it to a network interface. So /etc/firehol/firehol.conf now looks like this:

 

version 5

interface wlan0 dhcp1
    policy return
    client dhcp accept

interface eth0 dhcp2
    policy return
    client dhcp accept

# Accept all client traffic on any interface
interface any world
	server icmp accept
	server ssh accept
	server custom mdns udp/5353 default accept
	server multicast accept
	server custom pyramid tcp/6543 default accept
	server ident reject with tcp-reset
	client dhcp accept
	client all accept

 

Link to comment
Share on other sites

 

3 hours ago, The Terrible Triplett said:

Yup, saw that too. No mk2 code though. That's still stuck somewhere in a repository with other non free stuff, though it will be released at some point, I believe.

Link to comment
Share on other sites

I should have given up on this a long time ago, but you know, ordering in a proper TTL-serial device, though cheap enough, comes with that overhead of shipping that always necessitates padding the order, and it was month end with literally R500 left in the kitty (I'm very strict about dipping into savings) so there I was. Anyway, I've decided to give up on this makeshift serial converter which is basically the sparkfun rs232 shifter wired to a usb-serial converter. As I said earlier, that rs232 level in the middle is unnecessary. In addition, I think it is causing all my troubles. It is basically built on this circuit:

 

https://www.sparkfun.com/datasheets/Prototyping/RS232-Shifter-v2.pdf

 

Now correct me if I am wrong, but that whole parasitic negative voltage thing sitting on the RS-in line, charging capacitor C1, isn't going to work unless the usb-serial converter properly drives that line negative (I suspect it doesn't). I also suspect that somehow, because it is not properly driven, C1 actually charges the other way causing everything to smashed up to 5V VCC. This will explain why it works for a few seconds and then fails: C1 takes time to charge.

 

So the proper solution is just to junk it and use a proper converter. Or crack open the usb-serial converter and solder wires to the pins before the actual RS232 driver.

Link to comment
Share on other sites

1 hour ago, The Terrible Triplett said:

Plonkster, get a Pi 3. :P

Until such time as the Pi grows a can bus interface, there is almost no point in this. In fact, it would make sense to move to an older model B for what I'm doing  :-)

Having said that, there are two other things I could have done.

First: I could have wired the atmega's RX port directly to the serial header on the Pi. One is 5V and the other 3.3V, so I need a 2.2k/3.3k resistor divider to do this, but other than that, it's just two wires (because I'm only reading, not writing).

Second: I could connect the MCP2515 canbus controller directly to the SPI port of the Pi and completely skip the unnecessary atmega in the system.

So why didn't I? Well, I think this way is more flexible. Not everyone will use a Pi. Some people might use an old laptop/tablet. I also want to keep the interface for ve.can and ve.direct the same. Keep it Simple Stupid, as they say.

Link to comment
Share on other sites

(I cannot stop myself.) You calling me stupid? :D:D:D

Seriously though Plonkster. PLEASE tell me that a Pi will work with a Victorn Mk2 to USB and VE.Direct to USB cable?

Link to comment
Share on other sites

13 minutes ago, The Terrible Triplett said:

(I cannot stop myself.) You calling me stupid? :D:D:D

Seriously though Plonkster. PLEASE tell me that a Pi will work with a Victorn Mk2 to USB and VE.Direct to USB cable?

Of course it will. I've already tested it with the mk2, and Ve.direct is really just a serial link (come to think of it, I should match the baud rates, haven't done so yet).

Now if only Communica will wake up and process my order... :-) My favourite seller on BoB doesn't have stock :-(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...