After a couple of issues, the ESP8266 solar logger I started building is actually functioning! What where the problems?
Well, first of all, the MAX3232 adaptor I’m using has the wrong plug on it… a female block, instead of male, and it took me two days of hunting to find the adaptor to reverse this. I found it while fidgeting during a meeting of all things.
Next, it returned nothing when plugged in. I wasn’t sure why that would be, and then it dawned on me… the adaptor, which I tested successfully, is made for connecting to a computer, so it can speak to TTL level devices. That means to connect it to a separate device, I needed a null-modem adaptor. I have a cable that’d do just that, but it would require a second male-male DB-9 adaptor! So I had to buy one.
With that procured, I hooked it up and it started logging data successfully. Power cycling the inverter to get it to go to sleep, however, and it did not self-start again. It seemed like the “initialize” packet wasn’t being sent correctly. Double check my connections again, and then after that, hook the device back up to the serial port on my laptop. Using
stty -F /dev/ttyUSB0 9600 to set the baud rate correctly, then doing
hexdump < /dev/ttyUSB0, I can see that the initialization packets are sent. So let’s hook it up to the APU and compare. Huh, that’s weird:
0000000 233f 347e 7e41 5932 3031 3030 3f23 233f
0000010 347e 7e41 5932 3031 3030 3f23 233f 347e
0000020 7e41 5932 3031 3030 3f23 233f 347e 7e42
After double-checking my code, it turned out I pasted the first packet twice… the one that initializes the serial port, but not the one that says “spam the shit out of me with update packets”. After fixing that, building, and flashing, and it’s working correctly.
I’ve still got a few other things I’d like to do:
- Clean the code up a bit more.
- Probably some status LEDs.
- Maybe get a PCB made up, with a properly wired DB-9 male socket on it that’ll interface straight in, so I can have my null-modem cable back.
- I think I’ll have it ship other data back to collectd while I’m at it. Pretty sure I can do that.
- Configurable intervals (current is 15 seconds, though making it much bigger will be pretty rough in terms of buffer size).
But for now it’s working. I’ll keep an eye on it and make sure it works tomorrow too.