Show Posts
Pages: [1] 2
1  Using Arduino / Sensors / measuring pressure in liquids on: May 21, 2013, 10:56:23 am
I like to measure and log the pressure in waterpipes at my home. The maximum pressure is 5 bar.
I'am looking for suggestions for an affordable solution for witch sensor i can build in the circuit.

Secundo : I need also a flowmeter that I can use under 6 bar and 10000 l/hr.

Thanks for suggestions!
2  Topics / Home Automation and Networked Objects / Energy logging on: May 06, 2013, 02:33:19 pm
Since 6 months, I am logging temperature in/out and electricity
I use an arduino uno to collect the data from temperature and CT-sensors and also from a wireless connection I made around an atmega328.
The data are send trough a network shield to the internet where I use php to put the data in a mysql database.
With the data from the database I can make the reports I want.

So far so good, but ... i am desperate about the gas and the water. I don't find a way to read the meters electronically.
The gasmeter has no reflecting part in one of the digits.
I tried on both meters the get a signal with a sensitive hall sensor, but no succes. Also tried to read a number-wheel with a IR emittor-receiver but I cannot get a clear pattern from it.
Here I ask for help : are there suggestions to be able to read those meters? Is there a possibility to read the strips at a number-wheel with a fine beam emittor en a receiver?
By the way : my provider won't change to other meters in the near future.
3  Using Arduino / Networking, Protocols, and Devices / Re: arduino ethernet speed problem on: November 05, 2012, 02:14:54 pm
or I can multiply the value with 100 (curr1 = int(curr1*100)) and post it
then serverside divide by 100 again (in php).
This is maybe the easiest way.
4  Using Arduino / Networking, Protocols, and Devices / Re: arduino ethernet speed problem on: November 05, 2012, 01:55:40 pm
This is de calculation I used in previous project. numberOfSamples was 3000.
Now I will take less samples to avoid too many slow down the program.

Code:
for (int n=0; n<numberOfSamples; n++)
{
   //Used for offset removal
   lastSampleI=sampleI;
   //Read in voltage and current samples.   
   sampleI = analogRead(inPinI);
   //Used for offset removal
   lastFilteredI = filteredI;
   //Digital high pass filters to remove 2.5V DC offset.
   filteredI = 0.996*(lastFilteredI+sampleI-lastSampleI);
   //Root-mean-square method current
   //1) square current values
   sqI = filteredI * filteredI;
   //2) sum
   sumI += sqI; 
}

//Calculation of the root of the mean of the voltage and current squared (rms)
//Calibration coeficients applied.
Irms = ICAL*sqrt(sumI / numberOfSamples)-Ioffset;
if (Irms < 0.08) Irms = Irms/2.65; // correction at low current
5  Using Arduino / Networking, Protocols, and Devices / Re: arduino ethernet speed problem on: November 05, 2012, 01:13:20 pm
yes, you're right.
I forgot to tell that I perform some calculation before posting.
I need a number of samples because it is AC, those measures have to be calculated to the right value.
6  Using Arduino / Networking, Protocols, and Devices / Re: arduino ethernet speed problem on: November 05, 2012, 01:01:10 pm
to be complete: the value comes from a sensor at an analog port.
I will read it out and put the value in curr1.

More sensors are following (temperatures and currents).
7  Using Arduino / Networking, Protocols, and Devices / Re: arduino ethernet speed problem on: November 05, 2012, 12:48:04 pm
I will store the value in a variable, by example "curr1" and then replace 128 with curr1 in sprintf.
8  Using Arduino / Networking, Protocols, and Devices / Re: arduino ethernet speed problem on: November 05, 2012, 12:39:48 pm
Thank you SurferTim.
I tried to change the sprintf function, but it doesn't work (current is 0 and not 128).
What should be the right syntax, and can I use variables in place of values (128 in example hereunder)?
Current should be a float-variable (I expect also values like 32.12).
Code:
sprintf(pageAdd,"/vul.php?current=%f",128);
9  Using Arduino / Networking, Protocols, and Devices / Re: arduino ethernet speed problem on: November 05, 2012, 05:26:39 am
I tried this code from SurferTim.
I cannot use IPAddress server(46,30,211,56); because this is the IP of my provider (one.com).
So I have no private IP address.
I think I have to use my domain name (www.mysite.com).
What do I have to change in the code to perform that change?
Code:
/*
   Web client sketch for IDE v1.0.1 and w5100/w5200
   Posted October 2012 by SurferTim
*/

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0x92, 0xA2, 0xEF, 0x0D, 0x24, 0xAD };
IPAddress ip(192,168,1,153);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);

//IPAddress server(74,125,227,16); // Google
IPAddress server(46,30,211,56); // my provider

EthernetClient client;
int totalCount = 0;
int loopCount = 0;
char pageAdd[32];

void setup() {
  Serial.begin(9600);

  // disable SD SPI
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  delay(2000);
  Serial.println("Ready");
}

