Issue with device configuration

I continue to receive the following error when trying to install temp sensors:
Error while receiving device configuration: SyntaxError: Unexpected token C

I have even programmed another core to see if it was causing the issue. I have one BrewPi set up that did not have this issue and it starts up almost immediately when powered on. This BrewPi seems to take about 5 minutes before the screen displays anything or beeps.

You’ll get this error when there is no connection between browser and script, either a connectivity issue or the python script is not running.

It is very strange that it takes so long before you hear a beep. What if you power it with a phone charger? I am asking because it might be hanging on something USB related. Did you try rebooting?

I have powered it with the 12v connection, the usb to the Pi, and a phone charger to the usb connection. They all take a very long time for it to load. I also had a difficult time getting the Core to take the bin file. It kept giving an error on the USB connection failing. It finally took. I figured it might be a bad Core, so I replaced it and it did the same thing.

I purchased another RPi at the same time as this one for a friend and have it up and running for him. It loads within a few seconds and had no issues with the temp sensors or heating and cooling connections. I followed the same procedure for this one, but it just does not want to cooperate.

Could it be a hardware issue on the board related to the USB?

My first guess would be a crappy USB cable, did you try with a different one?

Yes, I used the cable from the BrewPi that worked and got the same error. It also takes a long time to cycle through looking for a serial port that is open.

Do you have the possibility to swap the spark cores between the brewpi boards? Best: just put the spark code that doesn’t work in the setup that does work. When you can apply this tactic to all parts of the system, you can find the cause.

If this helps, I’ve also seen the brewpi spark v1 take a very long time to boot up and do the “beep”. Sometimes it takes so long I have to give up and go home. I’ve tried connecting the 12v in addition to the supplied USB cable to the Pi with no luck. After leaving unplugged and connecting 1hr later it worked again so it seems intermittent.

I suspect this is because your pc is sending things over serial. Does it also do that without usb or powered with a phone charger?

I’ll try this out when I’m with the hardware next and report back.

Well, I swapped out the cores yesterday on my friends BrewPi. My core worked fine on his BrewPi, but his core had the same issue as mine when I inserted it on my BrewPi.

Can you narrow it down to the board, or might the PC/Pi play a role?
I can swap your BrewPi when I get back.

I used my friend’s setup and just swapped out the boards for the testing. The pi was the same one used for both boards. His board worked with both my core and his. Both cores failed on my board.

Yeah that confirms a bad board, I’ll ship you a new one as soon as I get back from Cambodia. I expect an issue with the OneWire bus master or the pullup resistors on its I2C port. Please create a ticket with your address details.

First off – this is some impressive amount of work you guys have done here.

I’ve got a similar trouble, but am unable to follow the same debug steps as above. Brand new BrewPi Spark, new CanaKit Raspberry Pi B+, all with the latest brew pi updates and released firmware.

