Library assistance needed for a smartphone/tablet interface to the Teensy 3x

Status
Not open for further replies.

t3andy

Well-known member
@Paul S ... In our project, we are using the Teensy 3x as a smartphone interface. The 1Sheeld library compiles fine for any standard
Arduino (1.0) board but fails with the Teensy 3x. Any help is appreciated. (See attached library file)
Not to worry, there are only about seven "simple" errors!
Note: oneSheeld is the library name/folder and use any of the provided user examples.

Errors:
C:\Users\Andy\Documents\Arduino\libraries\OneSheeld\OneSheeld.cpp: In member function 'void OneSheeldClass::sendPacket(uint8_t, uint8_t, uint8_t, uint8_t, ...)':
C:\Users\Andy\Documents\Arduino\libraries\OneSheeld\OneSheeld.cpp:81:3: error: 'va_list' was not declared in this scope
C:\Users\Andy\Documents\Arduino\libraries\OneSheeld\OneSheeld.cpp:81:11: error: expected ';' before 'arguments'
C:\Users\Andy\Documents\Arduino\libraries\OneSheeld\OneSheeld.cpp:82:28: error: 'va_start' was not declared in this scope
C:\Users\Andy\Documents\Arduino\libraries\OneSheeld\OneSheeld.cpp:94:56: error: expected primary-expression before '*' token
C:\Users\Andy\Documents\Arduino\libraries\OneSheeld\OneSheeld.cpp:94:57: error: expected primary-expression before ')' token
C:\Users\Andy\Documents\Arduino\libraries\OneSheeld\OneSheeld.cpp:94:57: error: 'va_arg' was not declared in this scope
C:\Users\Andy\Documents\Arduino\libraries\OneSheeld\OneSheeld.cpp:107:21: error: 'va_end' was not declared in this scope


For those not familiar with the 1Sheeld ...
Its a hardware Arduino shield with Bluetooth and co-processor that uses Firmata to link the Arduino GPIO to an Android app on a smartphone or tablet.

Kickstarter link:
https://www.kickstarter.com/projects/integreight/1sheeld-replace-your-arduino-shields-with-your-sma


We are using the Teensy 3x in a project that adds shields (see below) using a smartphone or tablet.

Parts required:
Teensy 3* Development Board & Arduino Shield <----- Tindie
Teensy 3x (PJRC.com)
Level converter for tx/rx on 1Shieeld (Adafruit) <--- not needed - 1sheeld has a 3.3 v interface switch.
1Sheeld Arduino Hardware Shield - Arduino shields using smartphone/tablet (Seeedstudio.com)
Also needed is a smartphone or tablet with Bluetooth 2.1 and Android release Gingerbread.


http://www.1sheeld.com/docs <----- library download link

http://www.seeedstudio.com/depot/1Sheeld-Replace-your-Arduino-shields-with-smartphone-p-1870.html

---------------
Sensor Shields
---------------

accelerometersensor-library
gravitysensor-library
temperaturesensor-library
lightsensor-library
temperaturesensor-library
pressuresensor-library
proximitysensor-library
gps-library
gyroscopesensor-library
orientationsensor-library
magnetometersensor-library

-----------------
Basic I/O Shields
-----------------

buzzer-library
togglebutton-library
keyboard-library
led-library
slider-library
pushbutton-library
mic-library
sevensegment-library
gamepad-library
keypad-library

---------------------
Communication Shields
---------------------

phone-library
skype-library
sms-library
email-library

---------------
Special Shields
---------------

clock-library
lcd-library
notification-library
camera-library
musicplayer-library

--------------------
Social Media Shields
--------------------

foursquare-library
twitter-library
facebook-library


:cool:
 

Attachments

  • 1sheeld_arduino_library_v1.0.zip
    88.5 KB · Views: 134
Last edited:
Downloaded Arduino 1.0.5-r2 and TeensyDuino revision 1.19 and OneShield compiled properly for both the Teensy 3.0 and 3.1.
Note: TeensyDuino revision 1.18 does not compile properly for the OneShield ??? :eek:

