Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: Entering numbers at the Serial Monitor on: April 12, 2014, 11:50:44 am
Hello Paul,
Thanks for the reply - you must be up early - it's 16:48 GMT here in UK.
I'm afraid that I'm at the stage in life where most folks prefer to do crosswords, but I'm always ready for a challenge and coping with Zigbee and Arduino plus the hardware is fairly demanding starting from zero. I'll take a look at all the things you have suggested and toInt() is a new one on me. I have to glean knowledge from wherever I can and I do make use of all the resources, but now and again you need a little guidance. I definitely WILL have a look at what reference has to say, but this is one old dog trying to learn new tricks.
Thanks again
2  Using Arduino / Programming Questions / Entering numbers at the Serial Monitor on: April 12, 2014, 10:02:04 am
Hello All,
I'm using a Uno + XBee Series 1 + LCD to mirror the reading at a gas meter - this is mainly to do with the difficulty in reading the thing where it is sited. As a real novice here, I have managed to get everything going to the point where the Hall sensor at the meter picks up each dial rotation and adds it to the LCD display in the house. To get real readings displayed, I need to input a nine digit number which is the "offset" to which the incoming pulses are added.

I was playing around with some published sketches (thank you) with the code below.

Code:
int incomingByte = 0;   // for incoming serial data
String inString = "";    // string to hold input

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
  Serial.print ("enter data at command line and check that set to NEWLINE");
  Serial.print("\n");//needs this to display "value" and "string" - if omitted, displays "string" only first time round
}

void loop() {
            // put your main code here, to run repeatedly:
             // send data only when you receive data:
            if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();
                 if (isDigit(incomingByte)) {
      // convert the incoming byte to a char
      // and add it to the string:
      inString += (char)incomingByte;
    }
                 if (incomingByte == '\n') {
      Serial.print("Value:");
      Serial.println(inString.toInt()*2);
      Serial.print("String: ");
      Serial.println(inString);
      // clear the string for new input:
      inString = "";
    }

             
        }
}

I have only changed some of the text messages and added one calculation (*2).

If I enter 999999999 (i.e.9 digits), everything is OK - if a tenth digit is added, it overflows.

Can someone tell me why it happens, and what is the significance of the "overflow" number that comes up on the Serial Monitor?

Thanks
3  Using Arduino / Displays / Re: What distance can LCD be separated from Arduino? on: December 22, 2013, 07:18:52 am
Hello everyone,
Thanks for all the replies.
I will give it a go and report back - at least no "won't works". I am still very new to all this, but enjoying the challenges. Setting up commercial programmable room thermostats and the like are always a challenge if sited 2 feet from the floor. I like to get buttons bit away from the guts of it on as long a lead as possible. Transmission speed will not be a problem with what is going to be a very slowly changing signal. I used to work with very high impedance sources (pH electrodes) where any movement of the cables caused problems. Answer - put the amplifier on the top of the electrode and the cable and length becomes a non-issue.
regards
4  Using Arduino / Displays / What distance can LCD be separated from Arduino? on: December 21, 2013, 11:24:12 am
Hello,
Does anyone have any experience of running a standard LCD module at, say, 1 metre from the Arduino? I am putting together a thermostat where the power/Arduino/relays etc will be in a power base which will be sited away from the display and any up/down/set buttons. If feasible, any recommendations for cable? twisted? shielded? ribbon? This to avoid climbing over an electrically heated water tank to see the readings or set the temperatures. Wireless?
Thanks
5  Using Arduino / Project Guidance / Re: Tide gauge and river water level sensor ideas on: July 28, 2013, 12:51:55 pm
Hello,
As an ex-industrial instrumentation technologist, I can confirm that most open tanks to depths up to 4-metres would have used ultrasonic devices. These were very expensive, but very reliable (Pepperl & Fuchs for example). Calibration is complex. I tried cheaper versions, but they are prone to wildlife like spiders taking up residence. Floats and wires and pulleys are still widely used. Have a look at heating oil tank gauges - these seem to be cheap, contactless and wireless - probably ultrasonic. Triangulation with a couple of optical sensors is possible, and the reflective type which use a reflector like a bicycle mudguard have surprisingly long ranges (20-metres or more). I am about to do something for calculating the volume of a rainwater storage tank. I will be looking at a differential pressure sensor, but the mechanical methods might be in the running. Laser distance finders are remarkably accurate, but would need some means of damping the target movement. Also might be worth looking at how cheap digital vernier calipers work - I believe this is capacitive and again it is reliable and cheap - you could look at mechanical scaling down of your range to bring it into the caliper range. I do know that the environment agencies use float methods for bomb-proof river level measurements.
Good luck
6  Topics / Home Automation and Networked Objects / Re: Arduino Thermostat Project on: November 25, 2012, 10:57:21 am
Well done - this looks really interesting and just what I am looking for. I don't really have the time or ability to develop complex code, but I'm fed up with expensive gear like Honeywell programmable thermostats breaking down and having to bin because they can't be fixed.you are definitley on the right tracks

