Show Posts
Pages: [1] 2 3 ... 12
1  Using Arduino / Programming Questions / Re: Changing modes question with SMlib on: July 27, 2014, 09:37:35 am
yes it is because 3 sensors has been set up, and 4 connected.
2  Using Arduino / Programming Questions / Re: Changing modes question with SMlib on: July 27, 2014, 08:08:02 am
Yes,  readings are in every 30 seconds.
Yes, those should fine as next steps ( LCD, GSM and sensors).
It is running now and will let it run for at least couple of hours.
This is nice without the delays, learning this kind is really useful.
In case there are 4 sensors attached and the code has defined as 3, than reading will up to 753ms.
3  Using Arduino / Programming Questions / Re: Changing modes question with SMlib on: July 27, 2014, 07:43:43 am
and that is fine smiley
Code:
Locating devices...Found 4 devices.
Parasite power is: OFF
Device 0  Address: 28FFB8DE15140085
Device 0 Resolution: 9

Device 1  Address: 28FFBA3B151400CE
Device 1 Resolution: 9

Device 2  Address: 28FF66CD14140062
Device 2 Resolution: 9

Requesting temperatures...DONE -- request ms 96

Temperatures are 25 Celsius, 25 Celsius, 25 Celsius

Requesting temperatures...DONE -- request ms 96

Temperatures are 25 Celsius, 25 Celsius, 25 Celsius

Requesting temperatures...DONE -- request ms 96

Temperatures are 25 Celsius, 25 Celsius, 25 Celsius

made a correction from sensorsTimeStart = millis(); to sensorsTimerStart = millis();
4  Using Arduino / Programming Questions / Re: Changing modes question with SMlib on: July 27, 2014, 07:27:34 am
I have modified my post, sorry smiley Yes it has been changed. So action was:

run original sketch -> got back the answer only for TEST,MSG  /END

after changed case from 10 to 0 -> got back several readings
5  Using Arduino / Programming Questions / Re: Changing modes question with SMlib on: July 27, 2014, 06:57:26 am
I have made a rookie's mistake, changing mode of serial monitor solved the problem, sorry!!
So it IS working! The result on serial :

Code:
Locating devices...Found 4 devices.
Parasite power is: OFF
Device 0Address: 28FFB8DE15140085
Device 0 Resolution: 9

Device 1Address: 28FFBA3B151400CE
Device 1 Resolution: 9

Device 2Address: 28FF66CD14140062
Device 2 Resolution: 9

MSG
test GSM message
/END
_
TEST
 SIGNAL QUALITY
after changing from case 10 to case 0
Code:
Locating devices...Found 4 devices.
Parasite power is: OFF
Device 0Address: 28FFB8DE15140085
Device 0 Resolution: 9

Device 1Address: 28FFBA3B151400CE
Device 1 Resolution: 9

Device 2Address: 28FF66CD14140062
Device 2 Resolution: 9

Device 3Address: 28FF69AC14140012
Device 3 Resolution: 9

Requesting temperatures...DONE -- request ms 97

Temperatures are 25 Celsius, 25 Celsius, 25 Celsius, 25 Celsius

Requesting temperatures...DONE -- request ms 96

Temperatures are 25 Celsius, 25 Celsius, 25 Celsius, 25 Celsius

Requesting temperatures...DONE -- request ms 96
6  Using Arduino / Programming Questions / Re: Changing modes question with SMlib on: July 27, 2014, 04:23:34 am
ok,

so result of the sensor reading time is 96ms.
last sketch did not found devices, but tells this:
Code:
Locating devices...Found 0 devices.
Parasite power is: OFF
Device 0Address: 28FFB8DE15140085
Device 0 Resolution: 9

Device 1Address: 28FFBA3B151400CE
Device 1 Resolution: 9

Device 2Address: 28FF66CD14140062
Device 2 Resolution: 9


the startup of the sensors library left out. So added sensors.begin(); after Serial.begin( 115200 );  and :
Code:
Locating devices...Found 4 devices.
Parasite power is: OFF
Device 0Address: 28FFB8DE15140085
Device 0 Resolution: 9

Device 1Address: 28FFBA3B151400CE
Device 1 Resolution: 9

Device 2Address: 28FF66CD14140062
Device 2 Resolution: 9

