Hello, I am not sure what I did wrong
I made a small PCB to have a nano 33 IoT with a temp sensor (dht22) to start fan when its getting too hot. Now It seems to all work good when connected with USB but my main issue is when I connect my 12V power (to the vin). It doesnt seem to run anything. It lights up but doesnt do anything. (Only 12V, not both)
When connected to the network, I make the builtin led flash. When connected to the 12V, it turns on, maybe flash once or twice and then stays off.. again nothing happens. My dashboard doesnt update. (works fine through USB)
This is my PCB board
-DC barrel connector + goes to vin. The Vin will also power the fans
-My DHT22 is connected to 3v3 and data pin goes to D2
-I have a logic level shifter that will turn on the fan. the pin is connected to D3 and will send the GRD to the fans
-GRD from barrel connector is connected to the board GRD, Sensor GRD and also provides the GRD for fans throught the level shifter.
This is the code I have:
// WiFiNINA - Version: Latest
#include <WiFiNINA.h>
#include "thingProperties.h"
#include "DHT.h"
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define dataPin 2 // Defines pin number to which the sensor is connected
#define relayPin 3
DHT dht(dataPin, DHTTYPE);
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS; // the Wi-Fi radio's status
int ledState = LOW; //ledState used to set the LED
unsigned long previousMillisInfo = 0; //will store last time Wi-Fi information was updated
unsigned long previousMillisLED = 0; // will store the last time LED was updated
const int intervalInfo = 5000; // interval at which to update the board information
void setup() {
Serial.begin(9600);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
dht.begin();
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, LOW);
pinMode(LED_BUILTIN, OUTPUT);
// attempt to connect to Wi-Fi network:
while (status != WL_CONNECTED) {
status = WiFi.begin(ssid, pass);
delay(10000);
}
}
void loop() {
ArduinoCloud.update();
curhum = dht.readHumidity();
curtemp= dht.readTemperature();
if (isnan(curtemp)) {
delay(1000);
return;
}
unsigned long currentMillisLED = millis();
// measure the signal strength and convert it into a time interval
int intervalLED = WiFi.RSSI() * -10;
// check if the time after the last blink is bigger the interval
if (currentMillisLED - previousMillisLED >= intervalLED) {
previousMillisLED = currentMillisLED;
// if the LED is off turn it on and vice-versa
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable
digitalWrite(LED_BUILTIN, ledState);
}
IPAddress ip = WiFi.localIP();
varIP = String(ip[0]) + String(".") + String(ip[1]) + String(".") + String(ip[2]) + String(".") + String(ip[3]) ;
long rssi = WiFi.RSSI();
if (curtemp > 40){
digitalWrite(relayPin, HIGH);
fanRelay = true;
delay(2000); //Delay 2 sec.
}
else{
digitalWrite(relayPin, LOW);
fanRelay = false;
delay(2000); //Delay 2 sec.
}
}
void onFanRelayChange() {
//do something
}
I Hope someone could help me out as I am running out of ideas