0
παιδια λιγο την βοηθεια σας διοτι εχω απογοητευτει...οταν τρεχω αυτον τον κωδικα απο τον υπολογιστη μου συνδεδεμενο με καλωδιο με το arduino ολες οι τιμες τυπωνονται κανονικα στο μυνημα που μου ερχεται...'#include "DHT.h"
#include "HX711.h"
#include <OneWire.h>
#include <LowPower.h>
#include <SoftwareSerial.h>
#define SigQ_Len 30
SoftwareSerial mySerial(7, ; // RX, TX
int incoming_byte_counter = 0;
int i = 0;
char temp;
char SigQ[SigQ_Len
[I]= {0};
float therm;
float maza;
float humid;
int send_times =1;
// ************** hx711
// HX711.DOUT - pin #A4
// HX711.PD_SCK - pin #A3
HX711 scale(A2, A3); // parameter "gain" is ommited; the default value 128 is used by the library
void setuphx711() {
// Start up the library
// zero factor from SparkFun_HX711_Calibration by sarahalmutlaq
//long zero_factor = scale.read_average(); //Get a baseline reading
long zero_factor = 150000;
scale.set_scale(19.44); // this value is obtained by calibrating the scale with known weights; see the README for details
//scale.tare(); // reset the scale to 0
scale.set_offset(zero_factor); //Zero out the scale using a previously known zero_factor for a permanent weight on the scale
}
void readhx711(){
Serial.println("*********** HX711 *********");
//Serial.print("one reading:\t");
//Serial.print(scale.get_units(), 1); //not needed anymore
maza= scale.get_units(10), 1;
Serial.print(" maza in void :\t");
Serial.println(maza);
Serial.print("\t| average in void readhx711:\t");
Serial.println(scale.get_units(10), 1);
// print the average of 10 readings from the ADC minus tare weight divided by the SCALE parameter
scale.power_down(); // put the ADC in sleep mode
delay(1000);
}
// ************** DHT11
#define DHTPIN 6 // what pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
void setupdht11() {
dht.begin();
}
void readdht11() {
Serial.println("*********** DHT11 *********");
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
humid=h;
therm=t;
Serial.print("Humin void is ");
Serial.print(humid);
Serial.print(" %\t");
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
}
void readSignal(){
mySerial.println("AT+CSQ");
delay(500);
while(mySerial.available()!=0 && incoming_byte_counter < (SigQ_Len-2))
{
temp=mySerial.read();
Serial.write(temp);
if((temp >= '0' && temp <= '9') || (temp == '.') || (temp == ',')) {
SigQ[i++] = temp;
SigQ= 0x00;
}
incoming_byte_counter++;
}
SigQ[SigQ_Len-1]= 0x00; /* Secure is NULL terminated */
}
//Main Code
int wait=1;
void setup(void)
mySerial.begin(115200); // Setting the baud rate of GSM Module
Serial.begin(115200); // Setting the baud rate of Serial Monitor (Arduino)
delay(500);
setuphx711();
delay(500);
setupdht11();
delay(500);
}
void loop(void) {
while(send_times==1){
// do the while only 1 time when send_times=1
Serial.print(" wait = ");
Serial.println(wait);
if(wait>=3){
scale.power_up();
delay(500);
readhx711();
Serial.print("maza in main is ");
Serial.println(maza);
delay(500);
readdht11();
Serial.print("humid in main is ");
Serial.println(humid);
Serial.print("temp is ");
Serial.println(therm);
readSignal();
delay(500);
Serial.print("signal = ");
Serial.print(SigQ);
sendMessage();
//-----------------------------
wait=1;
send_times++;
}
delay(1000);//delay
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
wait++;
delay(500);
}
delay(10000);
}
void sendMessage(){
Serial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
Serial.println("AT+CMGS="+306983xxxx"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("AT+CMGF=1");
delay(1000);
mySerial.println("AT+CMGS="+306983xxxx"\r"); // Replace x with mobile number
delay(1000);
mySerial.print("zigizei ");// The SMS text you want to send
mySerial.print(maza);
mySerial.print(" grammaria ");
mySerial.print(", hum=");
mySerial.print(humid );
mySerial.print(" % ");
mySerial.print(" ,temp=");
mySerial.print(therm);
mySerial.print(" Signal=");
mySerial.print(SigQ);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
mySerial.println();// Give module time to send SMS
delay(5000);
Serial.println("\nto minima stalthike!\n");
delay(2000);
mySerial.println("AT+CMGD=4");//Delete all messages including unread messages
delay(1000);
Serial.println("AT+CMGD=4");//Delete all messages including unread messages
Serial.println("ALL MESSAGE DELETED");
}.
οταν ομως δινω ρευμα στο συστημα μεσω χρονοδιακοπτη απο μπαταρια τοτε τυπωνονται ολες οι τιμες στο μυνημα εκτος απο το σημα του gsm....δηλαδη στην τιμη signal = (εδω δεν παιρνει τιμη ειναι κενο)....τι μπορει να φταιει???οποιος μπορει ας βοηθησει..ευχαριστω