Moteino 2 serial ports?

Started by kniqht152, September 25, 2015, 10:23:03 AM

kniqht152

Hi guys!

I'm new here but I've done a few small projects with the moteino platform and I'm really enjoying playing around with it, I have a question in relation to a project I'm working on.

I'm trying to build a smart wrist watch. I've got a moteino, an OLED screen, and a RTC module from spark fun but it looks like (and go figure) the regular moteino only has the 1 serial port. I'll need a serial port each to interface with the OLED screen and the RTC module from spark fun.

So my question is, is there a way to convert some of the other pins on the moteino to act as a serial port? Or possibly use the serial port pins that are provided ALONG WITH the serial port pins used to upload sketches? (they are separate right?)

TomWS

Quote from: kniqht152 on September 25, 2015, 10:23:03 AM
Hi guys!

I'm new here but I've done a few small projects with the moteino platform and I'm really enjoying playing around with it, I have a question in relation to a project I'm working on.

I'm trying to build a smart wrist watch. I've got a moteino, an OLED screen, and a RTC module from spark fun but it looks like (and go figure) the regular moteino only has the 1 serial port. I'll need a serial port each to interface with the OLED screen and the RTC module from spark fun.

So my question is, is there a way to convert some of the other pins on the moteino to act as a serial port? Or possibly use the serial port pins that are provided ALONG WITH the serial port pins used to upload sketches? (they are separate right?)
You could use software serial on non-serial port pins, but which devices are you using from Sparkfun?  I would expect them to have devices that support either I2C or SPI, either of which you could use with basic Moteino.

Tom

kniqht152

#2
Hi Tom thanks for the reply.

I'm using these guys:
https://www.sparkfun.com/products/12708?gclid=CNrM2OO5ksgCFYM-aQodJ5cD4w
https://lowpowerlab.com/shop/oled

It does say the RTC is I2C and SPI compatible. Not that I know what that means. I'm still fairly clueless, I had no idea software serial exists.

Excuse me while I go google stuff.

[Edited]

Is this what you meant by software serial? https://www.arduino.cc/en/Reference/SoftwareSerial
Looks like I might need to go that route.

Felix

Hey kniqht152,
The OLED is I2C and also the RTC which you linked. I2c is a serial protocol but not the regular serial used for programming (USART).
I2C for these is on A4 and A5. So you should be good to go without the need of an extra UART serial port.
For examples how to use the OLED see my Motion OLED Mote example.

kniqht152

#4
Hey Felix thanks for chiming in, also props on a wonderful product!

I actually did get the screen connected and working yesterday so YAY, but I was under the impression that the RTC needed to be connected to the SDA and SCL pins (A4 and A5) as well.

We can't have both the RTC and screen connected to the same pins right? I mean, not practically...

I just read up on this i2C stuff. I ACTUALLY CAN wire 2 devices in parallel with those pins and reference them by their i2c address.

Can someone confirm?


TomWS

Quote from: kniqht152 on September 25, 2015, 11:28:54 AM
We can't have both the RTC and screen connected to the same pins right? I mean, not practically...
Yes you can, if the device addresses are different.

Tom

kniqht152

Perfect Tom that's what I need to hear.

Thanks a lot!

Felix

Usually if you have multiple I2C devices of the same type there is some kind of mechanism built in them so they can all share the same bus but with different addresses. I don't have a ton of I2C experience but check out this great I2C spec writeup by Sparkfun.

TomWS

It took some digging in the DS1307 spec, but its 7 bit I2C address is: 0x68, the OLED display is 0x3C so there is no conflict and both of these can be used on the same bus. 

Be aware, however, that breakout boards tend to have the I2C pullup resistors mounted on the breakout so you'll have two sets of resistors on the I2C bus.  You should remove the resistors from one of the boards (I suspect the DS1307 will be easier to access the resistors).  It may work with both sets of resistors, but it's safer if you remove one of the sets.

Tom