Now we have to wait on the hardware being shipped from the far corners of the world. (Onesheeld from Seeedstudio China and Tindie Teensy 3x development board from Japan.

Even though the OneSheeld library compiles properly it does not mean all the software modules will work. Only actual hardware/software testing will reveal if the smartphone interface will work with the Teensy 3x. Stay tuned ...
 
Last edited:
Could you please be a little more specific about the steps you took? Which example did you compile?

The 1Sheeld library compiles fine for any standard
Arduino (1.0) board but fails with the Teensy 3x. Any help is appreciated. (See attached library file)

I added the library you posted to Arduino 1.0.5 with Teensyduino 1.19 installed. With Teensy 3.1 selected in Tools > Boards, I opened File > Examples > OneSheeld > Simple > Accelerometer. I clicked Verify.

It appears to compile without any errors. Here's a screenshot:

1s.png

EDIT: oh, I see now the issue was apparently with version 1.18. Ok, problem solved!
 
Looking at the code, I believe a tiny patch will be needed in OneSheeld.cpp.

Near the end is this:

Code:
//Instantiating Object
#if defined(__AVR_ATmega32U4__)
OneSheeldClass OneSheeld(Serial1);
void serialEvent1()
#else
OneSheeldClass OneSheeld(Serial);
void serialEvent()
#endif

That #if should probably be:

Code:
//Instantiating Object
#if defined(__AVR_ATmega32U4__) || defined(CORE_TEENSY)

Without this, the library will default to trying to communicate on the USB virtual serial, rather than Serial1 to the shield (or "sheeld"....)

Do they have a GitHub repo where I could send a pull request? Or does anyone know how to contact the author? I didn't see any email or other contact info in the code.
 
A past project.. we got a circa 2014 Android Samsung phone to talk through its USB port to a Digi XBee IEEE 802.15.4 radio. Via an FTDI to UART chip.
Did not need to root the phone.
 
Oh... it's also going to need serialEvent, which I haven't implemented, but it's on my todo list. Looks like I ought to get on that....
 
Do they have a GitHub repo where I could send a pull request?

No, I don't believe so. Since it was a kickstarter project done by a team, then the only place for the Arduino/Teensy 3x code would be ...
Link:
http://www.1sheeld.com/downloads

Or does anyone know how to contact the author?

I was told that any contact should be made on their forum board and their team response would be quick.
Note: See our question answered on their "installation and troubleshooting"

http://www.1sheeld.com/forum

Thanks Paul - we totally missed the serialEvent not working on the Teensy 3x.

Another Note: We believe their co-processor on the oneSheeld board (AVR_ATmega162)
which processes the Bluetooth and Firmata data to/from the Arduino/Teensy 3x is used
as a bridge. This firmware will be released along with their oneSheeld schematics.
A very enterprising Teensy forum board user could easily duplicate their oneSheeld with
2 Teensy 3xs and a HC-06 bluetooth module. This would reduce the system cost from
$100 to $50 USD and have all their Android software apps for FREE.

In the meantime ... waiting on the serialEvent handler.
 
Last edited:
A past project.. we got a circa 2014 Android Samsung phone to talk through its USB port to a Digi XBee IEEE 802.15.4 radio. Via an FTDI to UART chip.
Did not need to root the phone.

@Stevech - remind us as "topper" in the comic series Dilbert. :rolleyes:

What oneShieeld has accomplished is writing and making work all the above software shields that can work on any Smartphone/tablet. Please review the Kickstarter page on their project and you will see the amount of work done to bring their project to closure.
:cool:
 
@Stevech - remind us as "topper" in the comic series Dilbert. :rolleyes:
Just offering to assist anyone who has the same goal. My bad for not clarifying for @t3andy that it wasn't intended as mere boasting.
 
Last edited:
Just offering to assist anyone who has the same goal

Ok, how about a serialEvent handler - for the Teensy 3x? ;)

On another note ... The cost of Android tables are dropping every day. Some tablets can be had for $50 USD.
The ability to harness the massive resources of the Teensy 3x to wirelessly connect via Bluetooth to a smartphone/tablet, would be a major step forward in connecting to the internet by using the smartphone/tablet hardware. Applications like security and home monitoring (without fees)
could be easily designed with little effort. :cool:

