@Boots33 I have change to an arduino nano but still get some strange values. I'm going to make some changes over this project and see again what ill get.
Thanks for all the help.
@Boots33 I have change to an arduino nano but still get some strange values. I'm going to make some changes over this project and see again what ill get.
Thanks for all the help.
@zboblamont I have already read that pdf there they say this:
"The design of the Magnetic Transmission reduces the number of components
Operating in the water, increasing the reliability of the meter."
They also say this in the pdf:
"Any of these models can be supplied ready to receive the
Pulse transmission (see tele-count catalog). Ex .: MSV 1520t"
In this last information i made a search for MSV 1520t were i found again another pdf that talks about my water meter.
Here's the link: http://resopre.pt/conteudo.php?fam=CONTADORES,CONT_DOMESTICOS&pag=AGUA_RESOPRE.PT&detail=693
You can see 5 water meters on that link all off them say's Magnetic Transmission "Transmissão magnética" but has you can see none off them look like mine. Has i can understand mine is the more basic off them all i do belive that i have the first generation off this water meters.
I have done one last test yesterday leaving a water tap open and passed the hall sensor all over the water meter from side to side and top to bottom and never got any impulse digital led light turning on.
The led did turned on when i put my finger in the top off the sensor or in cables near the pins of the sensor.
@bart59 and @mfalkvidd Thanks for all the help. Today i toke the sensor to the water meter and for my luck my water meter is too old 1997 and no mater the position i put the hall sensor it just doesn't get any pulse at all at this time i really don't now what to use to get the data from my water meter...
I have already tried also the TCRT5000 and also does not work. Here's an image from my water meter
The TCRT5000 when i put over the glass the green led stays always on but when i remove it from the glass and point it to the black part of my meter the green led goes off the sensor is working ok but the glass from my meter does not help at all.
Any sugestions off other sensors i can try or use ?
I think i have fix my problem. I have been playing with the code and the sensor and notice that the power led and data led on the sensor were always on no mater the digital pin i was trying to use.
This also happened with the analog pin A0.
In one last attempt i decided to use the digital pin 3 with the resistor soldered on the board for sensors like dallas and dht11 or dht22.
Now the first thing i had noticed was the data led was not on and now it only comes on when i passe a magnet under my sensor... it does not count any pulsecount if i passe the magnet over the sensor only under it.
Counted the times i had passed the magnet under the sensor and my gateway received te exact number 30 times = 0.030 volume and now the volume is stop at this number no more ghost encrease numbers.
Tomorrow morning i'm going to mount the sensor over the water meter to see if this finaly works.
The only problem i'm getting now is some NACK over the transmissions... like this:
6604747 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=3,st=OK:30
volume:0.030
604794 !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=NACK:0.030
pulsecount:30
634781 !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=1,st=NACK:30
volume:0.030
634828 !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=2,st=NACK:0.030
Ok here's the photo off my sensor. On my code i'm using the digital pin2 since digital pin3 has a resistor for Dallas and dht sensors but i'm not using them at this time. This arduino is only for water meter.
@bart59 Yes i'm using the 3,3v from the arduino and i always connect everything with the arduino power off. Give me mor 5 minutes and i'll upload a photo from my sensor going to bring it inside home.
@mfalkvidd i think i don't have anything magnetic on the place were i'm putting the arduino and the sensor at this time.
Thanks for the replays.
New update.... have change the arduino mini pro for another one flash a new code a new sensor and again i'm getting volume data when the sensor is not near the water meter. I dont understand what's happening.
@bart59 Thanks have done like you said and did clean the data from the gateway.
All day until 1h ago i had left my arduino connected on my pc and i did like mfalkvidd said connecting the digital pin 2 to gnd and my arduino did not send any strange value to the gateway always seend volume 0.00 this was perfect.
Now that i'm at home i had connect my arduino to the sensor 3.3v gnd and digital pin2 and in the first log there it was value increase on volume when my sensor was in front off me...
I have a arduino nano pro 3.3v on easy pcb board and i'm using the hall sensor i dont see why i'm getting this problem...
I have a WiFi AP inside home and my sensor is outside.
Even the water flow says i have a 2.00 L/min when the sensor is not near the water meter.
@mfalkvidd Thanks. Have now connected the digital pin2 to gnd and in the last 1h the values are always 0.000 going to leave it this way until night since now i'm at work. I would like to find out what was creating the spurious interrupts??
Other thing that ill find out tonight is when i connect the sensor to the arduino will it create rong data or will it only send real data only when the water meter starts running water...
One more thing today at 8:00 when i did the pin2 to gnd the first "boot" over domoticz i got this value as you can see on the image below. Is this normal? Have been trying to deleted but it wont go away.
Once again thanks for your help.
Have been working with the code and have found one strange thing. When my sensor sends data to the gateway "domoticz" the gateway sends a value to the sensor. The strange thing is that my arduino does not have any sensor connected and sow the data send is zero but my gateway sends akways a positive value and increases this value every time it sends data to the arduino.
Even if i go to the arduino code and set the volume and pulseCount to 0 flash it to the arduino, load the value of zero to the gateway and then e flash the same code but this time i remove the volume and pulseCount to 0 the first time the arduino sends data to the gateway it always receive a value insted of zero since i dont have the hall sensor connected to the arduino.
I'm using a arduino mini pro 3.3v on a easy pcb by soundberg81 and i have setup the digital pin2 to connect the hall sensor.
Here's some log from my arduino:
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
3 TSM:INIT
4 TSF:WUR:MS=0
11 TSM:INIT:TSP OK
13 TSF:SID:OK,ID=1
14 TSM:FPAR
51 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
1032 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
1037 TSF:MSG:FPAR OK,ID=0,D=1
2058 TSM:FPAR:OK
2059 TSM:ID
2060 TSM:ID:OK
2062 TSM:UPL
2065 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2172 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2178 TSF:MSG:PONG RECV,HP=1
2181 TSM:UPL:OK
2182 TSM:READY:ID=1,PAR=0,DIS=1
2187 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2320 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2327 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
2335 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
3517 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
3526 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=11,sg=0,ft=0,st=OK:Water Meter
3535 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=5,sg=0,ft=0,st=OK:2.4.B
3544 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=21,pt=0,l=11,sg=0,ft=0,st=OK:Hall Sensor
3551 MCO:REG:REQ
3589 !TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=NACK:2
5596 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2
5665 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
5670 MCO:PIM:NODE REG=1
5673 MCO:BGN:STP
5677 TSF:MSG:SEND,1-1-0-0,s=1,c=2,t=25,pt=0,l=0,sg=0,ft=0,st=OK:
5683 MCO:BGN:INIT OK,TSP=1
6484 TSF:MSG:READ,0-0-1,s=1,c=2,t=25,pt=0,l=1,sg=0:0
Received last pulse count from gw:2
pulsecount:2
35686 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:2
volume:0.003
35694 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.003
l/min:2.05
65687 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.05
pulsecount:4
65695 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:4
volume:0.004
65704 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.004
l/min:0.00
95688 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:5
95696 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:5
volume:0.005
95706 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.005
pulsecount:5
125689 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:5
volume:0.006
125698 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.006
l/min:2.00
155691 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.00
pulsecount:7
155699 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:7
volume:0.007
155708 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.007
l/min:0.00
185691 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:8
185699 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:8
volume:0.008
185708 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.008
pulsecount:8
215696 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:8
volume:0.009
215707 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.009
l/min:2.00
245693 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.00
pulsecount:10
245701 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:10
volume:0.010
245710 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.010
l/min:0.00
275694 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:11
275702 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:11
volume:0.011
275714 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.011
pulsecount:11
305695 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:11
volume:0.012
305703 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.012
l/min:2.00
335698 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:2.00
pulsecount:13
335707 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=OK:13
volume:0.013
335718 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=0,st=OK:0.013
l/min:0.00
365732 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=OK:0.00
pulsecount:14
365776 !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=25,pt=5,l=4,sg=0,ft=0,st=NACK:14
volume:0.014
365788 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=35,pt=7,l=5,sg=0,ft=1,st=OK:0.014
376929 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
376934 TSF:MSG:BC
377041 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
l/min:5.36
395735 !TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=34,pt=7,l=5,sg=0,ft=0,st=NACK:5.36
pulsecount:16
Again since i'm geting this problem i don't have my sensor connected to the arduino.
@mfalkvidd Yes i did but has you can see even when the hall sensor is not connected the arduino sends data and the water increases in the the gateway. I can work on the SEND_FREQUENCY and see if it fix this problem.
Thnaks for the replay
Hi. i'm having a strange problem using a arduino nano connecting a hall sensor to read my water meter. My water meter is dated from 1996 and i can't use the TCRT5000 sensor so i'm trying my luck with the hall sensor. My problem is that my arduino is always sending data.... even if i have the water turned off the most strange thing is that even when the arduino is not connected to the hall sensor it send's data. How can i fix this problem ?
@Boots33 I'm going to change the arduino mini for an arduino nano to have the 5V still have one in the house.
Acs712 have already buy 2 off them just in case if i have to go back to arduino mini.
I was thinking on booting all my outside arduinos from this solar panel i have 2 more off them that i can connect.
Hi. sorry for my late replay....
Here's the way i'm powering things up.
I don't have a solar charge since last summer we had a big fire on my island and all my arduino and sensors that were outside were all damage from the fire and hot temperatures. So to fiz this problem i'm using the LM2596 to reduce the 12V from the solar panels to 5.5V so that the lipo charger can work. Above the 5v this charger will get damage.
Some data from this charger:
LED: Red = Charging, Green = Complete
Input Voltage: 4.5 to 5.5V
Battery Max Charge Voltage: 4.2V - charges a 1S Lithium Ion Polymer Battery
This outputs a 4.2V on the load and batt connections.
My arduino and sensors are connected to the load pins from the lipo charger as you can see on the picture.
Thanks for your replay and help.
This is my new code for this sensor and reajusted to library 2.1.1
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - epierre
* Contribution: bulldoglowell, gizmocuz
*
* DESCRIPTION
* Connect sensor ML8511 / Arduino:
*
* 3.3V = 3.3V
* OUT = A0
* GND = GND
* EN = 3.3V
* Arduino 3.3V = Arduino A1
*
* License: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
*/
// Enable debug prints
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
//#define MY_RS485
#include <SPI.h>
#include <MySensors.h>
#include <SPI.h>
//Hardware pin definitions
int REF_3V3 = A1;
int UVOUT = A0;
#define CHILD_ID_UV 0
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
MyMessage uvMsg(CHILD_ID_UV, V_UV);
float lastUV = -1;
unsigned long lastSend =0;
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("UV Sensor", "3.0");
// Register all sensors to gateway (they will be created as child devices)
present(CHILD_ID_UV, S_UV, "ML8511_UV");
}
void setup()
{
//gw.begin(NULL, 9, true);
pinMode(UVOUT, INPUT);
pinMode(REF_3V3, INPUT);
}
void loop()
{
int uvLevel = averageAnalogRead(UVOUT);
int refLevel = averageAnalogRead(REF_3V3);
unsigned long currentTime = millis();
//Use the 3.3V power pin as a reference to get a very accurate output value from sensor
float outputVoltage = 3.3 / refLevel * uvLevel;
//float outputVoltage = 5.0 * uvLevel/1024;
float uvIntensity = mapfloat(outputVoltage, 0.99, 2.8, 0.0, 15.0); //Convert the voltage to a UV intensity level
Serial.print("output: ");
Serial.print(refLevel);
Serial.print("ML8511 output: ");
Serial.print(uvLevel);
Serial.print(" / ML8511 voltage: ");
Serial.print(outputVoltage);
Serial.print(" / UV Intensity (mW/cm^2): ");
Serial.print(uvIntensity);
Serial.println();
if ((uvIntensity != lastUV)||(currentTime-lastSend >= 5*60*1000))
{
lastSend=currentTime;
send(uvMsg.set(uvIntensity,2));
lastUV = uvIntensity;
}
delay(100);
}
//Takes an average of readings on a given pin
//Returns the average
int averageAnalogRead(int pinToRead)
{
byte numberOfReadings = 8;
unsigned int runningValue = 0;
for(int x = 0 ; x < numberOfReadings ; x++)
runningValue += analogRead(pinToRead);
runningValue /= numberOfReadings;
return(runningValue);
}
//The Arduino Map function but for floats
//From: http://forum.arduino.cc/index.php?topic=3922.0
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}```
I'm working again on this system but i'm having some troubles... The code has you caan see i have already adapted it to version 2.1.1 Now on the hardware i'm building i have this:
My problem is that when i have the system online the values i'm getting are not right. For the battery voltage i get 5,5v when i believe i should be getting 3,7v or 4,1v maximum.
The charge and load are always on 0,2A or 0,0A
I have the acs712 connected to the negative side off the battery and the Voltage sensor connected to the negative and positive side off the battery.
What i'm i doing rong here ????
Hi. i have been working on this solar code and have made the changes to work over mysensors 2.1.1
I'm now triyng to add a line code to monitor the voltage from the solar panels. Can anyone give me a help on this?
I want to now the voltage watts or kws produce over my pannels. The idea is to have domoticz monitoring all data produce over the solar pannel.
Thanks
/*Sketch for a MySensor node to monitor a 12v battery with a solar panel for charging
* The node monitors battery voltage,current into and out of the battery, ambient temperature and battery temperature.
* 2 x DS18b20 dallas temperature ic's their data pins connected to arduino digital pin 3
* 1 x ACS712 current sensor module connected to arduino analog pin A4
* 1 x 25v voltage sensor module connected to arduino analog pin A0
* 1 x nRF24L01+ 2.4ghz tranceiver connected as per the MySensors web site.
* 1 x LED connected via a 330 ohm resistor to pin 6
* 1 x push button connected to pin 5
*/
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE
#include <MySensors.h>
#include <SPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 3 // Ds18b20 data wire is connected to digital pin 3 on the Arduino
#define ID_S_TEMP_A 0 // First temp device
#define ID_S_TEMP_B 1 // Second temp device
#define ID_S_MULTIMETERV 3 // Multimeter device for voltage measurement
#define ID_S_MULTIMETERC 4 // Multimeter device for positive current measurement
#define ID_S_MULTIMETERC1 5 // Multimeter device for negative current measurement
#define NUM_SAMPLES 10 // number of analog voltage samples to take per reading
int ledPin = 6; // the pin for the LED
int buttonPin = 5; // the input pin for offset pushbutton
int buttonState = 0; // variable for reading the pin status
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
int lastmilli = 25000; // set to an arbitary number outside of expected current sensor range to ensure a change when first run
float sensitivity = 66 ; // change this to 185 for ACS712-5 or to 100 for ACS712-20A or to 66 for ACS712-30A
int VQ = 0; // Placeholder for quiescent voltage calculations
int ACSPin = A4; // Analog pin number the ACS712 data pin connects to
float lastTemperature[2]; // Array to hold the last temp readings sent to gateway, only send new data if different
int sum = 0; // sum of voltage samples taken
unsigned char sample_count = 0; // current sample number
int lastVoltage = 30000; // set to an arbitary number outside of expected voltage sensor range to ensure a change when first run
int voltagePin = A0; // analog pin voltage sensor or voltage divider is connected to
int voltSenseMax = 25000; // set to the maximum input voltage in millivolts of your voltage divider input
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature.
// ------ Initialize messages ------- //
MyMessage msg(0,V_TEMP);
MyMessage msg_S_MULTIMETERv(ID_S_MULTIMETERV,V_VOLTAGE);
MyMessage msg_S_MULTIMETERc(ID_S_MULTIMETERC,V_CURRENT);
MyMessage msg_S_MULTIMETERc1(ID_S_MULTIMETERC1,V_CURRENT);
void presentation()
{
// Send the sketch version information to the gateway
sendSketchInfo("Battery Status Sensor", "2.1.1");
// Register all sensors to gw (they will be created as child devices)
present(ID_S_TEMP_A, S_TEMP);
present(ID_S_TEMP_B, S_TEMP);
present(ID_S_MULTIMETERV,V_VOLTAGE);
present(ID_S_MULTIMETERC,V_CURRENT);
present(ID_S_MULTIMETERC1,V_CURRENT);
}
void setup()
{
sensors.begin(); // Start up the onewire library
pinMode(buttonPin, INPUT_PULLUP); // Set buttonPin as input and turn on internal pull up resistor
pinMode(ledPin, OUTPUT); // Set ledPin as output
digitalWrite(ledPin, LOW); // Make sure ledPin is off
// ------ load offset for current sensor
int validCheck = loadState(0);
if (validCheck == 120) // check to see if valid data exists
{
VQ = loadState(1); // Load count offset into VQ
//Serial.print(" positive VQ offset loaded..."); Serial.println(VQ);
}
else if (validCheck == 125)
{
VQ = -abs(loadState(1));
//Serial.print(" negative VQ offset loaded..."); Serial.println(VQ);
}
else
{
//Serial.println("VQ offset not set");
}
delay(500);
}
void loop()
{
buttonState = digitalRead(buttonPin);
//Serial.print("buttonstate..."); Serial.println(buttonState);
if (buttonState == LOW)
{
VQ = determineVQ(ACSPin); // Returns the offset count needed to show zero with no load
if (VQ >= 0 && VQ < 255)
{ // check for valid data. VQ is positive number
saveState(0, 120); // Store 120 value in eeprom position 0. use this to check for valid data at boot
saveState(1, VQ); // Store offset count in eeprom. in case of re-boot
}
else if (VQ < 0 && VQ > -255) // VQ is a negative number. negatives cannot be stored in eeprom
{
saveState(0, 125); // Store 125 value in eeprom position 0. use this to check for valid data at boot
saveState(1, abs(VQ)); // convert VQ to positive and Store offset count in eeprom. in case of re-boot
}
}
//-------------------------------------------- Start voltage readings ----------------------------------------------------
sample_count = 0;
sum = 0;
while (sample_count < NUM_SAMPLES) // take a number of voltage samples
{
sum += analogRead(voltagePin);
sample_count++;
delay(10);
}
//Serial.print("sum count..."); Serial.println((sum / NUM_SAMPLES)); // print the count result. will be between 0 and 1023
int voltageI = map(sum/NUM_SAMPLES,0,1023,0,voltSenseMax); // map the reading and get our result in millivolts
//Serial.print("mapped volts..."); Serial.println(voltageI / 1000.0, 1); // convert millivolts back to volts and print. the 1 at the end determines how many decimal places to show
if ( voltageI != lastVoltage) // check if we have a new value. only send data if it is different
{
send(msg_S_MULTIMETERv.set(voltageI / 1000.0, 1)); // voltagel is in millivolts so we divide by 1000 to convert back to volts and send voltage message to gateway with 1 decimal place
lastVoltage = voltageI; // copy the current voltage reading for testing on the next loop
}
//---------------------------------------- Start Current readings ---------------------------------------------------------
int milli = readCurrent(ACSPin); // take a reading from the ACS712 and send to the readcurrent function
//Serial.print("Milliamps..."); Serial.println(milli); // print the value (in milliamps) returned
if ( milli != lastmilli) // check if value has changed
{
if ( milli > 0) // Battery is charging
{
send(msg_S_MULTIMETERc.set(milli/1000.0, 1)); // Send new data to charging amp device
send(msg_S_MULTIMETERc1.set(0)); // set the dis-charging amp device to zero
lastmilli = milli;
}
else if (milli < 0) // Battery is discharging
{
send(msg_S_MULTIMETERc.set(0)); // set the charging amp device to zero
send(msg_S_MULTIMETERc1.set(abs(milli)/1000.0, 1)); // use abs(milli) to Send a positive number to dis-charging amp device
lastmilli = milli;
}
else // No current flowing, set both to zero
{
send(msg_S_MULTIMETERc.set(0));
send(msg_S_MULTIMETERc1.set(0));
lastmilli = milli;
}
}
//--------------------------------------- Temperature readings start ------------------------------------------------------------
Serial.println(" Requesting temperatures...");
// Fetch temperatures from Dallas sensors
sensors.requestTemperatures(); // call sensors.requestTemperatures() to issue a global temperature request to all devices on the bus
// ------- query conversion time and sleep until conversion completed ------
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
sleep(conversionTime);
for (int i=0; i<2; i++)
{
//Serial.print("Temperature for Device: ");Serial.print(i);Serial.print(" is: ");
//Serial.println(sensors.getTempCByIndex(i)); // Why "byIndex"?
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
float temperature = static_cast<float>(static_cast<int>((sensors.getTempCByIndex(i)) * 10.)) / 10.; // Fetch and round temperature to one decimal in celcius
if (lastTemperature[i] != temperature) // check for a changed temperature reading
{
send(msg.setSensor(i).set(temperature,1)); // Send in the new temperature
lastTemperature[i]=temperature; // Save new temperatures for next compare
}
}
sleep(SLEEP_TIME);
}
/*-------------- Function to get the offset required for ACS712 to show zero with no current flowing -----------------*/
int determineVQ(int PIN)
{
digitalWrite(ledPin, HIGH); // Turn on LED to indicate offset being calculated
delay(500); // Delay to hold LED on
digitalWrite(ledPin, LOW); // Turn off LED
delay(150); // Delay to let readings stabilise
//Serial.print("estimating avg. quiscent voltage:");
long acsCount = 0;
for (int i=0; i<5000; i++) // read 5000 samples to stabilise value
{
acsCount += analogRead(PIN); // read the count value between 0 and 1023 and add it to acsCount
delay(1);
}
acsCount /= 5000; // acsCount now eaquals the average of the 5000 readings taken
//Serial.print(map(acsCount, 0, 1023, 0, 5000));Serial.println(" mV"); // Print the avg in millivolts
//Serial.print("acsCount:");Serial.println(acsCount); // Print the actual count value
return int(acsCount - 512); // return the count difference. 512 is the count for 2.5v which is what the reading should be with no current flow
}
/*--------------- Function to read current flowing ------------------*/
int readCurrent(int PIN)
{
int count = 0;
for (int i=0; i<5; i++) // read 5 analog count samples to stabilise value
{
count += analogRead(PIN) - VQ; // subtract the offset count VQ to improve accuracy
delay(1);
//Serial.print("raw count..."); Serial.println(count);
}
/* Notes on the conversion below
* .00488 is the volt value per count of the arduino adc. The analog pin measures from 0 to 5 volt and then assigns the result to
* a count from 0 to 1023, thats 1024 counts including zero. If we devide 5v by 1024 we get .oo488 volts for each count.
*
* The (count/5) just gets us the average of our 5 count samples.
*
* So after the first part of the equation (.00488 * (count/5) is complete we have converted our count reading into volts.
*
* The ACS712 can measure current flow in both directions so it outputs a voltage of 2.5v as it's center point (when no current is flowing).
* To allow for this offset we must subtract the 2.5v to center our voltage reading.
*
* Thats what the next part does (.00488 * (count/5)) - 2.5) After this is complete we are left with either a negative or positive voltage
* reading or a reading of zero for no current flow.
*
* NOTE: While the ACS712 is a 5v device it does not use the full 0 to 5v for it's output. The datasheet shows the 20A version has a sensitivity of
* 100mv per amp, so if we multiply 100mv by 20 we get 2v. That means the 20A ACS712 has an output range from .5v to 4.5v.
*
* So to convert our reading in volts to a reading in amps we need to add the last part ((.00488 * (count/5)) - 2.5)/(sensitivity/1000).
* The variable sensitivity is defined at the begining of the sketch and holds the ACS712 sensitvity amount, it is stored in millivolts.
* That is 66mv for the 30amp, 100mv for the 20amp and 185mv for the 5amp. As sensitivity is in millivolts we need to devide it by 1000
* to convert it back to volts so we can use it in the equation.
*
* Now we have our Amps value stored in the float amps. Integers are much easier to work with when checking for zero so we multiply by 1000
* to convert it to milliamps and return it as an integer.
*/
//Serial.print("VQ = ..."); Serial.println(VQ);
//Serial.print("current count..."); Serial.println(count/5);
//Serial.print("map milliamps..."); Serial.println(map((count/5), 102, 922, -20000, 20000));
float amps = ((.00488 * (count/5)) - 2.5) / (sensitivity/1000);
//Serial.print("float amps..."); Serial.println(amps, 1);
return int (amps * 1000); // convert to milliamps and return as an integer
}```
@sundberg84 Hi here's the code i'm using
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
#define MY_NODE_ID 7
#include <MySensors.h>
#define UV_SENSOR_ANALOG_PIN 0
#define CHILD_ID_UV 0
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
MyMessage uvMsg(CHILD_ID_UV, V_UV);
unsigned long lastSend =0;
float uvIndex;
float lastUV = -1;
uint16_t uvIndexValue [12] = { 50, 227, 318, 408, 503, 606, 696, 795, 881, 976, 1079, 1170};
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("UV Sensor", "1.2");
// Register all sensors to gateway (they will be created as child devices)
present(CHILD_ID_UV, S_UV);
}
void loop()
{
unsigned long currentTime = millis();
uint16_t uv = analogRead(UV_SENSOR_ANALOG_PIN);// Get UV value
if (uv>1170) {
uv=1170;
}
//Serial.print("UV Analog reading: ");
//Serial.println(uv);
int i;
for (i = 0; i < 12; i++) {
if (uv <= uvIndexValue[i]) {
uvIndex = i;
break;
}
}
//calculate 1 decimal if possible
if (i>0) {
float vRange=uvIndexValue[i]-uvIndexValue[i-1];
float vCalc=uv-uvIndexValue[i-1];
uvIndex+=(1.0/vRange)*vCalc-1.0;
}
//Serial.print("UVI: ");
//Serial.println(uvIndex,2);
//Send value to gateway if changed, or at least every 5 minutes
if ((uvIndex != lastUV)||(currentTime-lastSend >= 5UL*60UL*1000UL)) {
lastSend=currentTime;
send(uvMsg.set(uvIndex,2));
lastUV = uvIndex;
}
//sleep(SLEEP_TIME);
}```
@sundberg84 Here's my debug data with sensor connecte to pin A0:
Starting sensor (RNNNA-, 2.0.0)
TSM:INIT
TSM:RADIO:OK
TSP:ASSIGNID:OK (ID=7)
TSM:FPAR
TSP:MSG:SEND 7-7-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSP:MSG:READ 0-0-7 s=255,c=3,t=8,pt=1,l=1,sg=0:0
TSP:MSG:FPAR RES (ID=0, dist=0)
TSP:MSG:PAR OK (ID=0, dist=1)
TSM:FPAR:OK
TSM:ID
TSM:CHKID:OK (ID=7)
TSM:UPL
TSP:PING:SEND (dest=0)
TSP:MSG:SEND 7-7-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
TSP:MSG:READ 0-0-7 s=255,c=3,t=25,pt=1,l=1,sg=0:1
TSP:MSG:PONG RECV (hops=1)
TSP:CHKUPL:OK
TSM:UPL:OK
TSM:READY
TSP:MSG:SEND 7-7-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
!TSP:MSG:SEND 7-7-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=fail:2.0.0
TSP:MSG:SEND 7-7-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=1,st=ok:0
TSP:MSG:READ 0-0-7 s=255,c=3,t=6,pt=0,l=1,sg=0:M
TSP:MSG:SEND 7-7-0-0 s=255,c=3,t=11,pt=0,l=9,sg=0,ft=0,st=ok:UV Sensor
TSP:MSG:SEND 7-7-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=ok:1.2
TSP:MSG:SEND 7-7-0-0 s=0,c=0,t=11,pt=0,l=0,sg=0,ft=0,st=ok:
Request registration...
TSP:MSG:SEND 7-7-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
TSP:MSG:READ 0-0-7 s=255,c=3,t=27,pt=1,l=1,sg=0:1
Node registration=1
Init complete, id=7, parent=0, distance=1, registration=1
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:0.00
And here's my debug without sensor connected to arduino A0:
TSM:CHKID:OK (ID=7)
TSM:UPL
TSP:PING:SEND (dest=0)
TSP:MSG:SEND 7-7-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
TSP:MSG:READ 0-0-7 s=255,c=3,t=25,pt=1,l=1,sg=0:1
TSP:MSG:PONG RECV (hops=1)
TSP:CHKUPL:OK
TSM:UPL:OK
TSM:READY
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.17
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.75
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.46
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:7.90
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.46
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.07
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.46
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.79
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.84
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.38
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.49
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.46
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.25
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.46
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.80
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.36
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.11
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.61
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.46
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.18
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.43
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.97
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.95
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.36
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.52
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.46
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:8.71
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.32
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.31
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.15
TSP:MSG:SEND 7-7-0-0 s=0,c=1,t=11,pt=7,l=5,sg=0,ft=0,st=ok:9.39
Isn't this strange ??
I have already remove the sleep because i'm running this sensor on batteries.
@sundberg84 Thanks for the quick repaly.
I'm using the same code that's on the build section for the UV sensor. Have not made any changes to the code. But i can se the code when i arrived home at night and post here.
Once again thanks.
@sundberg84 I live in Portugal and today for example i have a day whit no clouds temps around the 28º and my UV sensor is giving me 0.00 values... and off course the last data my sensor had send to my gateway was at 08:35 since that time until now i have nothing and it was me how did a reset to the sensor at that time. I really don't understant this sensor.
I now that the arduino is working OK since i have change from a pro mini to a nano and this 2 arduinos work fine.
One other thing i have noticed was that whitout the sensor connected i had a 3.6 value and counting... whit the sensor i have 0.00 value and no data send to the gateway.
Using a weather station from wuntherground near my house i can see that the uv sensor off this weather station is registering 4.1 UV rigth now.
Hi. I'm getting values off 0.2 up to 0.6 on my UV sensor using the UVM-30A sensor. Is this normal?
The first attemp i used a arduino pro mini on my second attemp i'm using a nano pro but i'm getting this values during the day and the other strange problem is that if the value is 0.00 for example the sensor stops sending info to the gateway.
Hi. I'm having some troubles when i try to read the voltage off my arduino batterys,
The problem it's not the code, my problem is the wire connection... Do i connect the battery (+) to A0 pin only or do i have the connect the battery (+) to the A0 pin and the VCC pin on the arduino pro mini ???
If i connect the arduino over USB to see the serial monitor i can see the voltage on 4.8V to 5V.
But when i try to connect to my battery the i get dead antenna.
I have been adapting this mini-weather station code to he API 2.0 and add it the battery sensor. Here's my first attemp
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
#define MY_NODE_ID 2
#define MY_PARENT_NODE_ID 0
#define MY_PARENT_NODE_IS_STATIC
#include <SPI.h>
#include <MySensors.h>
#include <DHT.h>
#include <BH1750.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define CHILD_ID_LIGHT 2
#define CHILD_ID_BARO 3
#define CHILD_ID_BTEMP 4
#define CHILD_ID_WINDSPEED 5
#define CHILD_ID_BATTERY 6
#define MESSAGEWAIT 500
#define DHT_DATA_PIN 3 // Pin 3 digital = DHT11 or DHT12
#define windSpeedPin 4 // Pin 4 digital = Anenometer
#define SENSOR_TEMP_OFFSET 0
#define STABILIZATION_TIME 500 // Let the sensor stabilize 0.5 seconds before reading
static const uint8_t FORCE_UPDATE_N_READS = 10;
static const uint64_t UPDATE_INTERVAL = 60000;
#define BATTERY_FULL 7400 // 3,000 millivolts when battery is full (assuming 2xAA)
#define BATTERY_ZERO 2800 // 1,700 millivolts when battery is empty (reqires blown brownout detection fuse, use 2,800 otherwise)
const float ALTITUDE = 162; // <-- adapt this value to your own location's altitude.
int windSpeedPinCounter = 0; // impuls counter
int windSpeedPinStatus = 0; // actual impuls
int windSpeedPinStatusAlt = 0; // oude Impuls-Status
unsigned long windmeterStart;
unsigned long windmeterStartAlt = 0;
int windSpeed; // Variable voor Wind Speed
int beaufort = 0; // Variable Wind in Beaufort
const int windmeterTime = 10000;
//float knoten = 0.0;
//float wind = 0.0;
unsigned int knoten;
unsigned int wind;
long oldvoltage = 0;
bool metric = true;
float lastBmpTemp;
float lastPressure;
float lastHum;
float lastTemp;
uint8_t nNoUpdatesTemp;
uint8_t nNoUpdatesHum;
int updateAll = 60;
int updateCount = 0;
uint16_t lastLux;
unsigned long SLEEP_TIME = 60000;
Adafruit_BMP085 bmp = Adafruit_BMP085();
BH1750 lightSensor;
DHT dht;
MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE);
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgLux(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
MyMessage msgBtemp(CHILD_ID_BTEMP, V_TEMP);
MyMessage msgPressure(CHILD_ID_BARO, V_PRESSURE);
MyMessage msgWindSpeed(CHILD_ID_WINDSPEED, V_WIND);
MyMessage msgWGust(CHILD_ID_WINDSPEED, V_GUST);
MyMessage msgWDirection(CHILD_ID_WINDSPEED, V_DIRECTION);
void setup()
{
analogReference(INTERNAL);
dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod())
{
Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
}
// Sleep for the time of the minimum sampling period to give the sensor time to power up
// (otherwise, timeout errors might occure for the first reading)
sleep(dht.getMinimumSamplingPeriod());
if (!bmp.begin())
{
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
while (1) {}
}
metric = getConfig().isMetric;
}
void presentation()
{
lightSensor.begin();
sendSketchInfo("Weather Sensor", "4.1.C");
present(CHILD_ID_HUM, S_HUM, "WS Humidity");
// present(CHILD_ID_TEMP, S_TEMP, "WS Temperature");
present(CHILD_ID_LIGHT, S_LIGHT_LEVEL, "WS Lux");
present(CHILD_ID_BARO, S_BARO, "WS Pressure");
present(CHILD_ID_BTEMP, S_TEMP, "WS P Temperature");
present(CHILD_ID_WINDSPEED, S_WIND, "WS Windspeed");
present(CHILD_ID_BATTERY, S_CUSTOM, "WS Battery");
}
// Wind Meter https://github.com/chiemseesurfer/arduinoWeatherstation/blob/master/weatherstation/weatherstation.ino
float windmeter()
{
windmeterStart = millis(); // Actual start time measuringMessung
windmeterStartAlt = windmeterStart; // Save start time
windSpeedPinCounter = 0; // Set pulse counter to 0
windSpeedPinStatusAlt = HIGH; // Set puls status High
while ((windmeterStart - windmeterStartAlt) <= windmeterTime) // until 10000 ms (10 Seconds) ..
{
windSpeedPinStatus = digitalRead(windSpeedPin); // Read input pin 2
if (windSpeedPinStatus != windSpeedPinStatusAlt) // When the pin status changed
{
if (windSpeedPinStatus == HIGH) // When status - HIGH
{
windSpeedPinCounter++; // Counter + 1
}
}
windSpeedPinStatusAlt = windSpeedPinStatus; // Save status for next loop
windmeterStart = millis(); // Actual time
}
windSpeed = ((windSpeedPinCounter * 24) / 10) + 0.5; // WindSpeed - one Pulse ~ 2,4 km/h,
windSpeed = (windSpeed / (windmeterTime / 1000)); // Devided in measure time in seconds
Serial.print("wind Speed : ");
Serial.println(windSpeed);
knoten = windSpeed / 1.852; //knot's
return windSpeed;
}
void loop()
{
updateCount += 1;
if (updateCount == updateAll)
{
lastTemp = -1;
lastHum = -1;
lastLux = -1;
lastBmpTemp = -1;
lastPressure = -1;
updateCount = 0;
}
long voltage = readVcc();
if (oldvoltage != voltage) { // Only send battery information if voltage has changed, to conserve battery.
send(voltage_msg.set(voltage / 1000.0, 3)); // redVcc returns millivolts and set wants volts and how many decimals (3 in our case)
sendBatteryLevel(round((voltage - BATTERY_ZERO) * 100.0 / (BATTERY_FULL - BATTERY_ZERO)));
oldvoltage = voltage;
}
delay(2000);
// Force reading sensor, so it works also after sleep()
dht.readSensor(true);
// Get temperature from DHT library
float temperature = dht.getTemperature();
if (isnan(temperature))
{
Serial.println("Failed reading temperature from DHT!");
}
else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS)
{
// Only send temperature if it changed since the last measurement or if we didn't send an update for n times
lastTemp = temperature;
if (!metric)
{
temperature = dht.toFahrenheit(temperature);
}
// Reset no updates counter
nNoUpdatesTemp = 0;
temperature += SENSOR_TEMP_OFFSET;
send(msgTemp.set(temperature, 1));
#ifdef MY_DEBUG
Serial.print("T: ");
Serial.println(temperature);
#endif
}
else
{
// Increase no update counter if the temperature stayed the same
nNoUpdatesTemp++;
}
// Get humidity from DHT library
float humidity = dht.getHumidity();
if (isnan(humidity))
{
Serial.println("Failed reading humidity from DHT");
}
else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS)
{
// Only send humidity if it changed since the last measurement or if we didn't send an update for n times
lastHum = humidity;
// Reset no updates counter
nNoUpdatesHum = 0;
send(msgHum.set(humidity, 1));
#ifdef MY_DEBUG
Serial.print("H: ");
Serial.println(humidity);
#endif
}
else
{
// Increase no update counter if the humidity stayed the same
nNoUpdatesHum++;
}
uint16_t lux = lightSensor.readLightLevel();
if (lux != lastLux)
{
send(msgLux.set(lux));
lastLux = lux;
}
float pressure = bmp.readSealevelPressure(ALTITUDE) * 0.01;
float bmptemp = bmp.readTemperature();
if (!metric)
{
bmptemp = bmptemp * 1.8 + 32.0;
}
if (bmptemp != lastBmpTemp)
{
send(msgBtemp.set(bmptemp,1));
lastBmpTemp = bmptemp;
}
if (pressure != lastPressure)
{
send(msgPressure.set(pressure, 0));
lastPressure = pressure;
}
wind = windmeter();
Serial.print("Wind : ");
Serial.println(wind);
int wdirection = 1;
int wgust = 1;
send(msgWindSpeed.set(wind, 1));
send(msgWGust.set(wgust, 1));
send(msgWDirection.set(wdirection, 1));
sleep(SLEEP_TIME);
}
void incomingMessage(const MyMessage & message)
{
// We only expect one type of message from controller. But we better check anyway.
if (message.isAck())
{
Serial.println("This is an ack from gateway");
}
}
long readVcc()
{
// From http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
ADMUX = _BV(MUX3) | _BV(MUX2);
#else
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Start conversion
while (bit_is_set(ADCSRA, ADSC)); // measuring
uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
uint8_t high = ADCH; // unlocks both
long result = (high << 8) | low;
result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
return result; // Vcc in millivolts
}
It a little big but does what i need and the best thing it's that the anenometer works
Using IDE 1.6.5 i get this:
In file included from C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:10:0:
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:18:18: error: variable 'monthStr1' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr1[] PROGMEM = "January";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:19:18: error: variable 'monthStr2' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr2[] PROGMEM = "February";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:20:18: error: variable 'monthStr3' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr3[] PROGMEM = "March";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:21:18: error: variable 'monthStr4' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr4[] PROGMEM = "April";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:22:18: error: variable 'monthStr5' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr5[] PROGMEM = "May";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:23:18: error: variable 'monthStr6' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr6[] PROGMEM = "June";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:24:18: error: variable 'monthStr7' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr7[] PROGMEM = "July";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:25:18: error: variable 'monthStr8' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr8[] PROGMEM = "August";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:26:18: error: variable 'monthStr9' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr9[] PROGMEM = "September";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:27:19: error: variable 'monthStr10' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr10[] PROGMEM = "October";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:28:19: error: variable 'monthStr11' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr11[] PROGMEM = "November";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:29:19: error: variable 'monthStr12' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr12[] PROGMEM = "December";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:31:22: error: variable 'monthNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
PGM_P monthNames_P[] PROGMEM =
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:37:26: error: variable 'monthShortNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthShortNames_P[] PROGMEM = "ErrJanFebMarAprMayJunJulAugSepOctNovDec";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:39:16: error: variable 'dayStr0' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr0[] PROGMEM = "Err";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:40:16: error: variable 'dayStr1' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr1[] PROGMEM = "Sunday";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:41:16: error: variable 'dayStr2' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr2[] PROGMEM = "Monday";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:42:16: error: variable 'dayStr3' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr3[] PROGMEM = "Tuesday";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:43:16: error: variable 'dayStr4' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr4[] PROGMEM = "Wednesday";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:44:16: error: variable 'dayStr5' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr5[] PROGMEM = "Thursday";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:45:16: error: variable 'dayStr6' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr6[] PROGMEM = "Friday";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:46:16: error: variable 'dayStr7' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr7[] PROGMEM = "Saturday";
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:48:20: error: variable 'dayNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
PGM_P dayNames_P[] PROGMEM = { dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7};
^
C:\Users\marco\Documents\Arduino\libraries\Time\DateStrings.cpp:49:24: error: variable 'dayShortNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThrFriSat";
^
Erro ao compilar.
Using the new code for version 2.0.0 i'm getting this errors:
C:\Users\marco\Documents\Arduino\Nova pasta\RainGauge\RainGauge.ino: In function 'void setup()':
RainGauge:145: error: 'timeStatus' was not declared in this scope
while (timeStatus() == timeNotSet && millis() - functionTimeout < 30000UL)
RainGauge:145: error: 'timeNotSet' was not declared in this scope
while (timeStatus() == timeNotSet && millis() - functionTimeout < 30000UL)
RainGauge:152: error: 'hour' was not declared in this scope
currentHour = hour();
C:\Users\marco\Documents\Arduino\Nova pasta\RainGauge\RainGauge.ino: In function 'void loop()':
RainGauge:299: error: 'hour' was not declared in this scope
currentHour = hour();
C:\Users\marco\Documents\Arduino\Nova pasta\RainGauge\RainGauge.ino: In function 'void receiveTime(long unsigned int)':
RainGauge:597: error: 'setTime' was not declared in this scope
setTime(time);
RainGauge:599: error: 'hour' was not declared in this scope
sprintf(theTime, "%d:%2d", hour(), minute());
RainGauge:599: error: 'minute' was not declared in this scope
sprintf(theTime, "%d:%2d", hour(), minute());
Using library MySensors at version 2.0.0 in folder: C:\Users\marco\Documents\Arduino\libraries\MySensors
Using library SPI at version 1.0 in folder: C:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI
Using library Wire at version 1.0 in folder: C:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\Wire
exit status 1
'timeStatus' was not declared in this scope
Does anyone now how to fix this ??
Has i can see this GW is not to stable...
here's my log over domoticz:
2016-08-18 14:48:17.667 MySensors: connected to: 10.8.1.201:5003
2016-08-18 14:48:18.669 MySensors: Node: 0, Sketch Name: Ethernet GW
2016-08-18 14:48:18.671 MySensors: Node: 0, Sketch Version: 1,0
2016-08-18 14:53:23.808 MySensors: Connection reset!
2016-08-18 14:53:23.808 TCP: Reconnecting in 30 seconds...
2016-08-18 14:53:53.814 TCP: Reconnecting...
2016-08-18 14:53:54.816 MySensors: connected to: 10.8.1.201:5003
2016-08-18 14:53:55.818 MySensors: Node: 0, Sketch Name: Ethernet GW
2016-08-18 14:53:55.820 MySensors: Node: 0, Sketch Version: 1,0
2016-08-18 14:54:36.836 MySensors: Node: 3, Sketch Name: TemperatureAndHumidity
2016-08-18 14:54:36.839 MySensors: Node: 3, Sketch Version: 1.1
Reconnecting isues ???
@tlpeter
Ok it's fix i cant ping the gw ip but domoticz can see the new arduino gw.
Now at the gw i'm getting this message:
0;255;3;0;9;TSP:MSG:READ 192-1-0 s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSP:MSG:PVER mismatch
0;255;3;0;9;TSP:MSG:READ 192-1-0 s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSP:MSG:PVER mismatch
I don't undestand this mismatch
This is my GW with the mini ENC28J60 runing.
0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSM:RADIO:OK
0;255;3;0;9;TSM:GW MODE
0;255;3;0;9;TSM:READY
IP: 10.8.1.201
0;255;3;0;9;No registration required
0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
0;255;3;0;9;Eth: connect
0;255;3;0;9;Eth: 0;0;3;0;2;
0;255;3;0;9;Eth: 0;0;3;0;2;Get Version
0;255;3;0;9;Eth: 0;0;3;0;18;PING
0;255;3;0;9;Eth: 0;0;3;0;18;PING
0;255;3;0;9;Eth: 0;0;3;0;18;PING
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;Eth: 0;0;3;0;18;PING
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
@tlpeter
Thanks no more errors on the sketch.
My new problem is the ENC28J60 i had not notice that i had buy the MINI ENC28J60 having the code uploaded to the arduino i can't ping the GW IP...
Still having error
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -hardware "C:\Users\marco\AppData\Local\Arduino15\packages" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -tools "C:\Users\marco\AppData\Local\Arduino15\packages" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\marco\Documents\Arduino\libraries" -fqbn=arduino:avr:uno -vid-pid=0X2341_0X0043 -ide-version=10608 -build-path "C:\Users\marco\AppData\Local\Temp\build5e931445a472986892676631252e16b5.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\marco\AppData\Local\Temp\arduino_modified_sketch_600804\gw.ino"
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -hardware "C:\Users\marco\AppData\Local\Arduino15\packages" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -tools "C:\Users\marco\AppData\Local\Arduino15\packages" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\marco\Documents\Arduino\libraries" -fqbn=arduino:avr:uno -vid-pid=0X2341_0X0043 -ide-version=10608 -build-path "C:\Users\marco\AppData\Local\Temp\build5e931445a472986892676631252e16b5.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\marco\AppData\Local\Temp\arduino_modified_sketch_600804\gw.ino"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "C:\Users\marco\AppData\Local\Temp\build5e931445a472986892676631252e16b5.tmp\sketch\gw.ino.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "C:\Users\marco\AppData\Local\Temp\build5e931445a472986892676631252e16b5.tmp\sketch\gw.ino.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "C:\Users\marco\AppData\Local\Temp\build5e931445a472986892676631252e16b5.tmp\sketch\gw.ino.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "C:\Users\marco\AppData\Local\Temp\build5e931445a472986892676631252e16b5.tmp\sketch\gw.ino.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src\SPI.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\Dhcp.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\Dns.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\UIPClient.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\UIPEthernet.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\UIPServer.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\UIPUdp.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\utility\Enc28J60Network.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\utility\clock-arch.c" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\utility\mempool.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\utility\uip.c" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\utility\uip_arp.c" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\utility\uip_debug.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "C:\Users\marco\Documents\Arduino\libraries\UIPEthernet\utility\uip_timer.c" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\AppData\Local\Temp\build5e931445a472986892676631252e16b5.tmp\sketch\gw.ino.cpp" -o "nul"
"C:\Users\marco\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\cores\arduino" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\variants\standard" "-IC:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI\src" "-IC:\Users\marco\Documents\Arduino\libraries\UIPEthernet" "-IC:\Users\marco\Documents\Arduino\libraries\MySensors" "C:\Users\marco\AppData\Local\Temp\build5e931445a472986892676631252e16b5.tmp\sketch\gw.ino.cpp" -o "C:\Users\marco\AppData\Local\Temp\build5e931445a472986892676631252e16b5.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
In file included from C:\Users\marco\AppData\Local\Temp\arduino_modified_sketch_600804\gw.ino:50:0:
C:\Users\marco\Documents\Arduino\libraries\MySensors/MySensors.h:233:5: error: #error UDP mode is not available for ENC28J60
#error UDP mode is not available for ENC28J60
^
Using library SPI at version 1.0 in folder: C:\Users\marco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI
Using library UIPEthernet at version 1.04 in folder: C:\Users\marco\Documents\Arduino\libraries\UIPEthernet
Using library MySensors at version 2.0.0 in folder: C:\Users\marco\Documents\Arduino\libraries\MySensors
exit status 1
Error compiling for board Arduino/Genuino Uno.
@mfalkvidd said:
#define MY_USE_UDP
Ok here's what happens:
If i mark this line like this //#define MY_GATEWAY_ENC28J60 i can run the skecth with no error.
If i un mark the line above the skecth gives the error.
Inserting the line you have told in the end of the sketch i dont get any error if i have the //#define MY_GATEWAY_ENC28J60 marked, otherwise if i don't have this line with // the skecth gives the same error that we are triyng to fix.
The error arduin IDE gives points to this line off code int Mysensors.h
#elif defined(MY_GATEWAY_ENC28J60)
// GATEWAY - ENC28J60
#if defined(MY_USE_UDP)
#error UDP mode is not available for ENC28J60
#endif
Ok going to see if i can found were the UDP is define. Thanks for the help.
@mfalkvidd i don't understant this exit status 1 has i can see everithing is correct why do i get this error...
@tlpeter Yes i did, an d i have also put it on the test folder but i'm getting always the same error
Hummm then the problem can be my libraries
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
Using library UIPEthernet at version 1.04 in folder: C:\Users\marco\Documents\Arduino\libraries\UIPEthernet
Using library MySensors at version 2.0.0 in folder: C:\Users\marco\Documents\Arduino\libraries\MySensors
exit status 1
Error compiling for board Arduino/Genuino Uno.
SPI librarie or UIPEthernet ??? has they aren't version 2.0.0
Got a problem....
In file included from C:\Users\marco\Documents\Arduino\gw\gw.ino:93:0:
C:\Users\marco\Documents\Arduino\libraries\MySensors/MySensors.h:233:5: error: #error UDP mode is not available for ENC28J60
#error UDP mode is not available for ENC28J60
^
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI
Using library UIPEthernet at version 1.04 in folder: C:\Users\marco\Documents\Arduino\libraries\UIPEthernet
Using library MySensors at version 2.0.0 in folder: C:\Users\marco\Documents\Arduino\libraries\MySensors
exit status 1
Error compiling for board Arduino/Genuino Uno.
@tlpeter can you upload your working sketch
How did tlpeter got it to work ?
What can i do? Go back to the w5100? At this moment i dont have nothing working at home.
I'm getting this error on IDE
:\Users\marco\Documents\Arduino\libraries\MySensors/MySensors.h:233:5: error: #error UDP mode is not available for ENC28J60
#error UDP mode is not available for ENC28J60
@Anticimex Thanks going to see yhe examples and tried to fix this problem.
@Anticimex so i have to get my old code and remake it with the code from sensors 2.0.0
@tlpeter Have tryed no ip conflit thats ok
arduino ide debug i get this
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSM:RADIO:OK
0;255;3;0;9;TSM:GW MODE
0;255;3;0;9;TSM:READY
IP: 10.8.1.201
0;255;3;0;9;No registration required
0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
0;255;3;0;9;TSP:MSG:READ 5-5-0 s=9,c=1,t=14,pt=2,l=2,sg=0:55
Funny now the ping does not have any lag since i hade done a reeboot to the gateway
Yes i can, but i can see some lag on the ping today, on the last 2 days this was not happening....
Pinging 10.8.1.201 with 32 bytes of data:
Request timed out.
Reply from 10.8.1.201: bytes=32 time<1ms TTL=128
Request timed out.
Reply from 10.8.1.201: bytes=32 time=1ms TTL=128
Reply from 10.8.1.201: bytes=32 time<1ms TTL=128
Request timed out.
Request timed out.
Request timed out.
@tlpeter
I'm using the sketch that can be found on the test folder from the library 2.0.0
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enable gateway ethernet module type
#define MY_GATEWAY_W5100
// W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
//#define MY_W5100_SPI_EN 4
// Enable Soft SPI for NRF radio (note different radio wiring is required)
// The W5100 ethernet module seems to have a hard time co-operate with
// radio on the same spi bus.
#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
#define MY_SOFTSPI
#define MY_SOFT_SPI_SCK_PIN 14
#define MY_SOFT_SPI_MISO_PIN 16
#define MY_SOFT_SPI_MOSI_PIN 15
#endif
// When W5100 is connected we have to move CE/CSN pins for NRF radio
#ifndef MY_RF24_CE_PIN
#define MY_RF24_CE_PIN 5
#endif
#ifndef MY_RF24_CS_PIN
#define MY_RF24_CS_PIN 6
#endif
// Enable to UDP
//#define MY_USE_UDP
#define MY_IP_ADDRESS 10,8,1,201 // If this is disabled, DHCP is used to retrieve address
// Renewal period if using DHCP
//#define MY_IP_RENEWAL_INTERVAL 60000
// The port to keep open on node server mode / or port to contact in client mode
#define MY_PORT 5003
// Controller ip address. Enables client mode (default is "server" mode).
// Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
//#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
// The MAC address can be anything you want but should be unique on your network.
// Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
// Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address.
#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
// Flash leds on rx/tx/err
#define MY_LEDS_BLINKING_FEATURE
// Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300
// Enable inclusion mode
#define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
#define MY_INCLUSION_BUTTON_FEATURE
// Set inclusion mode duration (in seconds)
#define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
#define MY_INCLUSION_MODE_BUTTON_PIN 3
// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin
//#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED
#include <SPI.h>
#if defined(MY_USE_UDP)
#include <EthernetUdp.h>
#endif
#include <Ethernet.h>
#include <MySensors.h>
void setup()
{
}
void loop() {
}
2016-08-18 11:45:08.681 MySensors: Can not connect to: 10.8.1.201:5003
2016-08-18 11:45:08.681 TCP: Connection problem (Unable to connect to specified IP/Port)
2016-08-18 11:45:08.681 TCP: Reconnecting in 30 seconds...
2016-08-18 11:45:38.687 TCP: Reconnecting...
Ok. problem with the arduino IDE fix, i can upload the code without errors thanks Jason37.
But i still have the problem with the ethernet gateway no connecting to domoticz, same error, reconnecting.....
arduino with mysensorv version 1.5.4 was the last one i had used and all was working OK.
now i'm truing to use the mysensors 2.0.0 but hav this strange problem.
I don't want to go back to version 1.5.4 and stay on the new version 2.0.0 but i want to still have the ethernet gateway because my gateway is located outside my house for better received all my sensors outside.
Is there any fix for this problem? is this a bug?
Hi.
have change the switch the external radio antena for a normal radio but problem still continuos....
I had domoticz runing on a RPI3 and just for debuging change it for a RPI2 but the problem still persists...
I don't understand this error.
With the mysensors 1.5 i had all runing OK on RPI3 with the same ethernet gateway.
Other problem i'm having also no it's flashing the code into the arduinos all OK on the code but when i'm flashing it into the arduino gives a error at the end... and all this start hapening on this version 2.0.0.
Hi. I'm having a problem since i have upgrade to mysensors 2.0.0
The problem it's this:
2016-08-16 21:27:41.811 MySensors: connected to: 10.8.1.201:5003
2016-08-16 21:27:42.811 MySensors: Connection reset!
2016-08-16 21:27:42.811 TCP: Reconnecting in 30 seconds...
2016-08-16 21:28:12.814 TCP: Reconnecting...
2016-08-16 21:28:13.814 MySensors: connected to: 10.8.1.201:5003
2016-08-16 21:28:17.815 MySensors: Connection reset!
2016-08-16 21:28:17.815 TCP: Reconnecting in 30 seconds...
And i can't pass from here don't now what to do.
Can anyone give me a help on this?
Thanks
I think the problem is fix now.
bad cable between ground from 20v divider and arduino ground.
now i'm getting the same value at pin a0
here are the new logs
send: 6-6-3-0 s=255,c=3,t=11,pt=0,l=21,sg=0,st=ok:Battery Status Sensor
send: 6-6-3-0 s=255,c=3,t=12,pt=0,l=1,sg=0,st=ok:1
send: 6-6-3-0 s=0,c=0,t=6,pt=0,l=0,sg=0,st=ok:
send: 6-6-3-0 s=1,c=0,t=6,pt=0,l=0,sg=0,st=fail:
send: 6-6-3-0 s=3,c=0,t=38,pt=0,l=0,sg=0,st=fail:
send: 6-6-3-0 s=4,c=0,t=39,pt=0,l=0,sg=0,st=fail:
send: 6-6-3-0 s=5,c=0,t=39,pt=0,l=0,sg=0,st=ok:
sum count...715
mapped volts...14.0
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:14.0
Milliamps...-21
send: 6-6-3-0 s=4,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
send: 6-6-3-0 s=5,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.0
Requesting temperatures...
send: 6-6-3-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:29.3
send: 6-6-3-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:-127.0
sum count...710
mapped volts...13.9
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:13.9
Milliamps...52
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.1
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
sum count...713
mapped volts...13.9
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:13.9
Milliamps...-21
send: 6-6-3-0 s=4,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
send: 6-6-3-0 s=5,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.0
Requesting temperatures...
sum count...711
mapped volts...13.9
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:13.9
Milliamps...200
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.2
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
sum count...712
mapped volts...13.9
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:13.9
Milliamps...200
Requesting temperatures...
sum count...709
mapped volts...13.9
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:13.9
Milliamps...126
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.1
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
sum count...713
mapped volts...13.9
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:13.9
Milliamps...126
Requesting temperatures...
still using the cpu fan 12v 0.25A pin A0 3.28V
Mapped volts 13.9 it's very near the 13.2V the multimeter gives at the battery.
This is the best results i had until now.
Thanks boots33 for all your help.
3.29v It's the value i'm getting at the end off the 20v divider but at pin A0 i have 1.23V
Requesting temperatures...
sum count...198
mapped volts...3.9
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:3.9
Milliamps...200
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.2
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
sum count...511
mapped volts...10.0
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.0
Milliamps...126
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.1
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
sum count...511
mapped volts...10.0
Milliamps...-21
send: 6-6-3-0 s=4,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
send: 6-6-3-0 s=5,c=1,t=39,pt=7,l=5,sg=0,st=fail:0.0
Requesting temperatures...
sum count...520
mapped volts...10.2
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.2
Milliamps...126
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.1
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=fail:0
Requesting temperatures...
sum count...533
mapped volts...10.4
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.4
Milliamps...52
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.1
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
sum count...511
mapped volts...10.0
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.0
Milliamps...-21
send: 6-6-3-0 s=4,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
send: 6-6-3-0 s=5,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.0
Requesting temperatures...
sum count...511
mapped volts...10.0
Milliamps...200
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.2
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
Battery Voltage - 13.09
pin A0 - 1.055
send: 6-6-3-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.1
send: 6-6-3-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:3
sensor started, id=6, parent=3, distance=2
send: 6-6-3-0 s=255,c=3,t=11,pt=0,l=21,sg=0,st=ok:Battery Status Sensor
send: 6-6-3-0 s=255,c=3,t=12,pt=0,l=1,sg=0,st=fail:1
send: 6-6-3-0 s=0,c=0,t=6,pt=0,l=0,sg=0,st=fail:
send: 6-6-3-0 s=1,c=0,t=6,pt=0,l=0,sg=0,st=ok:
send: 6-6-3-0 s=3,c=0,t=38,pt=0,l=0,sg=0,st=fail:
send: 6-6-3-0 s=4,c=0,t=39,pt=0,l=0,sg=0,st=ok:
send: 6-6-3-0 s=5,c=0,t=39,pt=0,l=0,sg=0,st=fail:
sum count...532
mapped volts...10.4
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=fail:10.4
Milliamps...347
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=fail:0.3
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=fail:0
Requesting temperatures...
send: 6-6-3-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=fail:29.5
send: 6-6-3-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:-127.0
sum count...513
mapped volts...10.0
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.0
Milliamps...347
Requesting temperatures...
send: 6-6-3-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:29.4
sum count...519
mapped volts...10.1
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.1
Milliamps...421
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.4
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
send: 6-6-3-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=fail:29.5
sum count...511
mapped volts...10.0
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.0
Milliamps...347
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.3
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
send: 6-6-3-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=fail:29.4
sum count...511
mapped volts...10.0
Milliamps...347
Requesting temperatures...
send: 6-6-3-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=ok:29.5
sum count...511
mapped volts...10.0
Milliamps...200
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.2
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
sum count...485
mapped volts...9.5
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:9.5
Milliamps...273
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.3
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
sum count...510
mapped volts...10.0
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.0
Milliamps...347
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.3
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=fail:0
Requesting temperatures...
sum count...501
mapped volts...9.8
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:9.8
Milliamps...347
Requesting temperatures...
sum count...511
mapped volts...10.0
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.0
Milliamps...347
Requesting temperatures...
Once again i had connect the 12v fan to the load of the charge regulator
Hi once again.
Today i had to dismount all the solar system my arduino nano just died... don't now why and also the repeater node also dead...
I had replaced the arduino for the solar system i had also put he battery inside my house to make all the tests.
here is the serial monitor log:
Requesting temperatures...
sum count...511
mapped volts...10.0
Milliamps...-95
Requesting temperatures...
sum count...522
mapped volts...10.2
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.2
Milliamps...-95
Requesting temperatures...
sum count...506
mapped volts...9.9
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:9.9
Milliamps...-95
Requesting temperatures...
sum count...511
mapped volts...10.0
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.0
Milliamps...-95
Requesting temperatures...
sum count...511
mapped volts...10.0
Milliamps...-95
Requesting temperatures...
sum count...511
mapped volts...10.0
Milliamps...-95
Requesting temperatures...
sum count...511
mapped volts...10.0
Milliamps...-95
Requesting temperatures...
One thing i had notice now is that house voltage is 10V but solar regulator and multimeter says 13V, and i had moved the acs712 away from the battery.
The test i made was one CPU fan connect to the solar regulator load, this fan is 12A - 0.25A.
Running the fan the solar regulator shows a Load off 0.1A and the arduino shows values between 0A and 0.3A
send: 6-6-3-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.1
send: 6-6-3-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:3
sensor started, id=6, parent=3, distance=2
send: 6-6-3-0 s=255,c=3,t=11,pt=0,l=21,sg=0,st=ok:Battery Status Sensor
send: 6-6-3-0 s=255,c=3,t=12,pt=0,l=1,sg=0,st=ok:1
send: 6-6-3-0 s=0,c=0,t=6,pt=0,l=0,sg=0,st=fail:
send: 6-6-3-0 s=1,c=0,t=6,pt=0,l=0,sg=0,st=fail:
send: 6-6-3-0 s=3,c=0,t=38,pt=0,l=0,sg=0,st=fail:
send: 6-6-3-0 s=4,c=0,t=39,pt=0,l=0,sg=0,st=fail:
send: 6-6-3-0 s=5,c=0,t=39,pt=0,l=0,sg=0,st=fail:
sum count...511
mapped volts...10.0
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=fail:10.0
find parent
send: 6-6-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
Milliamps...52
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.1
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=fail:0
Requesting temperatures...
send: 6-6-3-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=fail:30.3
send: 6-6-3-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=fail:-127.0
sum count...517
mapped volts...10.1
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.1
Milliamps...200
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.2
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
send: 6-6-3-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=fail:29.9
sum count...511
mapped volts...10.0
send: 6-6-3-0 s=3,c=1,t=38,pt=7,l=5,sg=0,st=ok:10.0
Milliamps...126
send: 6-6-3-0 s=4,c=1,t=39,pt=7,l=5,sg=0,st=ok:0.1
send: 6-6-3-0 s=5,c=1,t=39,pt=2,l=2,sg=0,st=ok:0
Requesting temperatures...
I've a mistake when said 4 arduino nano with some sensors, correcting this mistake:
1º arduino nano with UV sensor;
1º arduino nano with lux sensor, pressure sensor, temp/hum sensor and one anemometer; "this is my meteo box sensor"
1º arduino nano with the acs712, voltage sensor and the dallas temperature sensor
1º arduino nano controling a rain gauge.
It's 4 arduino nano with 7 sensors, i don't believe that all this put together are draining 8.6A from the battery. Isn't this a too high value ?
Just took the readings from pin A0 and the values are 3.2V when the battery readins says 13V.
The house battery is fix at 16V or 16.2V but i could not move the acs712 to the box i wanted it's night now and i can't see well, sow this change will be done tomorrow. While i'm wainting let's see if this 16V changes during the day off tomorrow.
Well it's being dificult to get this project work like a charm but it's staring to get tune up thank's to your help Boots33.
Hi.
Ok i did not measure the pin A0 when i was measuring de 13V over the battery but i can do that.I have removed the comments but i hook up the arduino in the battery box and did not look over the serie monitor on PC, once again i'll do that today.
I think the voltage divider i ok, i did a check using a 3,7V battery and the values ia had get with the voltage divider were 0,20% differente from the ones i was getting over the multimeter, 3.2V to 3.4V
I'm going to mak some changes over the place were the asc712 is, i have a box on the wall 40cm to 80cm distance off the batteryes. That's were the ACS712 is going to be.
Thanks.
I really don't get this.
Has i can see i did everything correct but i'm still getting weard values.... In the charge regulator that i have the solar30 i'm connecting the ACS712 like you told.
The voltage dividir i had it connected also on the battery vcc for the 30K resistor and ground on the 10K resistor, over the code i ahd change the "voltSenseMax" to 20000.
With this changes the House battery went from 8.4V to 16.2V but when i make the reading off the battery with a multimeter i get 13V and also the charge regulator screen shows 13V...
The charge current is over 0A now but is night at my place ill wait until tomorrow to see if this values change over the morning and day.
The load current is 9.1A this one i dont get it...
I'm going to try this way and see what values i'll get.
Once again thanks.
@Boots33 said:
30k for R1 and 7.5k for R2
I was going to try to build the voltage sensing but i don't have any 7.5K resistor.... i can put 3 10k Resistors in serie to get the 30k Resistor but i cant make the 7.5K.
Can i use one 10K resistor in the place of the 7.5K, will this work ?? or will the values i'll get be rong??
Hi. i have read the post's you have made, one problem i have found its on the voltage sensing module don't now why it's not workin, simply dead, i have already bought 3 other modules and now i'm waiting for them to arrieved hope to get them until friday.
Have seen your graphs and they are really differents from mine.
Once again today with the multimeter i've made some readings from the battery and i got values in 13,2V - 12,9V and this values were measured at 19:00
Once again Thanks for helping me
@Boots33 Have check the voltage from the battery and is on 12V at this time is discharging the current i couldn't get but tomorrow i'll make new readings and see the values.
The 5V supply voltage is set to 5.02V will have to reduce the 0.02V to get just 5V.
Thanks for your help.
@Boots33 To be honest i just thought the values i was getting were too hight since the battery is 12V 20AH and i only have 4 arduino nano with some sensors using the power from the battery.
Today with one day having the changes made like you have said to do, i have value from the battery between hight 8.2A and 6.6A low, but the media value is almost always on 7.4A.
On the voltage side i'm getting high value 8.8V and low value 7.8V.
Is this good values, correct values for a 12V battery ??
Thanks for the reply, i'm going to make the changes tonight.
I'm getting readings from 8A to 18A this is not correct.
Hi.
I'm having some troubles trying to use the project.
I have the solar pannel that goes directly to the solar regulator. In the solar regulator i have the battery connection and the load connection.
In the battery connection i have my 12V battery connected and i have connected the arduinos over the load connection.
My problem is that i dont see were to connect the ACS712 module on the solar regulator.
At this moment i had connect the ACS712 over the load connection in the solar regulator but the values i'm getting are not correct...
Can anyone give me a help to fiz this problem.
Thanks.
Thanks for the quick reply.
i'm going to change the versions
I'm having a problem in this part off the code:
"present(counterChild, S_DIMMER, "Quality counter " NODE_TXT) ; // counter uses percentage from dimmer value"
I'm getting this error:
"exit status 1
'present' was not declared in this scope"
How can i fix this ?
Ok i have now configured the Weather Underground virtual hardware let's see what will happen during the day off tomorrow.
For what i can seen the UV sensor is detecting the UV normally between 11h and 17h....
I'm going to make one new change on the code to introduce the reading s of the MP8511 voltage.
And i'm going to change the location off the prototype in my house.
To test the UV sensor at night you can use a UV light.
I have done some changings to the code and corrected de 3.3V = A1 Pin that i did not had in the first code.
Onde day has passed with the changes and the result off this days is what you can see on the image below:
I dont now if this results are correct. I'm going to let the sensor outiside until the end of the week and see the results.
Does anyone in the forum have a UV sensor working? Is this chart correct ??
Looking over the schematic you have connected the 5V from the LM2596 directly to the 5V PIN over the arduino.
Is this correct ?
Don't we have to connect it to the VIN PIN??
Looking over the pin connection that you have post i do see one mistake i have done.
I did not connect de 3.3V to A1 pin.
I'm gona trie it when i'm at home.
The sensor is connected to domoticz but the readings are very low... 0.2 UVI
Well i have been searching for the code to work with my UV Sensor ML8511 over domoticz using mysensors off corse but i had no luck.
Tried to use the code over the build section for the UV Sensor but it does not work correctly whit the sensor i have.
Sow i have tried to make a working code, But i'm not a good programmer...
At he time i'm posting this i don't now if it's working correctly because it's night at my place...
#include <SPI.h>
#include <MySensor.h>
#include <MySensor.h>
#include <SPI.h>
#define UV_SENSOR_ANALOG_PIN 0
#define CHILD_ID_UV 0
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
MySensor gw;
MyMessage uvMsg(CHILD_ID_UV, V_UV);
float lastUV = -1;
unsigned long lastSend =0;
void setup()
{
gw.begin(NULL, 9, true);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("UV Sensor", "3.0");
// Register all sensors to gateway (they will be created as child devices)
gw.present(CHILD_ID_UV, S_UV, "ML8511_UV");
}
void loop()
{
gw.process();
int uvLevel = averageAnalogRead(UV_SENSOR_ANALOG_PIN);
unsigned long currentTime = millis();
float outputVoltage = 5.0 * uvLevel/1024;
float uvIntensity = mapfloat(outputVoltage, 0.99, 2.9, 0.0, 15.0);
if ((uvIntensity != lastUV)||(currentTime-lastSend >= 5*60*1000))
{
lastSend=currentTime;
gw.send(uvMsg.set(uvIntensity,2));
lastUV = uvIntensity;
}
//delay(100);
}
//Takes an average of readings on a given pin
//Returns the average
int averageAnalogRead(int pinToRead)
{
byte numberOfReadings = 8;
unsigned int runningValue = 0;
for(int x = 0 ; x < numberOfReadings ; x++)
runningValue += analogRead(pinToRead);
runningValue /= numberOfReadings;
return(runningValue);
}
//The Arduino Map function but for floats
//From: http://forum.arduino.cc/index.php?topic=3922.0
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Has you can seen i had adapted the code from the build area and other code i had found on the web.
Well if any one see erros in the code that i do believe it has, i do appreciate the help on fixing it and making this a perfect working code.
Hi. yesterday i disassembled the rain gauge circuit removed from it the reed switch and created a new circuit.
I have connnected the reed switch to GND and PIN3 whit 10kOhm resistor.
I'll post an image tonight.
Up until now the values i'me getting from this new circuit is:
Values i'm getting from serial port:
Rain last 24 hours:
1.80
Rain last 48 hours:
12481.94
Rain last 72 hours:
28210.34
Rain last 96 hours:
43938.74
Rain last 120 hours:
59667.14
read and drop: 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
read and drop: 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
read and drop: 5-5-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
read and drop: 6-6-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
Seeing the graphic and this values it seems the problem i was having is fixed...
But tonight i'm going do spread some water over the bucket to see if i get any values and not just 0
Thanks going to try it now. And today is a good day since its raining.
No luck... now i'm getting only "0"
What i have done until now:
Put a resistor 10kOhm between the GND and D3 Pin from arduino and connect it to TX2 over rthe rain gauge.
And connected the 5V from arduino to the VCC over the rain gauge.
But i'm only getting 0 ...
send: 4-4-0-0 s=3,c=1,t=28,pt=7,l=5,sg=0,st=fail:-0.2
read: 5-5-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
send: 4-4-0-0 s=4,c=1,t=16,pt=1,l=1,sg=0,st=ok:0
New Sensor State... Sensor: Not Tripped
read: 3-3-0 s=0,c=1,t=38,pt=7,l=5,sg=0:4.748
read: 0-0-4 s=4,c=2,t=24,pt=0,l=1,sg=0:1
read: 5-5-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
read: 5-5-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
Going to put the 10kOhm resistor. the internall pullup did not work.
One question. the resistor i put it between de 5v and the D3 pin
no i cant find any pullup or pulldown resistor.
You can see the images from de interior of the rain gauge hi have.
Looking over the IMG_2 should i connect arduino pin d3 to T1 just above the reed switch?
Or i'm i correct using the TX2 connection.
At the rain gauge i have an arduino nano conneting PIN "d3" to TX2 over the rain gauge circuit, the arduino is powered at pins VIN and GND.
The rain gauge gets its power from the 3.3V over the arduino.
im posting two images from the rain gauge circuit:
Starting to believe i had connect someting rong like for example had switched TX1 and TX2 at the rain gauge
Some times i do get value 0 but other times i get rain value a big rain value for example values above 10mm of rain.
The update is made every hour. Yesterday the rain value was 148mm when there was no rain at all. It doesn't rain for the last month.
Ill try today reassembling the arduino, clear cd rom and flash again the rain gauge code.
But i don't understand why i get this values.
I even beleaved that the sensor was sendind data because off the wind... but it's not the problem.
Hi.
i'm having some trouble whit my rain gauge...
My rain gauge is a Aercus KW9015, using the code provided i'm getting rain count every hour whit no rain at all.
I don't know what to do to fix this.
Over the rain gauge i have 4 connections.
1 - GND
2 - TX1 --- Temperature sensor
3 - TX2 --- Rain sensor
4 - VCC
Why i'm i getting reads of rain ever 1h when there is no rain ?
Can anyone help me whit this problem ?
@mfalkvidd Thanks for the replay.
Will use only one sensor per arduino.
Once again thanks
Hi.
I have been trying to connect two sensors to the same arduino nano using this code and i have add sensor 1 pin to A0 and GND, and sensor 2 pin A1 and GND.
But i only get the reads from sensor 1 sensor 2 doesn't appear...
Can anyone help me with this on how to get more than one moisture sensor working.
Thanks.
@hek said:
development branch
Thanks for the quick replay. Gona try the development branch. Once again thnaks
had to insert in the code "MySensor gw;" and some "gw." at sendSketchInfo and present to stop the errors, flash the code to arduino nano but no info at monitor serie or at domoticz gateway can't seem to find the gps...
No understanding the new problem...
hi. trying to use the code but i'm getting problems with this line "MyMessage msg(CHILD_ID_GPS, V_POSITION);"
sketch_nov15a:68: error: 'V_POSITION' was not declared in this scope
sketch_nov15a.ino: In function 'void present()':
sketch_nov15a:93: error: 'sendSketchInfo' was not declared in this scope
sketch_nov15a:96: error: 'S_GPS' was not declared in this scope
sketch_nov15a.ino: In function 'void loop()':
sketch_nov15a:125: error: 'send' was not declared in this scope
'V_POSITION' was not declared in this scope
Not getting this to work at all
Thanks to all for the help.
Problem solved using the value 5500 at PULSE_FACTOR.
Up until now the values i'm getting seem correct.
The only problem now is the domoticz over raspberry that from time to time hangs up an lose connectivity to mysensor serial gateway.
That's another problem to solve.
Once again thanks for the help.
Hi. Yes its The same sensor.
ill try toda with The value 5500.
This Will seem a dumb question but how can i measure it?
Hi thanks for the code.
My water flow sensor it's the FS300A G3/4
Flow Range: 1-60L/min
Working Pressure: <1.20/Mpa
I'm still having some troble on the readdings from this sensor.
I'm getting for an example in 00:30min readings almost 1.000 m3...
Thanks for the replay.
The only specs i have about this sensor is this:
Specifications
Mini. Wokring Voltage: DC 4.5V
Max. Working Current: 15mA (DC 5V)
Working Voltage: DC 5V~24V
Flow Rate Range: 0~60L/min
Load Capacity: ≤10mA (DC 5V)
Operating Temperature: ≤80℃
Liquid Temperature: ≤120℃
Operating Humidity: 35%~90%RH
Water Pressure: ≤2.0MPa
Storage Temperature: -25~+ 80℃
Storage Humidity: 25%~95%RH
Going to try today at home to change the #define PULSE_FACTOR has sayd and see if i get more real values.
Once again thanks for helping me.
Hi.
I'm using this water flow sensor using the code available from the pulse water meter but the values i'me getting are all rong...
I'm triyng to adapt the code to this water flow sensor with no luck.
Could anyone give me an help with the code?
Thanks in advance.