retired environmental scientist
7  Community / Gigs and Collaborations / Commissions on: April 25, 2012, 09:04:12 am
Hello all,
Just wondering if any experts out there are interested in taking on a commission to do a bit of programming for me.
I have one or two projects in mind, but just don't get the free time to get to grips with all.
I would be interested in getting a board going with 3 or 4 temperature inputs (would like to use onewire DS1820) with a humidity input, with aview to getting a mains (240-VAC) fan running when at least one temperature drops below a set point and humidity goes above a set point. Other temperatures are just for monitoring. Long term aim might include data logging or local (LCD) or PC display.
Cheers
8  Using Arduino / Programming Questions / Re: OneWire, again on: October 04, 2011, 10:26:32 am
Hi there,
That's what I thought, but it helps us newcomers if there was a bit of a clue where to put them.
Thanks
9  Using Arduino / Programming Questions / Re: OneWire, again on: October 04, 2011, 10:14:08 am
Hello John,
Error compiling = no ref to setup or loop?
10  Using Arduino / Programming Questions / OneWire, again on: October 03, 2011, 11:40:47 am
Hello,
I am a relative newcomer to Arduino, but after Blink, decided to go for OneWire as I have some potential applications for this technology.
There are many and varied examples of OneWire code out there, including examples in Arduino 0022. My problem has been to find a published sketch that works out of the box. I downloaded the DallasTemp and Onewire libraries from sites like PJRC and milesburton, and finally got some of these to work, for one device at least. After shuffling around some of these published libraries, it was a disappointment to find that the sketches that did work, suddenly didn't, and came up with errors like "OneWire does not name a type" or similar. I am coming to the conclusion that there are several versions of DallasTemp and OneWire libraries around, and if the wrong one is in the 0022 library folder, then nothing works.
Is there a universal solution to this i.e. a set of published libraries that work with all the published sketches, or is there a way of organising the libraries so that the right sketch finds the right libraries?
I want to persevere with OneWire, but at this stage I am still reluctant to mess about with library names - I know that there is version 2 of OneWire, so if I renamed this library OneWire2.h and called it as OneWire2 from the sketch. would this work?
A typical example is the OneWire Doghouse sketch from Hacktronics, which doesn't seem to work even when using their versions of DallasTemp and OneWire libraries.
Please forgive any misspellings or naivety, and at this stage, suggestions like use LM35 are not an option as I need the analogues for something else.

Thanks
11  Using Arduino / Installation & Troubleshooting / Re: Brief digital high on start up on: September 19, 2011, 12:03:12 pm
Hello all,
Thanks for all the replies and help.
It does seem to be OK on board reset (10 out of 10 resets fine).
It is behaving impeccably at the moment so I will need to see what I have done in the meantime (guilty of throwing solutions at it). I will definitely look at the other threads and will implement external pull-ups - I suspect floating pins might have something to do with it.
"Forcing low" was simply digitalWrite (LOW) to start with.
Sorry Rozee - only spotted Radman's post after I pushed the post button.
Looking for perfection in an imperfect world.
12  Using Arduino / Installation & Troubleshooting / Brief digital high on start up on: September 17, 2011, 11:03:24 am
Hello,
Using Decimilenove and noticed that on every start up or Serial Monitor select, the digitals briefly flash high - even does it in Blink, regardless of whether the digital is selected or not (i.e. plug an LED into pin 7 instead of 13), and that flashes as well. Tried forcing outputs low, but still get it. I haven't tried measuring duration or magnitude.

I want run some mains equipment via relay eventually, so I don't want any chattering every time I look on Serial Monitor.

It might only be a ghost transient and may disappear when pin is connected to real equipment - as all real life operations are slow (seconds, not milliseconds), could the output be "slugged" with a small capacitor?

Any ideas appreciated.
13  Using Arduino / Programming Questions / Re: Digital output goes high on power up on: September 12, 2011, 01:13:21 pm
Thanks all so far.
I think I have clue what the problem might be.
The Dallas datasheet gives 85 degrees C as a special number which is the device reset output on initial power up.
I caught this number in the serial monitor, and as I have set the digital output to go high on temperatures above 25 degrees, this why it goes high initially.
Tested this by setting my digital output to go high only on temperatures above 85 degrees, and problem solved, no digital output on power up.
Just need to find a way to keep this number out for about 5 seconds.
14  Using Arduino / Programming Questions / Re: Digital output goes high on power up on: September 12, 2011, 09:11:34 am
Thanks AWOL,
I didn't write the second quoted bit of code - that was copied from Sheepdogguides who seem to have copied it from Nuelectronics.
I tried swapping the two lines to no effect. This initial digital high is annoying rather than anything else. Should this bit of code be located somewhere else?
15  Using Arduino / Programming Questions / Re: Digital output goes high on power up on: September 10, 2011, 10:15:25 am
Thanks James - a complete novice here

Here is the sketch, lifted from Sheepdog. I tried to get the OneWire example to work , but it didn't - this one does.
The only bit of code the I have added to try and stop the initial digital high is at the start commented //PGS added this.
The USB and PSU thing was a red herring and you get this initial high on both power sources.

