Arduino Sensor 1.3 Beta 2

I have now posted a beta2 that should be more stable (at least during my tests) and generate less trash-messages.

I also had some serious problems using setPALevel(RF24_PA_MAX) on my gateway that has an amplified antenna version of NRF24L01. So the new SerialGateway (=ArduinoGateway) has a bit lower radio power by default… but you can change it back in sketch if you want.

Need some brave people to test it. The git-repo has been moved to github (Arduino-project) and can now be found here:

Note that this new beta requires you to update both gateway and sensors code due to new ack-mechanism and increased radio-transfer speeds. You can leave the Vera Plugin if you want.

Thanks Hek - ill try it out tonight!

I will give it a shot tomorrow.

I’ll try it tonight and let you know Hek. Thanks!

OK, This is what I’ve got so far:

  1. Upgraded Gateway code…After remembering to uncomment the LED code…My LED’s started working :slight_smile:

  2. Upgraded 3 Dallas sensors (3.3V Pro Minis) - No Problem all worked well

  3. Uploaded 1 sensor (3.3V Pro Mini) with both a Dallas and BMP085 Pressure board…I use this in my attic (Dallas to measure outside and the BP085 to measure the attic temp. This worked well with beta 1.2 but did not work once it sent to 1.3

    a) I Cleared the EEPROM and loaded just the Dallas sketch (Worked OK)
    b) Again Cleared the EEPROM and loaded just the BMP085 (Worked OK)
    c) Again Cleared the EEPROM and loaded my Dallas and BMP085 code and again it won’t work:

I get a constant loop of the following:

Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 4
Relalaying messagStarted sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 4

I’ll work on it tomorrow to see what I’ve got to change.

Question Hek… Do you want to bump the Library Version? It still says “1.2+”… Will probably make it easier to keep track of which sensors have been upgraded

[quote=“MDoc, post:5, topic:179310”] c) Again Cleared the EEPROM and loaded my Dallas and BMP085 code and again it won’t work:

I get a constant loop of the following:

Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 4
Relalaying messagStarted sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 4[/quote]

Looks like the Arduino crashes at startup. Please post your code.

Found the problem.

I had left the default “MAX_ATTACHED_DS18B20” to 16. Since I’m only using 1 sensor, I changed it to 1 and it resolved the problem. Do the new Libraries use more RAM or declare more Stack Space perhaps?

 #define MAX_ATTACHED_DS18B20 1
 float lastTemperature[MAX_ATTACHED_DS18B20];

All sensors are now working under 1.3

Ok good, but memory should not be that tight… I have changed the sketch and added MAX_ATTACHED_DS18B20 to for-loops in case your getDeviceCount reports a large number (will overwrite buffer today).

#include <Sleep_n0m1.h>
#include <SPI.h>
#include <EEPROM.h>  
#include <DallasTemperature.h>
#include <OneWire.h>
#include <RF24.h>
#include <Sensor.h>  

// Set RADIO_ID to something unique in your sensor network (1-254)
// or set to AUTO if you want gw to assign a RADIO_ID for you.
#define RADIO_ID AUTO

#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 

unsigned long SLEEP_TIME = 30; // Sleep time between reads (in seconds)

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

Sensor gw(9, 10);
Sleep sleep;

#define MAX_ATTACHED_DS18B20 16

float lastTemperature[MAX_ATTACHED_DS18B20];
int numSensors=0;
boolean metric = true; 