void loop()
{
  if(loopCount < 16)
  {
    // if loopCount is less than 30, just delay a second
    delay(1000);
  }
  else
  {
    // every thirty seconds this runs
    loopCount = 0;

    // Modify next line to load different page
    // or pass values to server
    sprintf(pageAdd,"/",totalCount);
   
   
    if(!getPage(server,pageAdd)) Serial.print("Fail ");
    else Serial.print("Pass ");
    totalCount++;
    Serial.println(totalCount,DEC);
  }   

  loopCount++;
}

byte getPage(IPAddress ipBuf,char *page)

{

  int inChar;
  char outBuf[128];

  Serial.print("connecting...");

  if(client.connect(ipBuf,80))
  {
    Serial.println("connected");

    sprintf(outBuf,"GET %s HTTP/1.0\r\n\r\n",page);
    client.write(outBuf);
  }
  else
  {
    Serial.println("failed");
    return 0;
  }

  // connectLoop controls the hardware fail timeout
  int connectLoop = 0;

  while(client.connected())
  {
    while(client.available())
    {
      inChar = client.read();
      Serial.write(inChar);
      // set connectLoop to zero if a packet arrives
      connectLoop = 0;
    }

    connectLoop++;

    // if more than 10000 milliseconds since the last packet
    if(connectLoop > 10000)
    {
      // then close the connection from this end.
      Serial.println();
      Serial.println("Timeout");
      client.stop();
    }
    // this is a delay for the connectLoop timing
    delay(1);
  }

  Serial.println();

  Serial.println("disconnecting.");
  // close client end
  client.stop();

  return 1;
}
10  Using Arduino / Networking, Protocols, and Devices / Re: arduino ethernet speed problem on: November 04, 2012, 08:52:10 am
Thanks!
This code is working but too slow for me. I must keep the interval between two intervals at 4000ms, to keep it going.
It is only for 2 temperatures, but the project will be expanded.
Code:
#include <DallasTemperature.h>
#include <OneWire.h>
#include <SPI.h>
#include <Ethernet.h>
// Data wire temp sensor is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
DeviceAddress temp1 = { 0x28, 0xD2, 0x56, 0xF3, 0x03, 0x00, 0x00, 0xA0 };
DeviceAddress temp2 = { 0x28, 0xE1, 0x76, 0xF3, 0x03, 0x00, 0x00, 0xEC };
// assign a MAC address for the ethernet controller.
 // fill in your address here:
 byte mac[] = { 0xEF, 0x12, 0xDA, 0xAB, 0x17, 0x24};
 // fill in an available IP address on your network here,
 // for manual configuration:

 IPAddress server(78,22,214,56); //IP of mysite
 
// initialize the library instance:
 EthernetClient client;
 
unsigned long lastConnectionTime = 10;          // last time you connected to the server, in milliseconds
 boolean lastConnected = false;                 // state of the connection last time through the main loop
 const unsigned long postingInterval = 40*1000;  // delay between updates, in milliseconds
 
void setup() {
   // start serial port:
   Serial.begin(9600);
   //instellen temperatuursensors
 sensors.begin();
 sensors.setResolution(temp1, 10);
 sensors.setResolution(temp2, 10);
   // give the ethernet module time to boot up:
   delay(1000);
   // start the Ethernet connection:
   if (Ethernet.begin(mac) == 0) {
     Serial.println("Failed to configure Ethernet using DHCP");
   // no point in carrying on, so do nothing forevermore:
     for(;;)
       ;
   }
   // print the Ethernet board/shield's IP address:
   Serial.print("My IP address: ");
   Serial.println(Ethernet.localIP());
 }
 
void loop() {
 
   // if there's incoming data from the net connection.
   // send it out the serial port.  This is for debugging
   // purposes only:
   if (client.available()) {
     char c = client.read();
     Serial.print(c);
   }
   // if there's no net connection, but there was one last time
   // through the loop, then stop the client:
   if (!client.connected() && lastConnected) {
     Serial.println();
     Serial.println("disconnecting.");
     client.stop();     
   }
 
  // if you're not connected, and ten seconds have passed since
   // your last connection, then connect again and send data:
   if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
     httpRequest();     
   }
   // store the state of the connection for next time through
   // the loop:
   lastConnected = client.connected();   
 }
 
// this method makes a HTTP connection to the server:
 void httpRequest() {
   // temperaturen lezen

 sensors.requestTemperatures();
 float temp11 = sensors.getTempC(temp1);
 float temp12 = sensors.getTempC(temp2);

 delay(1000);
   // if there's a successful connection:
   if (client.connect(server, 80)) {
     Serial.println("connecting...");
     client.print("GET http://www.mysite.be/fillDB.php?t1=");
     //fillDB.php = code to put the values in database
     client.print(temp11);
     client.print("&t2=");
     client.print(temp12);
     client.println(" HTTP/1.0");
     client.println();
 Serial.print(temp11);
 Serial.print(" ");
 Serial.println(temp12);
    // note the time that the connection was made:
     lastConnectionTime = millis();
     
   }
  else {
     // if you couldn't make a connection:
     Serial.println("connection failed");
     Serial.println("disconnecting.");
     client.stop();
   }
 }
11  Using Arduino / Networking, Protocols, and Devices / arduino ethernet speed problem on: November 04, 2012, 08:25:14 am
I want to post the analog values to my website every second to let them show up in real time.
With php-code I do some stuff with it to store data in a database.