Code:
/*ReadDS18B20
ver: 6 Jly 2010
THIS IS A FIRST DRAFT.... WORKS, but scheduled for overhaul.


Simple, simple test of reading DS18B20
connected to nuelectronics.com datalogging shield.

See...

http://sheepdogguides.com/arduino/ar3ne1tt.htm

... for explanation of this code.

Code lightly adapted from code from nuelectronics.com*/

#define TEMP_PIN  14 //See Note 1, sheepdogguides..ar3ne1tt.htm
#define LED 12//PGS added this line

void OneWireReset(int Pin);//See Note 2
void OneWireOutByte(int Pin, byte d);
byte OneWireInByte(int Pin);

void setup() {
    digitalWrite(TEMP_PIN, LOW);
    pinMode(TEMP_PIN, INPUT);      // sets the digital pin as input (logic 1)
Serial.begin(9600);
//9600 to match the data rate being used by the
//serial monitor on my system, which is set to
//the Arduino default. (Sample code published
//by nuelectronics used a faster baud rate.)
    delay(100);
    Serial.print("temperature measurement:\n");
   
    digitalWrite (LED,LOW);//PGS added this line - this was my attempt to keep it low
}



void loop(){
  pinMode(LED,OUTPUT);//added this line
 
  int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;

  OneWireReset(TEMP_PIN);
  OneWireOutByte(TEMP_PIN, 0xcc);
  OneWireOutByte(TEMP_PIN, 0x44); // perform temperature conversion, strong pullup for one sec

  OneWireReset(TEMP_PIN);
  OneWireOutByte(TEMP_PIN, 0xcc);
  OneWireOutByte(TEMP_PIN, 0xbe);

  LowByte = OneWireInByte(TEMP_PIN);
  HighByte = OneWireInByte(TEMP_PIN);
  TReading = (HighByte << 8) + LowByte;
  SignBit = TReading & 0x8000;  // test most sig bit
  if (SignBit) // negative
  {
    TReading = (TReading ^ 0xffff) + 1; // 2's comp
  }
  Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25

  Whole = Tc_100 / 100;  // separate off the whole and fractional portions
  Fract = Tc_100 % 100;
  //removed led flash from this point

//do {
 // digitalWrite(LED,HIGH);//added this line
//}
//while(Tc_100>2700); //added this line
//Serial.print("high");//added this line





//digitalWrite(LED,LOW);//ADDED THIS LINE
//delay(100);
//digitalWrite(LED,HIGH);
//delay(100);


  if (SignBit) // If its negative
  {
     Serial.print("-");
  }
  Serial.print(Whole);
  Serial.print(".");
  if (Fract < 10)
  {
     Serial.print("0");
  }

  Serial.print(Fract);
  Serial.print("   ");//added this line
  Serial.print(Tc_100);//added this line
 
  if(Tc_100>2500){
    Serial.print("   Over temperature");
    digitalWrite(LED,HIGH);
  }
  else {
    Serial.print("   Normal temperature");
    digitalWrite(LED,LOW);
  }

      Serial.print("\n");
  delay(5000);      // 5 second delay.  Adjust as necessary
}

void OneWireReset(int Pin) // reset.  Should improve to act as a presence pulse
{
     digitalWrite(Pin, LOW);
     pinMode(Pin, OUTPUT); // bring low for 500 us
     delayMicroseconds(500);
     pinMode(Pin, INPUT);
     delayMicroseconds(500);
}

void OneWireOutByte(int Pin, byte d) // output byte d (least sig bit first).
{
   byte n;

   for(n=8; n!=0; n--)
   {
      if ((d & 0x01) == 1)  // test least sig bit
      {
         digitalWrite(Pin, LOW);
         pinMode(Pin, OUTPUT);
         delayMicroseconds(5);
         pinMode(Pin, INPUT);
         delayMicroseconds(60);
      }
      else
      {
         digitalWrite(Pin, LOW);
         pinMode(Pin, OUTPUT);
         delayMicroseconds(60);
         pinMode(Pin, INPUT);
      }

      d=d>>1; // now the next bit is in the least sig bit position.
   }

}

byte OneWireInByte(int Pin) // read byte, least sig byte first
{
    byte d, n, b;

    for (n=0; n<8; n++)
    {
        digitalWrite(Pin, LOW);
        pinMode(Pin, OUTPUT);
        delayMicroseconds(5);
        pinMode(Pin, INPUT);
        delayMicroseconds(5);
        b = digitalRead(Pin);
        delayMicroseconds(50);
        d = (d >> 1) | (b<<7); // shift d to right and insert b in most sig bit position
    }
    return(d);
}

I am a very late entrant to Arduino, but can see huge potential for domestic energy control and monitoring. I would like to get a number of sensors around the house, mainly temperature, but some humidity. I used to do a lot of work with PLC's,but most of the hard work has been done with them ref code writing, so just getting an LED on is quite an achievement.
the outputs will be used to control extract fans etc.

On the PLC's I worked with, there used to be a facility to "force" an output on to test it - is there anything like that on the Arduino?
Pages: [1] 2