Hi all, I'm using an Ocean Controls thermocouple multiplexer shield on my NEO. I have the arduino side send the temp readings to the serial port. Then on the udoo side it reads/dev/ttyMCC. This all works well. Except that after I reboot the device, the arduino program is still there and running, but returns '-1000' for every temp reading. As you will see in the code below, this means that the bitRead() failed. But once I get into the arduino IDE and upload the arduino sketch it resumes working. Is there something extra I need to do in the udoo boot or arduino setup to make this arduino code work cleanly on reboot? This is the 'readtemperature() function where the problem lies. It is based on the sample code supplied with the Ocean Controls shield: int Read_Temperature(void) { unsigned int temp_reading; // force conversion now.. delay(5); digitalWrite(CS_TEMP,LOW); // Set MAX7765 /CS Low delay(5); digitalWrite(CS_TEMP,HIGH); // Set MAX7765 /CS High delay(250); // wait for conversion to finish.. // read result digitalWrite(CS_TEMP,LOW); // Set MAX7765 /CS Low delay(1); temp_reading = SPI.transfer(0xff) << 8; temp_reading += SPI.transfer(0xff); digitalWrite(CS_TEMP,HIGH); // Set MAX7765 /CS High delay(1); // check result if (bitRead(temp_reading,2) == 1) { // No Connection //log("Read error"); return(-1000); // Failed / NC Error } else { return((int)(temp_reading >> 5)); //Convert to Degc } }
The Arduino part of the Neo boots much faster than the Linux (A9) side. When sending data from Arduino to Linux without reading on the Linux side the serial buffer can be overflowing causing all strange things to happen. So it could help that you program your Arduino sketch so that it will only send data if it is sure there is someone listening on the Linux side.
Thank you, I'll try that. It doesn't feel like that's the problem, because when I watch the serial I see the new update every 10 seconds, it just has no valid data! But as you say, strange things can happen.