Nano 33 IoT WiFi

I’m trying to use a Nano 33 IoT for an MQTT project. While I’m connected to my laptop the WiFi works fine but when I disconnect and plug into a power adapter it won’t connect to my WiFi network. I’m using the wifiNinna library. Any help would be greatly appreciated. Thank you.

Hi!

It would be interesting if you share the specs of your power adapter and how exactly you´re connecting it to your 33 IoT.

do you have while (!Serial); in setup()?

With the MKR Wifi 1010 it is sometimes the same problem. But open the Arduino app and then the serial monitor. You will then always be shown something whether the device connects or not. If, I don't know right now, your device has a reset button, you can try pressing that too while connected to the battery (or similar).
Note, however, that the device does not connect to the WiFi immediately - it may also take a minute or two.

Also, it would help if we could see the code, because then we could check it for errors as well.
I hope I could help,

cloudDev

I’ve tried a couple of different adapters, even the one from my MacBook Pro. I would think that it’s out more power than the usb port on my laptop.

Possibly, but any power source from 5V-12V (except computer USB) must be conected to the Vin pin.

Also consider the other tips gave in previous answers.

Hi, I have the same issue with twi if my arduino nano 33 iot, both sometimes Not all the time get online by being connected to my laptop using the USB port, but whenever I need to connect it to an adapter (5 volts output) I cant get any of my devices online. I have tried connecting in school, in my house, in my friends house and nothing.

This is our sketch, it may have issues becaus we have not been able to make any test because we are never online. Please help we have a due date on school very soon, we dont know what to do.

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/bc343efd-d578-418c-b510-b9967bbdaffa 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float value_volt;
  int distancia;
  bool flujo;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#define ECHOPIN 4
#define TRIGPIN 5

const float VelSon = 34000.0;
int valvula = 2;
volatile int NumPulsos; //variable para la cantidad de pulsos recibidos
int PinHall = 3;    //Sensor conectado en el pin 3
float factor_conversion = 7.5; //para convertir de frecuencia a caudal
const int sensorPin = A4;
int sensorValue;

//---Función que se ejecuta en interrupción---------------
void ContarPulsos ()
{
  NumPulsos++;  //incrementamos la variable de pulsos
}

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial);
  pinMode (LED_BUILTIN, OUTPUT);
  
  
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();
  pinMode(ECHOPIN, INPUT);
  pinMode(TRIGPIN, OUTPUT);
  pinMode(valvula, OUTPUT);
  pinMode(PinHall, INPUT);
  attachInterrupt(0, ContarPulsos, RISING); //(Interrupcion 0(Pin8),funcion,Flanco de subida)


  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
    iniciarTrigger();
  // La función pulseIn obtiene el tiempo que tarda en cambiar entre estados, en este caso a HIGH
  unsigned long tiempo = pulseIn(ECHOPIN, HIGH);
  
  // Obtenemos la distancia en cm, hay que convertir el tiempo en segudos ya que está en microsegundos
  // por eso se multiplica por 0.000001
  distancia = tiempo * 0.000001 * VelSon / 2.0;
  
  sensorValue = analogRead(sensorPin);
  value_volt = fmap(sensorValue, 0, 1023, 0.0, 5.0);
  
  if (value_volt < 5.0) {
    flujo = true;
  } else {
    flujo = false;
  }

  if (flujo && distancia > 25) {
    digitalWrite(valvula, HIGH);
  } else {
    if (distancia <= 25 || !flujo) {
      digitalWrite(valvula, LOW);
    }
  }
}

// Método que inicia la secuencia del Trigger para comenzar a medir
  void iniciarTrigger()
  {
    // Ponemos el Triiger en estado bajo y esperamos 2 ms
    digitalWrite(TRIGPIN, LOW);
    delayMicroseconds(2);
    // Ponemos el pin Trigger a estado alto y esperamos 10 ms
    digitalWrite(TRIGPIN, HIGH);
    delayMicroseconds(10);
    // Comenzamos poniendo el pin Trigger en estado bajo
    digitalWrite(TRIGPIN, LOW);
  }
  
  float fmap(float x, float in_min, float in_max, float out_min, float out_max){
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
  }


/*
  Since Flujo is READ_WRITE variable, onFlujoChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onFlujoChange()  {
  // Add your code here to act upon Flujo change
}

/*
  Since ValueVolt is READ_WRITE variable, onValueVoltChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onValueVoltChange()  {
  // Add your code here to act upon ValueVolt change
}

/*
  Since Distancia is READ_WRITE variable, onDistanciaChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onDistanciaChange()  {
  // Add your code here to act upon Distancia change
}

Remove the following line from the sketch. The while loop waits forever for a USB data connection. This will never happen unless it is connected to a PC usb port.

while (!Serial);
1 Like

@yoshyqm if you have thee same problem, read what where the suggestions in replays

just a wrong message. it didn't fail. the status is checked in a while loop.
and your code is for an esp8266 or esp32, not for Nano 33 IoT. on Nano IoT the begin is blocking. the status will not change after it finished.

Sorry, thanks for correcting. Understand now. I deleted the post.

Why??

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.