BTW ... The TI CC3000 can now RIP with lousy firmware :mad:
 
Last edited:
Note, on the cheap tablets, make sure it has the appropriate connections you will need. My Amazon Kindle Fire for instance does not have bluetooth. I could imagine perhaps there are tablets without the headphone jack.

I wonder if we build the Teensy with HID instead of serial, whether we could use USB OTG that is available on some phones.

However, for connecting an Android to a Teensy 3.x, I'm wondering why you need the 1shield at all? I've used a HC-05 bluetooth serial chip to connect to my Samsung S-2 phone, and I've used free apps to have a set of buttons that send particular text strings to the Teensy 3.x. With Apple phones, you would need a bluetooth LE device instead of 'standard bluetooth'.
 
Last edited:
Note, on the cheap tablets, make sure it has the appropriate connections you will need
From above ... Also needed is a smartphone or tablet with Bluetooth 2.1 and Android release Gingerbread.


My Amazon Kindle Fire for instance does not have bluetooth

What? You have been Bezos-ed - no Bluetooth!!!!
Please note: The Kindle Fire is a e-book reader with a WiFi connected to Amazon. There is a difference between an e-book reader and an Android tablet.:)

However, for connecting an Android to a Teensy 3.x, I'm wondering why you need the 1shield at all?
The co-processor makes it easily to access the GPIO on the Arduino/Teensy and prevents hogging of the main microcontroller.
Besides, there should be no reason to reinvent the wheel when the oneSheeld team members did all the grunt work.
Of course, if you are an University type doing it twice does not matter.:)

That's why I said above ...
A very enterprising Teensy forum board user could easily duplicate their oneSheeld with
2 Teensy 3xs and a HC-06 Bluetooth module. This would reduce the system cost from $100 to $50 USD and have all their Android software apps for FREE.
:cool:
 
Last edited:
The Plan ...

Hardware/software Teensy 3x and OneSheed (1Shield) Testing Phases:

However, for connecting an Android to a Teensy 3.x, I'm wondering why you need the 1shield at all?
Thanks Michael ... we changed our mind but Paul would not like to see using 2 Teensys drop down to only one. :(

Note: The ultimate goal is to reach testing phase #4 by using only one Teensy 3.1 and one Bluetooth HC-06 module. The cost reduces from $100 USD down to $30 USD. The only pre-requisite for phase #4 is to be a professional C programmer to merge all the software into the Teensy 3.1 and have all the Android apps work at the same time. Since we are a bunch of hackers, we will stop at phase #3.
Any takers on phase #4 after we did the testing for three phases?

#1. Use a standard AVR Arduino board and 1Sheed shield. <--- Cost ~ $75 USD

Since the Arduino is a 5V device, then keep the 3.3vdc/5vdc switch on 5 VDC on the 1Sheeld. There is another switch that switches the only communications comport between the 1Sheeld and the Arduino. Switch to the Arduino (USB) when downloading user"shield" code and switch back to 1Shield to communicate with the co-processor on the 1Shield. (Normal operation) Note: Arduino has only one comport for communications. All code should work due to the fact the 1Sheeld design team did all the testing in their Kickstarter project?
Note: The AVR 328P only has 32K flash and 2K RAM @ 16 Mhz.
Status: Spot checking their code reveals all is ??.

#2. Use a Teensy 3x and the 1Sheeld shield. <--- Cost ~ $100 USD

For easy hardware testing, we obtained from Tindie, a Teensy 3x development board.(Japan)
https://www.tindie.com/products/freto/teensy-3-breakout-board-and-shield/?pt=directsearch
We will cut the PCB track on back of the Teensy 3x so we could power the Teensy 3x and the 1Sheeld from the barrel 2.1 mm power jack on the development board. We will put the 1Sheeld slider switch to 3.3 VDC since the Teensy 3x Tx & Rx pins are 3.3 VDC. We had to wire the Tx Rx from the Teensy 3.x to the Sheeld Rx Tx and also had to put a software patch in the 1Sheeld library CPP to accommidate the Teensy 3x comport (Serial1) and the Teensy 3x core per Paul S.

#3. Use two Teensy 3x without the 1Sheeld shield. <--- Cost ~ $63 USD

Using the same Tindie development board, we put another Teensy 3x #2, on the bottom and wired both Teensy's 3x serial1 ports together.
We will hopefully obtained the firmware code for the 1Sheeld co-processor and download in the Teensy 3x #2. We will wired up Teensy 3x #1 TX to Teensy 3x #2 RX and Teensy 3x #1 RX to Teensy 3x #2 Tx.
Make sure to cut the PCB tracks on both Teensy's 3x so you can power both from the onboard 5VDC power supply. You also need to wire in a Bluetooth HC-06 to the Teensy 3x #2 Serialx comport and power it with same 5 VDC supply from the PCB onboard regulator.

http://www.ebay.com/itm/Wireless-Se...dule-HC-06-RS232-With-backplane-/200924726178
Note: The above Bluetooth HC-06 might not work due to the fact that its version 2.0 Bluetooth not 2.1 !!!!

For hard-core Teensy hobbyist, on a budget, just obtain a perfboard and install two Teensy 3x's and one HC-06 Bluetooth module. <--- Cost ~ $40 USD

#4. Use only one Teensy 3.1 without the 1Sheeld shield. <--- ~ $30 USD.

The mighty ARM Teensy 3.1 stamp has 262K flash with 64K RAM @ 96 Mhz and through careful software design, a user could duplicate (with extreme pain) the 1Sheeld co-processor and main controller in one microcontroller. (Teensy 3.1 ARM Stamp) Just wire the Bluetooth HC-06 to the Teensy 3.1 Serialx and configure the software so both the 1Sheeld co-processor firmware and the user code both work alone on one Teensy 3.1! You will need +5 VDC regulated external power for both the Teensy 3.1 and the Bluetooth HC-06 module. The code will have to be very "modular" so if there are any changes in "their" library, it can be easily modified and still work with the 1Sheeld apps.

:cool:
 
Last edited:
The latest 1.20-rc1 has serialEvent support. Please let me know if it works together with the 1Sheeld library? It should, but so far it's only been tested with Arduino's example program. As far as I know, 1Sheeld is the first library using serialEvent.
 
Just received updated info on the 1Sheeld shield board...

1Sheeld Tech Specs:
Uses a standard HC-06 Bluetooth adapter
(Bluetooth 2.1) <-------
Range up to 30 feet
Running on an Atmel ATMega162 <------
7.37 MHz operating frequency
Communicates with Arduino using UART
Communication baud rate 11,5200 b/s


An "oddball Bluetooth" HC-06 v 2.1 module is being used on the 1Sheeld.
Any user knows where to find this unique "slave" Bluetooth module?
It has to be very cheap?

Update ... A compatible one that can be used is the TI/Panasonic CC2560-PAN1325A and Digikey sells them around $15.
Another Bluetooth compatible module is Roving Networks/Microchip RN-42. ($15 USD)
So, the very inexpensive ebay HC-06 modules will not work? :(


Bluetooth module
What Bluetooth HC-06 v 2.1 module are you using on your 1Sheeld?
Can it be easily obtained on the Internet? Ebay?
All the ones on Ebay uses v 2.0?

you can buy any of those of ebay, Android phones support both of them. :) Ours is the same as the ones in the market. but sometimes manufactures use 2.0 and 2.1 for the same device.

Again we stand corrected ... we shall see:cool:
 
Last edited:
The latest 1.20-rc1 has serialEvent support. Please let me know if it works together with the 1Sheeld library? It should, but so far it's only been tested with Arduino's example program. As far as I know, 1Sheeld is the first library using serialEvent.

Along with the following patches ...

Code:
Two places to patch for the Teensy 3x in OneSheeld library
Added "|| defined(CORE_TEENSY)" to the following file

File: OneSheeld.cpp

Line 59
//Library Starter
void OneSheeldClass::begin(long baudRate)
{
  #if defined(__AVR_ATmega32U4__)  || defined(CORE_TEENSY)
  Serial1.begin(baudRate);
  #else
  Serial.begin(baudRate);
  #endif
}

Line 306:

//Instantiating Object
#if defined(__AVR_ATmega32U4__) || defined(CORE_TEENSY)
OneSheeldClass OneSheeld(Serial1);
void serialEvent1()
#else
OneSheeldClass OneSheeld(Serial);
void serialEvent()
#endif


@Paul S ... Your serialEvent() seems to work on the Teensy 3.1 with 1Sheeld library. :)
More testing is needed.
 