note that I am just connected 4 sensor to check..no problem...
maybe with this newline I am doing something wrong...after this, no answer ... (pressed enter, entered /n, ...)
7  Using Arduino / Programming Questions / Re: Changing modes question with SMlib on: July 25, 2014, 11:06:47 am
So first sketch : compiled successfully. After loading up and checking serial monitor, nothing can be found on the screen.
requesting temperature: I checked DS18B20 specs -> reading out is under 200ms if I'm right. And it depends maybe the lenght of the cable. Another one : SHT10 take less time. I am not a pro smiley
8  Using Arduino / Programming Questions / Re: Changing modes question with SMlib on: July 24, 2014, 02:40:08 am
So I am away from the boards, but I will back to you asap.
Serial speed: just for testing.
HW inputs: when I was trying to start and test my sim900 shield I found some information here in the forum maybe, it was one of the examples. This is working fine since months in another solution of mine with the same code.
The current hwSerialRead( ) code of yours compiled succesfully.
I will upload it and test as soon as I can!
9  Using Arduino / Programming Questions / Re: Changing modes question with SMlib on: July 23, 2014, 09:32:20 am
looks like a rebuilt of the code. thanks for helping me!
10  Using Arduino / Programming Questions / Re: Changing modes question with SMlib on: July 23, 2014, 01:41:04 am
Hi GoForSmoke,

here is the code:
Code:
//================================================LIBRARIES
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "inetGSM.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
//================================================DEFINE AND VARIABLES

// Data wire is plugged into port 3 on the Arduino
#define ONE_WIRE_BUS 3
#define TEMPERATURE_PRECISION 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// arrays to hold device addresses
DeviceAddress Thermometer1, Thermometer2, Thermometer3;
//                BS  E  D4 D5  D6 D7
LiquidCrystal lcd(7, 6, 28, 26, 24, 22);

int temp1;
int temp2;
int temp3;

InetGSM inet;
char msg[50];
char buff[100];
char senddata[64];
int numdata;
char inSerial[50];
int i=0;
boolean started=false;
const int GSMOnPIN = 9;
const int GSMresetPIN = 10;
const int ledPin =  8;

const unsigned long readsensorsinterval = 30000UL; //30 seconds
const unsigned long gsmsendinterval = 60000UL; //60 seconds

// Variable holding the timer value so far. One for each "Timer"
unsigned long readsensorstimer;
unsigned long gsmsendtimer;

//================================================SETUP

void setup()
{
  pinMode(GSMOnPIN, OUTPUT);
  pinMode(GSMresetPIN, OUTPUT);  
  pinMode(ledPin, OUTPUT);
  delay(100);

  Serial.begin(19200);
  // Start up the Sensors library
  sensors.begin();

  // locate devices on the bus
  Serial.print(F("Locating devices..."));
  Serial.print(F("Found "));
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(F(" devices."));

  // report parasite power requirements
  Serial.print(F("Parasite power is: "));
  if (sensors.isParasitePowerMode()) Serial.println(F("ON"));
  else Serial.println(F("OFF"));

  oneWire.reset_search();
  if (!oneWire.search(Thermometer1)) Serial.println(F("Unable to find address for Thermometer1"));
  if (!oneWire.search(Thermometer2)) Serial.println(F("Unable to find address for Thermometer2"));
  if (!oneWire.search(Thermometer3)) Serial.println(F("Unable to find address for Thermometer3"));
  
  // show the addresses we found on the bus
  Serial.print(F("Device 1 Address: "));
  printAddress(Thermometer1);
  Serial.println();
  Serial.print(F("Device 2 Address: "));
  printAddress(Thermometer2);
  Serial.println();
  Serial.print(F("Device 3 Address: "));
  printAddress(Thermometer3);
  Serial.println();
  

  // set the resolution to 9 bit
  sensors.setResolution(Thermometer1, TEMPERATURE_PRECISION);
  sensors.setResolution(Thermometer2, TEMPERATURE_PRECISION);
  sensors.setResolution(Thermometer3, TEMPERATURE_PRECISION);
    
  Serial.print(F("Device 1 Resolution: "));
  Serial.print(sensors.getResolution(Thermometer1), DEC);
  Serial.println();
  Serial.print(F("Device 2 Resolution: "));
  Serial.print(sensors.getResolution(Thermometer2), DEC);
  Serial.println();
  Serial.print(F("Device 3 Resolution: "));
  Serial.print(sensors.getResolution(Thermometer3), DEC);
  Serial.println();
  
  readsensorstimer = millis ();
  gsmsendtimer = millis ();
 }
