LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Hx711 scale(A0, A1);// Hx711.DOUT - pin #A0
// Hx711.SCK - pin #A1
int maximumRange = 20; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, depth; // Duration used to calculate depth
float leveldifference, levelinpercentage;
Ubidots client(TOKEN);
void setup() {
client.wifiConnection(SSID,PASS);
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(10, OUTPUT);// declare pin 10 to be an output of buzzer
lcd.begin(16, 2);
}
void loop()
{
Serial.print(scale.getGram(), 1);
if(scale.getGram()>=200)
{
digitalWrite(buzzerPin, HIGH);
}
Serial.println(" g");
delay(100);
lcd.setCursor(8, 0);
lcd.print (scale.getGram(), 1);
lcd.setCursor(14,0);
lcd.print ("g");
lcd.setCursor(0,0);
lcd.print("WEIGHT:");
/* The following trigPin/echoPin cycle is used to determine the
depth of the bin using the nearest objects by bouncing soundwaves off of them. */
digitalWrite(trigPin,LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
depth = duration/58.2;//Calculate the depth (in cm) based on the speed of sound.
leveldifference =(20-depth);
levelinpercentage =(leveldifference/20)*100; //percentage used up in %
lcd.setCursor(8, 1);
lcd.print (levelinpercentage);
lcd.setCursor(14,1);
lcd.print ("%");
lcd.setCursor(0,1);
lcd.print("level :");
if (depth >= maximumRange || depth <= minimumRange){
/* Turn buzzer on to indicate "out of range" */
Serial.println("out of range");
digitalWrite(buzzerPin, HIGH);
delay(100);
}
else {
Serial.print(levelinpercentage);
Serial.println("%");
digitalWrite(buzzerPin, LOW);
}
/* Send the depth level and weight to the cloud and display on lcd, then
turn buzzer OFF to indicate successful reading. */
float value = scale.getGram();
float value2 = levelinpercentage;
client.add(ID,value);
client.add(ID2,value2);
client.sendAll();
delay(1000); //Delay 10ms before next reading.
}
just posted the code and here is the error.
out of ò
0.0 g
out of range
=>576fbfb47625425249e235cb:0.00,576fbfbb76254252e5274df5:100.00,
Response of ESP8266:
Response of ESP8266:
Response of ESP8266:
Error at CIPMODE
0.0 g
out of range
=>576fbfb47625425249e235cb:0.00,576fbfbb76254252e5274df5:100.00,576fbfb47625425249e235cb:0.00,576fbfbb76254252e5274df5:100.00,
Response of ESP8266:
now i get an error cipsend. initially i was stuck with cipmode error then edited the .cpp at AT+CIPMODE FROM “OK” to “ERROR”) !=NULL
NOW THE CIPSEND is a problem
@xmex i was trying to get the same error that you have, I found a possible explanation for that and it is the small timeout for CIPSEND, i gave just 1 second and it need wait more time to get a response. I will fix it and upload a new version.
hello everyone, i will explain how to change the baud rate inside the library, plesase follow next steps to change it, try with different values of baud rate because the ESP that you got, can have different firmware of AT commands.
Steps
**Step One:**Download the library here
**Step two:**Unzip te file of the library Step three: Open UbidotsESP8266.cpp with any text edito such as notepad, wordpad, vim, etc. Step four: Go to the line 35 and change the number (9600). There you can put 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, or 115200, it deppends of your ESP model.
Step five: Add the lib to Arduino IDE and test it.
Be careful to use ESP as a WiFi shield. Your ESP needs the default firmware that receives AT commands; if your ESP doesn’t have that firmware please follow this guide.
The AT commands firmware is the default factory firmware of ESP.