Attachments

  • photo.JPG
    photo.JPG
    228.8 KB · Views: 212
Last edited:
Testing Phase #1:

#1. Use a standard AVR Arduino board and 1Sheed shield. <--- Cost ~ $75 USD

AVR Arduino test Board: Seeeduino v3 (328P with FTDI) by Seeedstudio <--- $22.50
Note: Any Arduino board can be used with the 1Sheeld?

1Sheeld shield cost: <---- $55.00
System: PC Win 8.1 64 bit
Arduino IDE: 1.0.5 Rc2
1Sheeld Arduino library: v 1.0
Tablet/smartphone used: Android Samsung Tab 2

Comments:

Background: The 1Sheeld shield uses an Arduino co-processor (ATMega162) and a HC-06 v 2.1 Bluetooth module. This shield communicates via TTL serial to an Arduino compatible board on Serial1. Firmata, which is a communications protocol for the Arduino GPIO is used to serially communicate between the Arduino and 1Sheeld microcontrollers. The data is sent/received to/from the HC-06 Bluetooth module by the 1Sheeld co-processor.
You need to pair and link your smartphone/tablet Bluetooth to the 1Sheeld shield Bluetooth for proper operation.

All Sheelds app code sketches should have been already tested by the Kickstarter 1Sheeld team?

Uses Arduino special serialEvent command for commands from 1Sheeld co-processor. Paul S. made a patch for the Teensy 3.x for serialEvent();
For Arduino operation - flip the power switch on 1Sheeld to 5 VDC only and keep it there.
For Arduino operation - flip the communications switch between USB app sketch download and normal Bluetooth communications operation.
Modules/app shields were only "spot" tested:

Testing status: OK <----------<<<<<
 
Testing Phase #2:

#2. Using the Teensy 3.x (3.1) and 1Sheed shield. <--- Cost ~ $100 USD

Parts:
1Sheeld shield cost: <---- $55.00 (China - Seeedstudio)
Tindie Teensy 3.x Development shield for the Teensy 3.x (Japan)
Teensy 3.x (3.1)
Tablet/smartphone used: Android Samsung Tab 2


Software:
System: PC Win 8.1 64 bit
Arduino IDE: 1.0.5 Rc2 - along with Teensy release 1.20 rc-1 for serialEvent()
1Sheeld Arduino library: v 1.0 with patch(es) for Teensy 3.x. (see above)
Tablet/smartphone used: Android Samsung Tab 2

Comments:

Background: The 1Sheeld shield uses an Arduino co-processor (ATMega162) and a HC-06 v 2.1 Bluetooth module. This shield communicates via TTL serial to the Teensy 3.x on Serial1. Firmata, which is a communications protocol for the Arduino GPIO is used to serially communicate between the Teensy 3.x and 1Sheeld microcontrollers. The data is sent/received to/from the HC-06 Bluetooth module by the 1Sheeld co-processor.
You need to pair and link your smartphone/tablet Bluetooth to the 1Sheeld shield Bluetooth for proper operation.

Note: All Sheelds app code sketches should have been already tested by the Kickstarter 1Sheeld team BUT more testing is needed between the Teensy 3.x and 1Sheeld.
Note: Uses Arduino special serialEvent() command for firmata commands from 1Sheeld co-processor.
Note: Paul S. made a patch for the Teensy 3.x for serialEvent(); (Teensy release 1.20 rc-1)
For Teensy operation - flip the power switch on 1Sheeld to 3 VDC only and keep it there.
For Teensy operation - flip the communications switch to close for normal Bluetooth communications operation.
Modules/app shields were only "spot" tested:

Testing status: OK <----------<<<<<
 
Last edited:
Status
Not open for further replies.
Back
Top