//================================================FUNCTIONS
void serialhwread(){
  i=0;
  if (Serial.available() > 0){            
    while (Serial.available() > 0) {
      inSerial[i]=(Serial.read());
      delay(10);
      i++;      
    }

    inSerial[i]='\0';
    if(!strcmp(inSerial,"/END")){
      Serial.println("_");
      inSerial[0]=0x1a;
      inSerial[1]='\0';
      gsm.SimpleWriteln(inSerial);
    }
    //Send a saved AT command using serial port.
    if(!strcmp(inSerial,"TEST")){
      Serial.println(F("SIGNAL QUALITY"));
      gsm.SimpleWriteln("AT+CSQ");
    }
    //Read last message saved.
    if(!strcmp(inSerial,"MSG")){
      Serial.println(msg);
    }
    else{
      Serial.println(inSerial);
      gsm.SimpleWriteln(inSerial);
    }    
    inSerial[0]='\0';
  }
}

void serialswread(){
  gsm.SimpleRead();
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print(F("0"));
    Serial.print(deviceAddress[i], HEX);
  }
}
// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print(F("Temp C: "));
  Serial.print(tempC);
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print(F("Resolution: "));
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();    
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print(F("Device Address: "));
  printAddress(deviceAddress);
  Serial.print(F(" "));
  printTemperature(deviceAddress);
  Serial.println();
}  

// read sensors
void readsensorstolcd(){
  //READ TEMPERATURE
  Serial.print(F("Requesting temperatures..."));
  sensors.requestTemperatures();
  Serial.println(F("DONE"));

  Serial.print(F("Temperatures are "));
  Serial.print(sensors.getTempC(Thermometer1));
  Serial.print(F(" Celsius, "));
  Serial.print(sensors.getTempC(Thermometer2));
  Serial.print(F(" Celsius, "));
  Serial.print(sensors.getTempC(Thermometer3));
  Serial.print(F(" Celsius, "));
  Serial.print(F("\n\r"));
  delay(100);
  temp1=(sensors.getTempC(Thermometer1));
  temp2=(sensors.getTempC(Thermometer2));
  temp3=(sensors.getTempC(Thermometer3));
  delay(100);
    
  readsensorstimer = millis ();
  
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("T1:   C");
  lcd.setCursor(0, 1);
  lcd.print("T2:   C");
  lcd.setCursor(0, 2);
  lcd.print("T3:   C");
    lcd.setCursor(3, 0);
  lcd.print(temp1);
  lcd.setCursor(3, 1);
  lcd.print(temp2);
  lcd.setCursor(3, 2);
  lcd.print(temp3);
  lcd.setCursor(3, 3);
  delay(200);
}

//GSM start,send ,stop
void gsmandsend(){

  digitalWrite(GSMOnPIN, LOW);    
  delay(3000);      
  Serial.println(F("GSM Shield starting..."));
  digitalWrite(GSMOnPIN, HIGH);   // sets the GSM on
  delay(800);                
  Serial.println(F("Its now Started"));
  digitalWrite(GSMOnPIN, LOW);
  delay(5000);

  if (gsm.begin(4800)){
    Serial.println(F("\nstatus=READY"));
    started=true;  
  }
  else Serial.println(F("\nstatus=IDLE"));
  if(started){
    if (inet.attachGPRS("***********************", "", ""))
      Serial.println(F("status=ATTACHED"));
    else Serial.println(F("status=ERROR attaching APN"));
    delay(1000);
    if (inet.connectedClient())
      digitalWrite(ledPin, HIGH);
    else
      digitalWrite(ledPin, LOW);


    //Read IP address.
    gsm.SimpleWriteln("AT+CIFSR");
    delay(5000);
    //Read until serial buffer is empty.
    gsm.WhileSimpleRead();

    // Sending data

    sprintf(senddata,"/update?key=***************************",temp1,temp2,temp3);
    delay(500);
    numdata=inet.httpPOST("*************************", 80, senddata, buff, msg, 50);

    //Print the results.
    Serial.println(F("\nNumber data received:"));
    Serial.println(numdata);  
    Serial.println(F("\nData received:"));
    Serial.println(msg);  
  }
  serialhwread();

  //Read for new byte on NewSoftSerial.
  serialswread();
  delay(800);    
  digitalWrite(GSMOnPIN, LOW);    
  delay(3000);      
  Serial.println(F("GSM Shield stopping..."));
  digitalWrite(GSMOnPIN, HIGH);   // sets the GSM off
  delay(800);                
  Serial.println(F("Its now Stopped"));
  digitalWrite(GSMOnPIN, LOW);
  gsmsendtimer = millis ();
  delay(5000);
}