I think the arduino is not fast enough to perform a http-post every second.
Somebody knows a way to get around that?

For the moment I only reach a frequence of data-post every 4 seconds.
12  Using Arduino / Project Guidance / Re: streaming live data and fill mysql database on: November 04, 2012, 03:39:09 am
OK, that makes sense.

Now I use this code to send the data.
I cannot make it faster bij decrementing the interval between 2 posts, otherwise the program stucks.
Is there a better way to send the data?

Code:
#include <DallasTemperature.h>
#include <OneWire.h>
#include <SPI.h>
#include <Ethernet.h>
// Data wire temp sensor is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
DeviceAddress temp1 = { 0x28, 0xD2, 0x56, 0xF3, 0x03, 0x00, 0x00, 0xA0 };
DeviceAddress temp2 = { 0x28, 0xE1, 0x76, 0xF3, 0x03, 0x00, 0x00, 0xEC };
// assign a MAC address for the ethernet controller.
 // fill in your address here:
 byte mac[] = { 0xEF, 0x12, 0xDA, 0xAB, 0x17, 0x24};
 // fill in an available IP address on your network here,
 // for manual configuration:

 IPAddress server(78,22,214,56); //IP of mysite
 
// initialize the library instance:
 EthernetClient client;
 
unsigned long lastConnectionTime = 10;          // last time you connected to the server, in milliseconds
 boolean lastConnected = false;                 // state of the connection last time through the main loop
 const unsigned long postingInterval = 20*1000;  // delay between updates, in milliseconds
 
void setup() {
   // start serial port:
   Serial.begin(9600);
   //instellen temperatuursensors
 sensors.begin();
 sensors.setResolution(temp1, 10);
 sensors.setResolution(temp2, 10);
   // give the ethernet module time to boot up:
   delay(1000);
   // start the Ethernet connection:
   if (Ethernet.begin(mac) == 0) {
     Serial.println("Failed to configure Ethernet using DHCP");
   // no point in carrying on, so do nothing forevermore:
     for(;;)
       ;
   }
   // print the Ethernet board/shield's IP address:
   Serial.print("My IP address: ");
   Serial.println(Ethernet.localIP());
 }
 
void loop() {
  
   // if there's incoming data from the net connection.
   // send it out the serial port.  This is for debugging
   // purposes only:
   if (client.available()) {
     char c = client.read();
     Serial.print(c);
   }
   // if there's no net connection, but there was one last time
   // through the loop, then stop the client:
   if (!client.connected() && lastConnected) {
     Serial.println();
     Serial.println("disconnecting.");
     client.stop();    
   }
 
  // if you're not connected, and ten seconds have passed since
   // your last connection, then connect again and send data:
   if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {
     httpRequest();    
   }
   // store the state of the connection for next time through
   // the loop:
   lastConnected = client.connected();  
 }
 
// this method makes a HTTP connection to the server:
 void httpRequest() {
   // temperaturen lezen

 sensors.requestTemperatures();
 float temp11 = sensors.getTempC(temp1);
 float temp12 = sensors.getTempC(temp2);

 delay(1000);
   // if there's a successful connection:
   if (client.connect(server, 80)) {
     Serial.println("connecting...");
     client.print("GET http://www.mysite.be/fillDB.php?t1=");
     //fillDB.php = code to put the values in database
     client.print(temp11);
     client.print("&t2=");
     client.print(temp12);
     client.println(" HTTP/1.0");
     client.println();
 Serial.print(temp11);
 Serial.print(" ");
 Serial.println(temp12);
    // note the time that the connection was made:
     lastConnectionTime = millis();
    
   }
  else {
     // if you couldn't make a connection:
     Serial.println("connection failed");
     Serial.println("disconnecting.");
     client.stop();
   }
 }


Moderator edit: [code] [/code] tags added.
13  Using Arduino / Project Guidance / Re: streaming live data and fill mysql database on: November 03, 2012, 01:35:32 pm
for the good understanding: I want to stream the output every second to a webpage, but only every 20 seconds perform a storage in the database to analyse it afterwards.
14  Using Arduino / Project Guidance / streaming live data and fill mysql database on: November 03, 2012, 12:23:25 pm
Since 2 months I have an ethernet Arduino running that fills a mysql database with data from the analog ports.
That runs without any issue.
Data - analog in - ethernet (with client.print("GET http://www.... etc).
That way I can take the data with php on my website and put it in in the database. I take a sample every 20 seconds.

However, next to that I want to stream the data to a website (by example every second) to show them live on screen (on the internet).

What is the best way to put that together? Pushing the data every second in the database is no option; that is too many.
15  Using Arduino / Microcontrollers / Re: programming ATMEGA328 on: October 26, 2012, 06:01:54 am
I am a bit novice in this.
Therefore, I like to program it with the arduino IDE because I am familiar with it.
Can I use the solutions given by Nick Gammon and fungus for this?
So yes, is there somewhere a toturial available?
I already have an arduino UNO but now I want to build a project with the atmega328.

thanks!
Pages: [1] 2