Could you have swapped Tx and Rx? Also, the adding of all digits seems wrong (I know this is the same as the app note too, but it looks wrong there as well). Anyway, this isn't your problem right now since you don't even get there. I would temporarily replace the entire loop() with a simple Log.d(TAG, "read: " + in.read()); just to figure out what's really going on. On Dec 24, 2014 1:01 AM, "Ben" <[email protected]> wrote:
> Thanks Ytai for the proposal. > > I try to build something similar to that: > http://www.co2meters.com/Documentation/AppNotes/AN128-%20Cozir_Arduino.pdf > . Which from a electronic schema is rather straight forward. Documentation > of the sensor: > http://www.co2meters.com/Documentation/Manuals/Manual-COZIR-Sensor.pdf > > I connect to the 3.3V of the IOIO, one of the GND and finally pin 12,14 > for the RX,TX > > My code extract: > > In Setup: > > uart_ = ioio_.openUart(12,14,9600,Uart.Parity.NONE,Uart.StopBits.ONE); > > > > uart_input = uart_.getInputStream(); > > uart_output = uart_.getOutputStream(); > > > > In Loop: > > > int availableBytes =uart_input.available(); > > > if (availableBytes > 0) { > > > int command = uart_input.read(); > > > switch (command) > > > { > > > case 'Z' : > > // nerver goes here always get 0 as command with only one byte > String CO2Filtered = String.valueOf((char)(uart_input.read())) + > > > String.valueOf((char)(uart_input.read())) + > > > String.valueOf((char)(uart_input.read())) + > > > String.valueOf((char)(uart_input.read())); > > > setCO2Text(CO2Filtered); > > > break; > > > > > > case 'z' : > // never goes here > > String CO2NonFiltered = String.valueOf((char)(uart_input.read())) + > > > String.valueOf((char)(uart_input.read())) + > > > String.valueOf((char)(uart_input.read())) + > > > String.valueOf((char)(uart_input.read())); > > > setCO2Text(CO2NonFiltered); > > > break; > > > } > > Normally the sensor should start to fire immediately but in my case I get > maximum on byte with a 0 value (thus no Z) > > I tried to push command with > > uart_output.write("Z \r\n".getBytes()); > > > uart_output.flush(); > > Thread.sleep(500); > > int n = uart_input.available(); > > if (n>0) > > { // never goes here > > int a = uart_input.read(); > > a = uart_input.read(); > > a = uart_input.read(); > > a = uart_input.read(); > > a = uart_input.read(); > > > By the way, I am connecting with the IOIO through Bluetooth. Could that > make a difference? > > Thanks in advance > > B. > > > On Wednesday, December 24, 2014 4:03:51 AM UTC+1, Ytai wrote: >> >> I'm not familiar with such a tutorial except the information on the IOIO >> wiki. How about you share your circuit, which sensor you're using and the >> relevant piece of your code and I'll try to help. >> On Dec 23, 2014 3:14 PM, "Ben" <[email protected]> wrote: >> >>> Hello, >>> Since 2 days I am struggling trying to connect the IOIO to a sensor >>> through UART. I tried 2 different sensor models and 2 different IOIO (in >>> case one has a defect). Still does not work. When I loop RX with TX, I can >>> read whatever I have sent but once connected to the sensor: silence. >>> >>> Can one point us to a kind of tutorial how to connect the IOIO with a >>> UART sensor (including the electronic schema, sensor model, and source >>> code)? I guess that if I would be successful with such tutorial, I could >>> deduce what is wrong with my setting. >>> >>> Many thanks, >>> >>> B. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "ioio-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at http://groups.google.com/group/ioio-users. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > You received this message because you are subscribed to the Google Groups > "ioio-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/ioio-users. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "ioio-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/ioio-users. For more options, visit https://groups.google.com/d/optout.