//================================================LOOP

void loop()
{
  if ( ( millis() - readsensorstimer ) >= readsensorsinterval )
  {
    readsensorstolcd();
    readsensorstimer += readsensorsinterval; }

  if (( millis() - gsmsendtimer ) >= gsmsendinterval )
  {
    gsmandsend();
    gsmsendtimer += gsmsendinterval;
  }
}

This is for testing purposes, it will be extended with more sensors.  So it is now reading sensors in every 30 seconds, and sending data in every 60 seconds (what can be found in temp variables at that time will be send, thinking if it is the right way, or should I read sensors again before sending the data in gsmandsend() ).
So main goal is to read sensor values and send to lcd, and in other hand send the sensor values with gsm.
1. If I would like to have 'independent' routines for showing data on LCD and for sending data, I should put sensor readings too to gsmandsend() routing. Is it correct?

2. I would like to have a pushbutton to set modes for sensor readings and drive relays for example (push1 - mode1: switch relay with X temp1 sensor value ; push2-mode2: switch relay with Y temp1 value ; push3-mode1;push4-mode2 and so on) . Beside the values have to send with gsmandsend()

3. After further tests (and learning smiley ) I would like to have lcd and button to set the temp1 values for example  (but this is not important at this point.

Thanks for any help!

11  Using Arduino / Programming Questions / Changing modes question with SMlib on: July 22, 2014, 01:43:46 am
Hi,
I am currently using my loop as below (reading sensors and sending data with gsm):
Code:
void loop()
{
  if ( ( millis() - readsensorstimer ) >= readsensorsinterval )
  {
    readsensorstolcd();
    readsensorstimer += readsensorsinterval;
  }                                                                           

  if (( millis() - gsmsendtimer ) >= gsmsendinterval )
  {
    gsmandsend();
    gsmsendtimer += gsmsendinterval;
  }
}

I would like to have states with a pushbutton / or can be a switch button too, like:

- when button pushed/switched - use readsensorstolcd(); than gsmandsend(); (this should be mode1)
- when button pushed/switched again - use readsensorstolcd2(); than gsmandsend(); (this should be mode2) //here readsensorstolcd2(); would be new with different values

Maybe SMlib example 2 can be a starting point?
Your help would be appreciated, thanks!
12  Using Arduino / Sensors / Re: Temp, Humidity CO2 sensor and library. on: July 09, 2014, 01:03:41 am
aaah thanks! I am testing on pins 11-12. works also perfect smiley
13  Using Arduino / Sensors / Re: Temp, Humidity CO2 sensor and library. on: July 08, 2014, 08:26:30 am
Happy to hear that!!! Great!
Note: if you are using MEGA 2560 board, and you are using ICSP pins ( for example wiznet shield ), than do not use 50 - 51 pins, because ICSP using in this case 50-51-52 pins. So in case try using other pins from the availables( for example 11-12).
Usually pin10 is wiznet, pin4 is sd, pin13 is onboard led on mega...
Anyway I do not know what and where is 62, 63, 64, 65, 66, 67, 68, 69  ...  smiley-confuse
14  Using Arduino / Sensors / Re: Temp, Humidity CO2 sensor and library. on: July 07, 2014, 04:29:26 pm
Dear All,

I have found the solution to use this sensor with mega 2560!
As Softwareserial notes:
"Note:
 Not all pins on the Mega and Mega 2560 support change interrupts,
 so only the following can be used for RX:
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69"

So let's connect the RX pin of the sensor to mega pin 51, and TX pin of the sensor to mega pin 50 and use DirtGambit's sketch with modification:

Code:
SoftwareSerial nss(50,51); // TX and RX pins

And smile when you realise this is working fine after calibration!
15  Using Arduino / Sensors / Re: Temp, Humidity CO2 sensor and library. on: July 07, 2014, 04:03:56 pm
Hi,
I have tried DirtGambit's library, tried all the possibilities ( 5v, pins, and so on ) what can be found here, but the same problem:
Code:
Celcius : 0.00
Fahrenheit : 32.00
Humidity : 0.00
CO2 : 0
Digital Filter : 0
I am trying this with Mega board...

Maybe there is a problem with the sofwareserial...? When using sim900 shield, there was a hwserial lib instead of the swserial...
Do you have any idea?
It would be great to make it work on mega...
Pages: [1] 2 3 ... 12