There are 2 issues which may be related. (#1) The spark connection to the raspberry pi seems intermittent. I can unplug it and plug it back in and sometimes (after a minute) all is well. But most of the time I get the same Unexpected token C message…
In one case, I had a connection established and all I did was change the device number (in the web interface) and then suddenly the web pages shows “Cannot receive LCD text from python script”. Checking /dev on the raspberryPi, the ttyACM0 is still there (my spark), which leads me to believe it’s a python script issue. Perhaps the python script is crashing and leaving the serial object open?

Sure enough, checking the logs:

Traceback (most recent call last):

File “/home/brewpi/brewpi.py”, line 728, in
ser.write(‘l’)
File “/usr/local/lib/python2.7/dist-packages/serial/serialposix.py”, line 518, in write
raise SerialException(‘write failed: %s’ % (v,))
serial.serialutil.SerialException: write failed: [Errno 5] Input/output error
Aug 18 2015 16:02:02 Opening serial port
Aug 18 2015 16:02:12 Errors while opening serial port:
Could not find compatible serial devices

(#2) Along with my brewpi spark I bought 2 of the new one-wire temp sensors (with the RJ connector already installed). One of them seems to want to read 182F when I first plug it in. It slowly works it’s way down to room temperature. This device is set as the beer temp (do you have slew-rate limiting on the reporting?). Like I said, not sure if this is related, or a bad sensor, or one-wire pullups are having issues.
UPDATE: Looks like the sensor is fine – the slew rate limit has to do with it being assigned to the “beer temp”. I just swapped my 2 detectors and when set to “Room” they respond quickly, but when set to “beer” they seem to have an artificial rate limiter imposed. Might be topic for another discussion.

Any thoughts or help?

Further regression:
I was able to recover from that lockup by VNC’ing into the rPi and running the updater.py script (which shuts down all the brewpi python scripts). I also have to unplug/replug the spark and then everything comes back up all right, for a moment. Here’s the error log when it goes down again:

Aug 18 2015 16:12:12 Found BrewPi v0.2.11 build 0.2.11-0-ga28c22d, running on a Particle Photon with a V2 shield on port /dev/ttyACM0

Aug 18 2015 16:13:04 Serial Error: [Errno 5] Input/output error)
Aug 18 2015 16:13:04 Serial Error: [Errno 5] Input/output error)
Aug 18 2015 16:13:05 Serial Error: [Errno 5] Input/output error)
Aug 18 2015 16:13:05 Serial Error: [Errno 5] Input/output error)
Aug 18 2015 16:13:06 Serial Error: [Errno 5] Input/output error)
Aug 18 2015 16:13:07 Serial Error: [Errno 5] Input/output error)
Aug 18 2015 16:13:07 Serial Error: [Errno 5] Input/output error)
Traceback (most recent call last):
File “/home/brewpi/brewpi.py”, line 728, in
ser.write(‘l’)
File “/usr/local/lib/python2.7/dist-packages/serial/serialposix.py”, line 518, in write
raise SerialException(‘write failed: %s’ % (v,))
serial.serialutil.SerialException: write failed: [Errno 5] Input/output error

I find the above sequence of events quite repeatable. Python script crashes at that line and I can power cycle the spark and kick the scripts. Works for a while, then eventually chokes again.

In the current code @Elco filters the beer and fridge temperatures but not room temperature. I believe in the next revision he is going to change this to filter the PID outputs instead of the temperature inputs.

UPDATE
Further Regression:
I’ve had the setup stable for 16 hours now. The trick seems to involve the micro-USB connector on the BrewPi Spark. By VNC’ing into the Pi and looking at /dev I was able to wiggle, push, & prod the cable until I got a reliable connection. I suspect that the data lines on the micro USB connector are not properly soldered or strain relieved. Definitely not the cable. When I get a a chance, I will open up the BrewPi spark and do a little F/A and report back here.

UPDATE 8/21:
I opened up the spark case and noticed 2 things. (#1) The spark board itself was not fully seated into the custom brew board. (#2) three out of 4 of the USB connector pins were cold soldered…still making contact most likely. Anyway – reseated the board and reflowed the cold solder. No more connection issues, but not sure which was the problem.

It does suggest needing a bit more exception handling and reporting to the user when that serial port suddenly goes down. The non-report (to the user when the serial comm got interrupted) made it difficult for me o find the point of failure… I’ve been looking in the code and hope to make minor improvements and issue a pull request or two down the road.

Just documenting it in this thread in case anyone else gets here with a google search.

Has anyone found the root cause of this? Is it because of bad BrewPi boards? I ran into this issue today after setting up my Raspberry Pi and BrewPi for the first time. I’m pretty bummed out.

I have had a few Photons with a bad USB connector. As these are assembled by Particle and not by BrewPi, I cannot do much about it except notifying Particle of the issue.

In most cases though, swapping the USB cable fixed the issue.

I tested your suggestion of plugging the brewpi spark into just a 5v charger and I still get a white screen and no boot. The same thing happens if plugged into the usb port of the pi. Oddly, when the brewpi spark is in a cold and damp atmosphere the problem persists. If I put the controller in my warm dry pocket for 15mins or warm it up on a radiator it boots fine.

One time, it couldn’t decide whether to boot or not so it did this flashing https://goo.gl/photos/7RPJJH9YMrkmvrRQ8

I have had to solder the micro usb connector on my brewpi photon twice after accidentally applying too much stress to the cable. (I have brewpi spark and photon controllers for two different breweries.) It seems the tiny photon board can’t take too much strain. One solution would be to introduce an intermediate cable/connector that is tied to the brewpi board so the connector to the outside world does not load the photon board directly.