Beginner mistake :-) But since IOIO is for beginners like me, why not adding a little comment on that in the documentation (https://github.com/ytai/ioio/wiki/UART)?
Luckily I did not break the Cozir sensor, but I might have well broken the other one (for which I was not more successful swapping the RX/TX) :-) B. On Wednesday, December 31, 2014 3:34:30 AM UTC+1, Ytai wrote: > > Yes, hooking up the transmit line (tx) from the IOIO to the receive line > (rx) of the device is the common way to connect. Luckily, you haven't > caused any damage while doing it wrong initially. > On Dec 30, 2014 2:37 PM, "Ben" <[email protected] <javascript:>> wrote: > >> Hello, >> >> Back from holiday break. Well I have to admit that swapping the RX & TX >> did the trick. It works now. I tried that with a different sensor model >> without success but it seems to be the solution for the Cozir sensor. >> >> But is it normal to link the CoZir RX pin to the TX Pin of the IOIO? Just >> new to UART, it would be good to know for others. Otherwise there is an >> error either in the IOIO javadoc or the Cozir Dpcument ( the first >> argument of the openUart function is the RX as per javadoc and it links >> to the TX as per CoZIR sensor documentation) >> >> Thanks again for the great support, >> >> B. >> PS: the way to add all the digits is indeed odd but it is the way this >> sensor communicates its result. Not the most efficient from a communication >> perspective but once we get use to it, it is not that bad to interpret. >> >> >> On Thursday, December 25, 2014 8:16:21 AM UTC+1, Ytai wrote: >>> >>> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> 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.
