Getting started with Google Assistant

I've searched quite a bit, and can't seem to find something definitive on this.

I'd like to control my new Nano 33 IOT with my Google home speaker, and vice versa. But I can't seem to find the ideal way to go about starting a simple test like turning on and off the onboard LED.

Some tutorials say to use Adafruit IO some Blynk, but done mention the Arduino IOT cloud? And it also seems none of the tutorials are there for the Nano IOT, which means I ended up running into the wrong library suggestions, etc.

Anyone that can point me in the right direction?

Thanks for any suggestions!

I've never touched Google assistant, but that seems to be the place to start. It looks like you need to configure the layout of your house and what devices you have where. Makes sense, but a fair bit of initial work unless you already have that in place.

You could easily blink an LED with Blynk, but I don't see how that would hook up with GA.

Thanks for the response. I got the home stuff all sorted, that works fine. I can even get my assistant to talk to Adafruit IO. But that's where I got stuck.

Partially also because the tutorials were all for other boards, and the link between the back and Adafruit IO didn't seem to work. I then started wondering if Adafruit is even the smartest way to go...

It sounds like you have done the heavy lifting already. I would have thought that connecting the Nano to Adafruit would be the easier part. What happens?

I get the error below:

(Line 22, where you try to connect to adafruit) error: ‘AdafruitIO_WiFi’ does not name a type; did you mean ‘AdafruitIO_Time’?

And from what I can find online, it has to do with the library being for the wrong chipset?

Here’s my code:

// Adafruit IO Arduino - Version: Latest 
#include <AdafruitIO.h>
#include <AdafruitIO_MQTT.h>
#include <AdafruitIO_WiFi.h>


#include <ArduinoHttpClient.h>

/************************ Adafruit IO Configuration *******************************/

// visit io.adafruit.com if you need to create an account,
// or if you need your Adafruit IO key.
#define IO_USERNAME    "...."
#define IO_KEY         "...."

/******************************* WIFI Configuration **************************************/

#define WIFI_SSID       "...."
#define WIFI_PASS       "...."

AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);

/************************ Main Program Starts Here *******************************/

#define LED_PIN 0

// button state
int current = 0;
int last = 0;

// set up the 'command' feed
AdafruitIO_Feed *command = io.feed("lights");

void setup() {

  // set button pin as an input
  pinMode(LED_PIN, OUTPUT);

  // start the serial connection
  Serial.begin(115200);

  // connect to io.adafruit.com
  Serial.print("Connecting to Adafruit IO");
  io.connect();
  
  // set up a message handler for the 'command' feed.
  // the handleMessage function (defined below)
  // will be called whenever a message is
  // received from adafruit io.
  command->onMessage(handleMessage);

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  // we are connected
  Serial.println();
  Serial.println(io.statusText());

}

void loop() {

  // io.run(); is required for all sketches.
  // it should always be present at the top of your loop
  // function. it keeps the client connected to
  // io.adafruit.com, and processes any incoming data.
  io.run();


}

// this function is called whenever a 'command' message
// is received from Adafruit IO. it was attached to
// the command feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {

  int command = data->toInt();

  if (command == 1){ //light up the LED
    Serial.print("received <- ");
    Serial.println(command);
     digitalWrite(LED_PIN, HIGH);     
  } else {
    Serial.print("received <- ");
    Serial.println(command);
    digitalWrite(LED_PIN, LOW);
  }
}

I see. It looks like an error from AdafruitIO_WiFi.h - it has options for selecting the appropriate Wifi library and it’s saying that none of the ones it knows are defined. I faked it out with this:

// Adafruit IO Arduino - Version: Latest
#include <AdafruitIO.h>
#include <AdafruitIO_MQTT.h>
#define ARDUINO_ARCH_ESP32 1
#include <AdafruitIO_WiFi.h>

But I then fell foul of later problems with missing ESP libraries. I don’t really know which wifi library Adafruit supports is appropriate for Nano 33(if any). Might be worth a few minutes testing (I don’t have the hardware) but I rather suspect it won’t work.

The Nano 33 docs say it works with Arduino IOT cloud. If GA supports it I’d be inclined to try that instead of Adafruit, much as I like them.

Thanks for the response. I don't mind using Arduino IOT cloud (I have no IOT experience, I'll use whatever service works best with the nano). But I do understand that I need to use IFTTT for the connection, and I can't find Arduino IOT in there. I'll do some googling on Arduino IOT and GA.

On reflection, I think I'd take the easy way out and put the nano 33 aside for another project (just like my 33 BLE). Since you've got Adafruit IO working, just get some hardware that's already acknowledged to be working with it.

Haha, interesting idea too. I only have one Arduino device though, this is the first. I'd have to buy another one, simply for this project.

I'm wondering where it's going wrong though, I somehow think it must be something small. Maybe I'm not experienced enough with devices like these, but once there's a wifi connection, how you "connect" to the IOT service shouldn't be different on different devices right?

It appears to me that the Adafruit library is able to work with a number of different varieties of WiFi hardware and the problem is that none of the types it knows are present. I faked it out with the code fragment above. What happens if you try that?

I suspect though that the Nano you have wasn't known when the Adafruit library was last revised, so as is, it probably won't work.

It occurs to me though that there must be an equivalent wifi library for the Nano 33, so it might be enough to edit the Adafruit header so that it uses that one.

wildbill:
I faked it out with the code fragment above. What happens if you try that?

In file included from /home/builder/opt/libraries/latest/adafruit_io_arduino_3_6_3/src/AdafruitIO_WiFi.h:36:0,

from /tmp/244092499/sketch_jun16c/sketch_jun16c.ino:8:

/home/builder/opt/libraries/latest/adafruit_io_arduino_3_6_3/src/wifi/AdafruitIO_ESP32.h:24:10: fatal error: WiFiClientSecure.h: No such file or directory

By the way, using the web developer for the Arduino.

Yup, I got the same thing. It's solvable, but it doesn't look trivial.

You might see if you can get a plain MQTT example going. It might be plausible to forgo the Adafruit libraries and just hit their service. I haven't read enough of their docs to see whether that's the gateway into the IO service you hooked up with GA.

Another alternative: apparently you can use Blynk from IFTTT. Since you're already using the latter, perhaps that's a solution that avoids having to hack libraries.

I suggest you try to get a simple Blynk app working standalone first to prove to yourself that the Nano 33 can do it.

wildbill:
You might see if you can get a plain MQTT example going. It might be plausible to forgo the Adafruit libraries and just hit their service.

That already is starting to sound non-trivial to an Arduino newbie like myself. I liked the simplicity of the Arduino IOT Cloud service (watched a few tutorials), and I'd like to use as few ecosystems as possible for this, so maybe that would eventually be the way to do, not using Adafruit IO.

Your suggestion of looking at Blynk is a good idea, I'll go through one of those tutorials later and see if I can get that going.

I must say I'm a bit surprised at the complication on this project, but I guess it's the various different boards and chips that's making it harder. Which Arduino board would you suggest for a beginner in case it's better for me to get started with one that has more support? I'll be doing very simple stuff (single sensor, simple LED or message via an online service).

The trouble is that the hardware you have is fairly new. What you want to do will be much easier when (if) the Adafruit library catches up.

Since you have already got the data to Adafruit IO, I would look at the list of their hardware that is supported by that system and buy the cheapest one they have in stock. Personally, I would prefer to get one with the header pins soldered on for me.