M5 Stack ESP32 and RICOH THETA


#1

TheM5 Stack is an ESP32 Arduino development platform that comes in a nice case with buttons and and a large number of IO ports.

In the picture below, the M5 Stack is in the upper right.

It’s possible to control the THETA V using the M5 Stack.

This picture from KA-2 on Qiita.

KA-2 also has it working with as a external screen monitor for THETA information.

You can see a demo of his project here:

Project code from KA-2 is here:


Hardware and Basic Kit

Everything comes in a nice plastic box. I got this for $40 from Amazon with 2 day free Prime shipping.

Display looks great.



Test of Plug-in

Compiles no problem on Android Studio.

3181c61f0344fddb11108e5532829bd86bf33679

Set Permissions with Wi-Fi

First, connect to the THETA via USB.

Second, you must give the plug-in permission to use the USB port in order to connect with the M5 Stack. So run the following commands:

$ adb shell settings put global usb_debug true
$ adb tcpip 5555
$ adb connect 192.168.1.1:5555 

NOTE: In the example above, replace the IP address with the IP address of your THETA such as 10.42.0.181:5555 if you have your THETA connected to your computer in Client Mode (connecting THETA to router ).

Third, now connect from your computer directly to the THETA via Wi-Fi.

Connect Vysor to THETA with Wi-Fi

image

If you skipped the adb commands above, the THETA will not show up in Vysor over Wi-Fi.

no%20devices%20found

On the camera itself, if the Wi-Fi LED briefly blinks yellow, this is another indication the plug-in does not have permission to use the USB port. Please repeat the steps in this section to Set Permissions with Wi-Fi.

Connect M5Stack to THETA with USB OTG

When you plug the M5Stack into the THETA, you will see the message below.

Click the checkbox and press OK.

With Arduino IDE

IMPORTANT: The instructions below are for Linux. For Mac and Windows, please see the alternate instructions

Install espressif esp32 support

http://www.m5stack.com/download/package_m5stack_index.json

After adding URL in previous step, go to boards manager and select espressif esp32.

Hit install.

image

Install M5Stack Library from Library Manager.

Install Arduino JSON Library

From inside of Library Manager, search for ArduinoJson
Install version 5.x not the beta version 6, which is installed by default.

Update pyserial

This step likely only needed on Linux.

I needed to update pyserial with

pip install pyserial

Select Board M5Stack-Core-ESP32

Select Port

image

If the USB port does not show up (on Mac), you may need to install the serial driver for CP210x USB to UART Bridge.

See this document for more information.

Add User to Access USB Port

On Linux Ubuntu, I needed to add my user to the group that controls the USB port ttyUSB0.

image

Load Sample Arduino Code From GitHub Repo

The Arduino file is in the same repo as the THETA Plug-in.
In folder M5QR_sample

Upload to M5 Stack

Usage

Press Center Button on the M5Stack to take a picture

left button clears image.

right button restores last QR code.


M5Stack Can Draw Power From RICOH THETA

In my testing of the plug-in, it draws down power from the THETA quickly. Be sure to fully charge your THETA ahead of time for longer testing.

Point Mobile Phone Camera at QR Code

Google Pixel automatically finds URL to go to.

Opens up browser to preview image.


Community Modification for Camera Information


#2

I just got a chance to try this out. Actually, taking a picture with a remote shutter (the USB-C cable I’m using is 3’) and then just scanning the QR code with my regular phone app (iPhone 6 Plus) brings up new photos in Safari. Works really smoothy. I’m going to install the Arduino IDE and install M5Stack tools and see if I can learn more.


#3

For the installation of the M5Stack board on Windows 10, this document is useful.


This was also useful:

run git submodule update --init --recursive in the esp32 arduino folder

M5Stack board detected on Windows

image

ArduinoJson library 5.13.4

image

compile

image

Fully working on Windows 10.


#4

I installed Arduino IDE on my iMac. The documentation in the packaging is outdated. You need to ignore starting guide and use the scripts here:

https://github.com/m5stack/M5Stack/blob/master/docs/arduino-ide/mac.md

Then you can use Boards Manager and find M5Stack-Core-ESP32.


#5

Compile the code with the “verify” button on the IDE. You don’t need to flash the board if you want to preserve your existing program on the M5Stack. From roughly line 346 in the Arduino code, there is a function ExecWebApi. That is taking the results of /osc/state.
https://developers.theta360.com/en/docs/v2.1/api_reference/protocols/state.html

It looks like we can pull the state data as documented in the API link above and then put the results to the screen. It also looks like we could run any API command. I think the next task for the community is to parse the results of state and display to the M5Stack screen. I think the next challenge for @jcasman is to compile the existing code. You’ll need to get the libraries set up.

I think this would be easy for anyone from the embedded IoT community that you were involved with last year.

//-------------------------------------------
// THETA API functions
//-------------------------------------------
int     ThetaAPI_Post_State(void)
{
  int iRet=0;

  String strJson = ExecWebAPI("POST", "/osc/state", "", HTTP_TIMEOUT_STATE);
  
  iRet = strJson.length();
  if ( iRet != 0 ) {
    char sJson[iRet+1];
    strJson.toCharArray(sJson,iRet+1);
    StaticJsonBuffer<350> jsonBuffer;
    JsonObject& root = jsonBuffer.parseObject(sJson);
    if (!root.success()) {
      //Serial.println("ThetaAPI_Post_State() : parseObject() failed.");
iRet=-1;

Current status

  • removed QRcode from display
  • added last URL to text interface

Would like to display iRecordableTime to the screen. Coming out as zero right now.

I checked the output of the OSC API and it looks like _recordableTime is 0. Maybe it only shows the information when the camera is recording. The results of info might be more promissing as I can at least grab the apiLevel, serialNumber, uptime, bluetoothMacAddress, wlanMacAddress.


#6

theta360.guide community!

We’ve set up a private repo for this code on GitHub. We’ve had me, Craig and another community member put some work into it. It’s come along quite a ways! If you’re interested in trying it out, maybe adding some functionality or not, please just drop me a note at jcasman@oppkey.com or DM me here (@jcasman) and I’ll get you access to the repo.

Exciting stuff!


#7

Thanks to the community contribution, I think we can access and display the full API results.

The M5Stack turns on automatically when it’s plugged into the THETA and is immediately usable.

@jcasman, you should post some pictures of community contribution builds.

Community Contribution Update: 2/14/2019

Code modified by IoT community member. Tested and photographed by @jcasman

Community Contribution Update: 2/15/2019

Sample Arduino code.

M5Stack-THETA-Debugger.zip (4.9 KB)


Information on ArduinoJson

The M5Stack sample code uses ArduinoJson to parse the response from the RICOH THETA.

There is good documentation on this library below.

I’m testing ArduinoJson Assistant to get memory pool sizes.