/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/5cbc04df-d5fd-4188-a730-0d86f3adf5ea
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float realTimeStorage;
float storageLevel;
bool actuatorStatus;
bool truckDetection;
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"
#include "Adafruit_VL53L0X.h"
// Alarm
const int buzzer = 14; //D5
// truck detection
const int trigPin = 15; //D8
const int echoPin = 13; //D7
// display status
const int redLight = 2; //D4
const int greenLight = 0; //D3
// relay control actuator
const int relay1 = 16; //D0
const int relay2 = 12; //D6
// defines variables
long duration;
float distance;
double lvl;
double realLvl;
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
void setup() {
pinMode(buzzer, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(redLight, OUTPUT);
pinMode(greenLight, OUTPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
// Initialize serial and wait for port to open:
Serial.begin(115200);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// wait until serial port opens for native USB devices
while (! Serial) {
delay(1);
}
// Serial.println("Adafruit VL53L0X test");
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
// power
Serial.println(F("Chute is ready\n"));
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection, false);
/*
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();
digitalWrite(redLight, LOW);
digitalWrite(greenLight, LOW);
truckDetection = false;
actuatorStatus = false;
// keep the motor off by keeping both HIGH
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
delay(2000);
}
void loop() {
ArduinoCloud.update();
VL53L0X_RangingMeasurementData_t measure;
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!
delay(100);
Serial.println(measure.RangeMilliMeter);
lvl = 100 - (100 * (measure.RangeMilliMeter))/206;
storageLevel = constrain(lvl,0.0,100);
realLvl = 1000 * lvl/80;
realTimeStorage = constrain(realLvl,0.0,1000);
if (storageLevel > 30)
{
digitalWrite(trigPin, LOW); // Clears the trigPin
delayMicroseconds(2);
digitalWrite(trigPin, HIGH); // Sets the trigPin on HIGH state for 10 microseconds
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
distance = duration * 0.034 / 2; // Calculating the distance
if (distance > 7) {
truckDetection = false;
truckOff();
}
if (distance < 7 && distance > 3) {
truckDetection = true;
actuatorStatus = true;
ArduinoCloud.update();
truckOn();
}
}
else{
digitalWrite(redLight, HIGH);
digitalWrite(greenLight, LOW);
turnOFF();
truckDetection = false;
actuatorStatus = false;
}
}
void truckOn() {
// Truck detected
delay(2000);
digitalWrite(redLight, HIGH);
digitalWrite(greenLight, LOW);
loadingProcess();
}
void truckOff() {
noTone;
turnOFF();
digitalWrite(redLight, LOW);
digitalWrite(greenLight, HIGH);
}
void loadingProcess(){
actuatorPull();
delay(3650);
actuatorPush();
ArduinoCloud.update();
delay(3650);
tone(buzzer, 1000, 3000);
delay(5000);
}
/*
* pushes the actuator
*/
void actuatorPush()
{
digitalWrite(relay1, LOW);// turn relay 1 ON
digitalWrite(relay2, HIGH);// turn relay 2 OFF
}//actuatorPush()
/*
* pull the actuator
*/
void actuatorPull()
{
digitalWrite(relay1, HIGH);// turn relay 1 OFF
digitalWrite(relay2, LOW);// turn relay 2 ON
}//actuatorPull()
/*
* turnOFF the actuator
*/
void turnOFF()
{
digitalWrite(relay1, HIGH);// turn relay 1 OFF
digitalWrite(relay2, HIGH);// turn relay 2 OFF
}//turnOFF()
My code is working properly last February, but when I reopened it again, there is historical data that can be seen but does not show on the dashboard.
Click the following link to open the list of your Arduino Cloud Things in the web browser: https://app.arduino.cc/things
Click the name of the Thing.
The "Setup" page for the Thing will open.
Select the "Sketch" tab at the top of the page.
The "Sketch" page for the Thing will open.
Make sure the serial port of the Arduino board is selected on the sketch editor toolbar. ⓘ Some Devices produce an "Over-the-Air" port and a serial port. In this case, there will be a menu on the toolbar that allows you to select either one. The serial port must be used for this procedure.
Click the icon that looks like a magnifying glass ("Open Serial Monitor") on the sketch editor toolbar.
A new browser window will open.
Make sure the correct port is shown on the toolbar in the window.
Select "115200 baud" from the menu at the bottom of the window.
Press and release the reset button on the Arduino board.
You should now see information about the progress of the Thing initialization printed in the window.
If the board is able to connect to your Wi-Fi access point, you should see a message like this:
Connected to "some-ssid"
After that, if the board is able to connect through the Internet to the Arduino Cloud servers, you should see this message:
Connected to Arduino IoT Cloud
Was the Thing initialization successful as I described?
I'm not sure I understood correctly what you mean by "nothing showed up on the desktop site". Please add a forum reply here that provides a more detailed description to help us to understand it.
Please provide the full and exact text of what "showed up" in the mobile app.
I'm not sure I understood correctly what you mean by "live update". Please add a forum reply here that provides a more detailed description to help us to understand it.
You will be much more likely to get effective assistance here if you make a stronger effort to communicate. Keep in mind that I can't see your computer or mobile device and I'm not psychic. The only information I have to work with is the information you provide here on the forum. I want to help, but if I don't have a good understanding of what is happening in your system then there is not much hope I will be able to accomplish that.
This is the desktop site dashboard Understand?
The thing 'showed up' is the scatter dots on the graph.
The values not showing in the graph but the data is recorded when I download the historical data.
And also the widgets like led, on off status, and percentage are not functioning as well
unfortunately, there was an issue with the Arduino systems, as reported by @ptillisch, which caused problems with the Things properties and the Dashboards. The issue has been solved now and everything should work as expected.
Hello,
I have an IoT Home Lights circuit. If I turn on a lamp in the dashboard, I also receive a notification in my messenger on the dashboard. Unfortunately, things keep going wrong for me.
I no longer receive any messages in my messenger.
No text will appear here, no matter what I turn on or off.
Every now and then several messages appear in succession in the messanger and my lights go on or off. Strange cloud behavior.
What's going on in the cloud?
Does the problem still occur if you try it again now?
As mentioned above, there was a bug in the Arduino Cloud system around the time you made your post. That bug has since been fixed so if the problems you describe were related to the bug then we would expect that they won't occur now. If the problem is still occurring then it likely has a different origin, which we can try to investigate.
Things works fine now. But I have an issue connecting the device to the connection. I cannot to my phone hotspot, but I have changed the connection to 2.4GHz. For others devices, the console monitor show is connected then after few seconds the connection will terminated.
BUt works fine when connecting to home 2.4GHz wifi. So what is the issue? Am I require to buy a air router to connect the device>