This article is a memorandum when I tried running Android Things on Raspberry Pi3 Model B. I am running in an environment where Android Studio 2.2 or higher and ADB commands can be used.
Download the latest image from the Official Page and unzip it. Since it is about 4GB, it will take some time to deploy. Connect the MicroSD card to your PC using a card reader or the like. It seems that it may not be recognized by the slot attached to the notebook PC etc. In that case, please purchase a card reader. Follow the steps here (https://www.raspberrypi.org/documentation/installation/installing-images/windows.md) to install Win32DiskImager and write the image.
Assemble the circuit while looking at the image in the README of sample-button. However, since the Assistant sample does not move at this rate, change the LED wire (blue line in the image) to BCM25 (11th from the upper right) and change the switch wire (green line in the image) to BCM23 (from the upper right). Please change to 8th).
Attach the SD card, HDMI cable, LAN cable, USB microphone, and speaker to the Raspberry Pi. Check the switch and LED circuits again and turn on the power.
If the Android Things startup screen appears, it is successful.
Since the IP address is displayed on the screen, try connecting from a PC on the same network.
Start a command prompt and enter the following code.
> adb connect [IP address]
When a message such as Success appears, the connection is complete.
I will also set up WiFi here. It's an IoT device, so you want to connect wirelessly anyway.
With adb connect successful at the command prompt
> adb shell am startservice -n com.google.wifisetup/.WifiSetupService -a WifiSetupService.Connect -e ssid <Network_SSID> -e passphrase <Network_Passcode>
To check the connection, use the following command.
> adb shell logcat -d | grep Wifi
There are various things, but if the following result is displayed, it is successful.
V WifiWatcher: Network state changed to CONNECTED V WifiWatcher: SSID changed: ... I WifiConfigurator: Successfully connected to ...
Clone the following repositories from Github. https://github.com/androidthings/sample-googleassistant Next, set the Google Console according to the ReadMe.
https://developers.google.com/assistant/sdk/prototype/getting-started-other-platforms/config-dev-project-and-account Follow this page to set up the Google API.
client_secret_ <client-id> .json
.To use Assistant, allow activities from the following https://myaccount.google.com/activitycontrols Turn on the following items
--Web and app activity --Location history --Terminal information --Voice activity
https://github.com/GoogleCloudPlatform/google-auth-library-python-oauthlib
Install google-auth-oauthlib using pip (python's package management system). (If you don't have Python installed, install it here. Either 2 or 3 is OK)
Start a command prompt and enter the following command
> pip install google-auth-oauthlib
Start Android Studio and open the project in the directory where you cloned Google Assistant.
Also, at this timing, change one line of source code on Android Studio.
Set the variable on line 61 of app> java> AssistantActivity.java to false.
private static final boolean AUDIO_USE_I2S_VOICEHAT_IF_AVAILABLE = false;
After making changes, save the file.
Make the working directory of the command prompt a cloned directory of Google Assistant and enter the following command. For client_secret_NNNN.json
, specify the file saved in 5 of Creating Google API Console Project.
google-oauthlib-tool --client-secrets client_secret_NNNN.json --credentials app/src/main/res/raw/credentials.json --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save
The browser will start automatically and the authentication screen will appear, so select Allow. It's okay to close the page when the screen changes.
Then enter the following command.
> gradlew assembleDebug
> adb install -g app/build/outputs/apk/app-debug.apk
It should succeed if the Raspberry Pi 3 is connected. If it fails, check the connection with ʻadb connect [IP address]`.
Finally, run (▶) in Android Studio. The app will be placed and launched. After waiting for a while, press the switch and try talking in English. If you get a response, you are successful. Thank you for your hard work.
I briefly wrote down what I did from scratch to moving the sample. Android Things has little Japanese information, but I think it is an attractive service, such as Google's API can be used on IoT terminals. Assistant's response is quick. In the next step, we will actually create an app. Thank you for reading this far.
Recommended Posts