Salve a tutti sono Nicola, da non molto ho iniziato ad usare the Iot cloud service di arduino.
Sto facendo un progetto con Arduino per aprire e chiudere la porta/finestra della serra che ho qui a casa. Ho questo stepper motor che mi aprirebbe questo pannello scorrevole.
Riesco a far funzionare questo stepper motor in un normale ambiente, per esemprio se scarico il sample per fare un giro al motore e poi torna indietro, non c’e problema il motore funzione è collegato bene. Ma non riesco a farlo funzionare nel servizio “Arduino iot cloud”, Copiato and incollato il codice ma non funziona. Potreste per favore dare un occhiata al codice perfavore ed indicrm perchè il motore non funziona?
Grazie in anticipo.
Nicola
/*
Sketch generated by the Arduino IoT Cloud Thing "New"
https://create.arduino.cc/cloud/things/9e8192bd-2d87-42d1-86ff-6d2e0c5cfed5
Arduino IoT Cloud Properties description
The following variables are automatically generated and updated when changes are made to the Thing
bool WaterSolenoid1;
int TempInt;
float LightInt;
int TempExt;
int HumidityInt;
Properties 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"
#include <DHT.h>
#include <DHT_U.h>
#include <Stepper.h>
// DHT sensor library - Version: Latest
#define DHTPIN0 2 //dht int
#define DHTPIN1 4 // dht ext
#define WaterSolenoid1 3
int HumidityExt;
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
#define DHTTYPE DHT11
DHT dht0(DHTPIN0, DHTTYPE);
DHT dht1(DHTPIN1, DHTTYPE);
void setup() {
// Initialize serial and wait for port to open:
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
//delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
dht0.begin();
dht1.begin();
pinMode(A1,INPUT);
pinMode(WaterSolenoid1, OUTPUT);
digitalWrite(WaterSolenoid1, LOW);
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
/*
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();
Serial.begin(9600);
}
void loop() {
ArduinoCloud.update();
// Your code here
TempInt = dht0.readTemperature();
HumidityInt = dht0.readHumidity();
TempExt = dht1.readTemperature();
HumidityExt = dht1.readHumidity();
LightInt = analogRead(A1);
digitalWrite(WaterSolenoid1, HIGH);
digitalWrite(WaterSolenoid1, LOW);
Serial.print("Temp Interna: ");
Serial.print(TempInt);
Serial.print(F(" Umidity interna:"));
Serial.print(HumidityInt);
Serial.print(F(" Luce"));
Serial.print(LightInt);
Serial.print(F(" Solenoide:"));
Serial.print(WaterSolenoid1);
Serial.print(F(" Umidità esterna:"));
Serial.print(HumidityExt);
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
//delay(500);
}
void onTempIntChange() {
}
void onWaterSolenoid1Change() {
// Do something
}