void setup()  
{ 
  Serial.begin(BAUD_RATE);  // Used to type in characters
  sensors.begin();
  gw.begin(RADIO_ID);

  // Fetch the number of attached sensors  
  numSensors = sensors.getDeviceCount();
  // Register all sensors to gw (they will be created as child devices)
  for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
     gw.sendSensorPresentation(i, S_TEMP);
  }
  metric = gw.isMetricSystem();
}



 
void loop()     
{     
  sensors.requestTemperatures(); // Fetch temperatures from Dallas
  delay(100);
  for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
    // Fetch and round temperature to one decimal
    float temperature = static_cast<float>(static_cast<int>((metric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
    // Only send data if temperature has changed and no error
    if (lastTemperature[i] != temperature && temperature != -127.00) {
      gw.powerUp(); // Powerup introduces a small delay (which is missing in radio.write powerup)
      // Send variable (using registered shortcut) to gw
      gw.sendVariable(i, V_TEMP, temperature, 1);
      lastTemperature[i]=temperature;
    }
  }
  // Power down the radio.  Note that the radio will get powered back up
  // on the next write() call.
  delay(500);
  gw.powerDown();
  sleep.pwrDownMode(); //set sleep mode
  sleep.sleepDelay(SLEEP_TIME * 1000); //sleep for: sleepTime 
}

Anyone else having problem? Will bump version to 1.3 when more people reports good result.

An EthernetGateway-version will also soon be available f?r (just need to connect/verify that all is ok) .

Could you already inform us what hardware the EthernetGateway-version will support so that one can order it in advance?

I hope it will support both WizNet and ENC28J60. A-lurker made a contribution of Ethernet-code and had it running for WizNET.

After reduction of library ENC28J60 code (had to remove DHCP = only static ip supported) and removal of string-class in gateway it looks like this (when DEBUG is disabled):

Sketch uses 29,846 bytes (97%) of program storage space. Maximum is 30,720 bytes.
Global variables use 1,663 bytes (81%) of dynamic memory, leaving 385 bytes for local variables. Maximum is 2,048 bytes.
Low memory available, stability problems may occur

WizNET (default Ethernet library) looks better (but module is a bit more expensive):

Sketch uses 24,456 bytes (79%) of program storage space. Maximum is 30,720 bytes. Global variables use 1,047 bytes (51%) of dynamic memory, leaving 1,001 bytes for local variables. Maximum is 2,048 bytes.

I only have an ENC28J60 here at home to verify. As I said… this has not been done yet… and might fail when I startup for the more memory intensive ENC28J60.

Sounds great Hek!
I have a EtherTen Arduino compatible with onboard Ethernet | Freetronics i can test with. Its Wiznet i believe…

Im interested because occasionally my Vera loses the serial port on reboot - i think due to USB hub…so hopefully this will bring stability there!

G

Hi Hek,

I’m having issues with motionsensor example.
If i load the same sketch , but using the old Vera libraries it works fine…
Im wondering if its similar to the issue you had with the radio power…Ill see if i can work out how to change this and report.

Relaying message back to gateway.
Tx: fr=7,to=0,la=7,ne=0,ci=0,mt=1,ty=16,cr=211: 0
Send failed.
1
Relaying message back to gateway.
Tx: fr=7,to=0,la=7,ne=0,ci=0,mt=1,ty=16,cr=180: 1
Send failed.
0
Relaying message back to gateway.
Tx: fr=7,to=0,la=7,ne=0,ci=0,mt=1,ty=16,cr=211: 0
Send failed.
Open ping reading pipe: 7
Tx: fr=7,to=255,la=7,ne=255,ci=255,mt=4,ty=9,cr=17: 
Sent successfully
No relay nodes was found. Trying again in 10 seconds.
Tx: fr=7,to=255,la=7,ne=255,ci=255,mt=4,ty=9,cr=17: 
Sent successfully
No relay nodes was found. Trying again in 10 seconds.
Tx: fr=7,to=255,la=7,ne=255,ci=255,mt=4,ty=9,cr=17: 
Sent successfully
No relay nodes was found. Trying again in 10 seconds

Hi Hek,

I install the new version yesteday and everything worked fine for me until this morning.
It seems like gateway is not responing any more.

I’ll try to restart it and se what happens.

Best regards
Jesper

[quote=“gregl, post:12, topic:179310”]I’m having issues with motionsensor example.
If i load the same sketch , but using the old Vera libraries it works fine…
Im wondering if its similar to the issue you had with the radio power…Ill see if i can work out how to change this and report.[/quote]

I’ve been running my relay sketch for 3 days straight now (and a modified motion+temp sketch) .
You can adjust power by setting PA level after begin. Please report any findings.

gw.begin(AUTO);
gw.setPALevel(RF24_PA_HIGH);  //Adjust PA-level: MIN, LOW, HIGH, MAX   (MAX can sometimes cause problems when using amplified NRF24L01)

Thanks Hek, I’ll try later tonight. I looked at the library late last night, but didnt make any changes. So I’ll give this a go and report back.

Sent from my Nexus 5 using Tapatalk

[quote=“hek, post:8, topic:179310”]Anyone else having problem? Will bump version to 1.3 when more people reports good result.
An EthernetGateway-version will also soon be available f?r (just need to connect/verify that all is ok) .[/quote]

Thanks hek! I look forward to testing the Ethernet Gateway. I’ve got a ENC28J60 module just waiting if we go that route.

I updated my libraries to the new ones, but kept my original sketches. All appears to still be working.

I did update the sketch on the gateway to the current one along with libraries.

Should I be updating my sketches as well?
I have two sensors built that include the motion and DHT Sensor
One Distance Sensor
and one Arduino that I modified to look at 6 reed switches on my wired door sensors on the house.

[quote=“waynehead99, post:17, topic:179310”]I updated my libraries to the new ones, but kept my original sketches. All appears to still be working.

I did update the sketch on the gateway to the current one along with libraries.

Should I be updating my sketches as well?
I have two sensors built that include the motion and DHT Sensor
One Distance Sensor
and one Arduino that I modified to look at 6 reed switches on my wired door sensors on the house.[/quote]

Very strange that it still works… the transfer speed of your old sketches and updated gateway differs now… I thought nothing would get through… Are you sure the gateway was updated with code from the new location at github?

OK i think i found my stupidity…
I think when i updated my serialgateway, i still have the \libraries\vera directory in place.

I have just deleted and re-updated the serial gateway and my motion/button/relay sketch came to life…

Wayne - think you may have same issue…

Everything has been working great for a few days now. I have a single relay mini pro, a 4 relay with temp and LCD screen nano , 2 servos on mini pros. I have been using the internal pull-up resistors for the button inputs for a while now too. I also just used my old sketches since they looked identical to the new except for changes I made. I deleted the old libraries and copied the new from github then updated each arduino. Until I updated them with the new libraries they were unresponsive. For the data rate would you need to include this command in the gateway

gw.begin(); gw.setPALevel(RF24_PA_HIGH); //Adjust PA-level: MIN, LOW, HIGH, MAX (MAX can sometimes cause problems when using amplified NRF24L01) gw.setDataRate(RF24_2MBPS); // Would you need this line?
I tried it and sensors still work. Not sure how to determine what data rates they are really using.