@mfalkvidd Good! I have now succeded in getting 2.2.0 Beta up and running with Ethernet GW

Posts made by miljume
-
RE: NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
-
RE: NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
@Jokgi Mots probably they are not genuine (bought from Aliexpress) but these devices themselves have not caused me any issues before. It started when I upgraded to 2.1.1. Although, after a clean install with 2.2.0 Beta it started working again so I am 100% sure that it's not the modules
-
RE: NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
@gohan Yes, otherwise it fails already during build
-
RE: NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
@gohan I have tried a clean install both with Rapbian Stretch and Raspbian Jessie but the results are the same
-
RE: NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
@Yveaux The FAILยดs all occur with 2.1.1 and the OK is with 2.2.0 Beta. Same radio connections for both so the FAILยดs should not be connected to communication with the radio module. I have also tried 3 radios and 2 different ways of connecting them (Shield and Dupont cables) Even if 2.2.0 starts OK the problem is that it for the Ethernet GW it fails to connect
mysgw: Starting gateway... mysgw: Protocol version - 2.2.0-beta mysgw: MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0-beta mysgw: TSF:LRT:OK mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: TSM:INIT:TSP OK mysgw: TSM:INIT:GW MODE mysgw: TSM:READY:ID=0,PAR=0,DIS=0 mysgw: MCO:REG:NOT NEEDED mysgw: connect: Connection refused mysgw: failed to connect mysgw: Eth: connect mysgw: connect: Connection refused mysgw: failed to connect mysgw: Eth: connect
And for the Serial GW it gives the following error in Domoticz
2017-10-10 18:43:07.538 MySensors: Using serial port: /dev/ttyUSB020 2017-10-10 18:43:07.538 Error: Serial Port closed!... Error: End of file 2017-10-10 18:43:08.538 MySensors: retrying in 30 seconds...
None of them picks up sensor reports
-
RE: NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
@gohan Now I have tried compiling it with one line command but the GW still don't start with 2.1.1
./configure --my-transport=nrf24 --my-gateway=ethernet --my-port=5003
mysgw: Starting gateway... mysgw: Protocol version - 2.1.1 mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1 mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: !TSM:INIT:TSP FAIL mysgw: TSM:FAIL:CNT=1 mysgw: TSM:FAIL:PDT
-
RE: NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
@Yveaux Thanks for the feedback but I am using a RPI Shield so the connections should be stable
-
RE: NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
@gohan Thanks, will try that as soon as I can
-
RE: NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
@mfalkvidd Sure, below are commands and debug logs for both 2.1.1 and 2.2.0 Beta
As you can see both of the Gateways fails with 2.1.1. I have seen other people having the exact same problem so that is why I thought it could be something with the libraries
Commands with 2.2.0 Beta (serial GW)
./configure --my-transport=nrf24 ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB020 make
Debug Log
mysgw: Starting gateway... mysgw: Protocol version - 2.2.0-beta mysgw: MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0-beta mysgw: TSF:LRT:OK mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: TSM:INIT:TSP OK mysgw: TSM:INIT:GW MODE mysgw: TSM:READY:ID=0,PAR=0,DIS=0 mysgw: MCO:REG:NOT NEEDED mysgw: MCO:BGN:STP mysgw: MCO:BGN:INIT OK,TSP=1
Domoticz Log
2017-10-10 18:43:07.538 MySensors: Using serial port: /dev/ttyUSB020 2017-10-10 18:43:07.538 Error: Serial Port closed!... Error: End of file 2017-10-10 18:43:08.538 MySensors: retrying in 30 seconds...
Repeats every 30th second,
Commands with 2.2.0 Beta (Ethernet GW)
./configure --my-transport=nrf24 ./configure --my-gateway=ethernet --my-port=5003 ./configure --my-gateway=ethernet --my-controller-ip-address=127.0.0.1 make
Debug Log
mysgw: Starting gateway... mysgw: Protocol version - 2.2.0-beta mysgw: MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0-beta mysgw: TSF:LRT:OK mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: TSM:INIT:TSP OK mysgw: TSM:INIT:GW MODE mysgw: TSM:READY:ID=0,PAR=0,DIS=0 mysgw: MCO:REG:NOT NEEDED mysgw: connect: Connection refused mysgw: failed to connect mysgw: Eth: connect mysgw: connect: Connection refused mysgw: failed to connect mysgw: Eth: connect
Commands with 2.1.1 (serial GW)
./configure --my-transport=nrf24 ./configure --my-gateway=serial --my-serial-is-pty --my-serial-pty=/dev/ttyUSB020 make
Debug Log
mysgw: Starting gateway... mysgw: Protocol version - 2.1.1 mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1 mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: !TSM:INIT:TSP FAIL mysgw: TSM:FAIL:CNT=1 mysgw: TSM:FAIL:PDT
Commands with 2.1.1 (Ethernet GW)
./configure --my-transport=nrf24 ./configure --my-gateway=ethernet --my-port=5003 ./configure --my-gateway=ethernet --my-controller-ip-address=127.0.0.1 make
Debug Log
mysgw: Starting gateway... mysgw: Protocol version - 2.1.1 mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1 mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: !TSM:INIT:TSP FAIL mysgw: TSM:FAIL:CNT=1 mysgw: TSM:FAIL:PDT
-
RE: NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
@gohan Yes, I have tried compiling it as Ethernet GW but that didn't work either
Output:
mysgw: Starting gateway... mysgw: Protocol version - 2.2.0-beta mysgw: MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0-beta mysgw: TSF:LRT:OK mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: TSM:INIT:TSP OK mysgw: TSM:INIT:GW MODE mysgw: TSM:READY:ID=0,PAR=0,DIS=0 mysgw: MCO:REG:NOT NEEDED mysgw: Listening for connections on 0.0.0.0:5003 mysgw: MCO:BGN:STP mysgw: MCO:BGN:INIT OK,TSP=1 mysgw: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0: mysgw: !TSF:MSG:LEN,0!=7 mysgw: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0: mysgw: !TSF:MSG:LEN,0!=7 mysgw: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0: mysgw: !TSF:MSG:LEN,0!=7 mysgw: TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0: mysgw: !TSF:MSG:LEN,0!=7 mysgw: New connection from 127.0.0.1 mysgw: Client 0 connected mysgw: Client 0: 0;0;3;0;2; mysgw: Client 0: 0;0;3;0;2;Get Version mysgw: Client 0: 0;0;3;0;18;PING mysgw: TSF:MSG:READ,0-0-0,s=0,c=3,t=18,pt=0,l=4,sg=0:PING mysgw: !TSF:MSG:LEN,0!=11 mysgw: TSF:MSG:READ,0-0-0,s=0,c=3,t=18,pt=0,l=4,sg=0:PING mysgw: !TSF:MSG:LEN,0!=11
Then the GW repeats the last 2 lines forever
Compiled it with IP 127.0.0.1 for the controller and port 5003
It does not pick up the sensors and values
If I compile it with the local IP of the controller I get the following errors
mysgw: Starting gateway... mysgw: Protocol version - 2.2.0-beta mysgw: MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0-beta mysgw: TSF:LRT:OK mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: TSM:INIT:TSP OK mysgw: TSM:INIT:GW MODE mysgw: TSM:READY:ID=0,PAR=0,DIS=0 mysgw: MCO:REG:NOT NEEDED mysgw: connect: Connection refused mysgw: failed to connect mysgw: Eth: connect mysgw: connect: Connection refused
After that the last 2 lines repeats forever
-
NRF24L01+ problems in 2.1.1 and 2.2.0 Beta
Hello,
I would like to submit a bug report for these libraries in the use of NRF24L01+ radio
I have problems with NRF24L01+ on both 2.1.1 and 2.2.0 Beta
I have installed a fresh RPI with all new libraries and trying to make a RPI Serial GW
In 2.1.1 it doesn't start at all but in 2.2.0 it starts but in the log I constantly receive the following in the Domoticz log where I have added the GW
I2017-10-09 19:25:12.306 MySensors: Gateway Version: 2.2.0-beta 2017-10-09 19:25:12.306 Error: Serial Port closed!... Error: End of file 2017-10-09 19:25:13.306 MySensors: retrying in 30 seconds...
After a while I get the following in the console
mysgw: TSF:MSG:READ,0-0-0,s=0,c=3,t=2,pt=0,l=11,sg=0:Get Version mysgw: !TSF:MSG:LEN,0!=18
The above points at something wrong with the radio connection
I have tried 3 different radios but still no luck so I guess it has something to do with the libraries
-
RE: Can't connect to radio on raspPi with latest stable 2.1.1 build, but works with 2.2.beta but with beta mqtt gateway very unstable...
I also have problems with NRF24L01+ on both 2.1.1 and 2.2.0 Beta
I have installed a fresh RPI with all new libraries and trying to make a RPI Serial GW
In 2.1.1 it doesn't start at all but in 2.2.0 it starts but in the log I constantly receive the following in the Domoticz log where I have added the GW
2017-10-09 19:25:12.306 MySensors: Gateway Version: 2.2.0-beta 2017-10-09 19:25:12.306 Error: Serial Port closed!... Error: End of file 2017-10-09 19:25:13.306 MySensors: retrying in 30 seconds...
After a while I get the following in the console
mysgw: TSF:MSG:READ,0-0-0,s=0,c=3,t=2,pt=0,l=11,sg=0:Get Version mysgw: !TSF:MSG:LEN,0!=18
The above points at something wrong with the radio connection
I have tried 3 different radios but still no luck
So I guess it all boils down to that there is some problems with these libraries and the NRF24L01
Any guesses?
-
RE: ๐ฌ LoRa Ra-01 ATmega328P Node
Nice work! Any chance you can post some code samples to interact with MySensors gateway?
-
RE: ๐ฌ My Slim 2AA Battery Node
@sundberg84 Thank you for your feedback! I used the design found here so the sensor is OK. I had also tried to use a pulldown resistor but it showed that I had used too low value. When I use 10k as you suggested it worked like a charm, thank you! What I dont understand is why I should need the pulldown resistor in the first place? Shouldn't it be possible to solve that in the software?
-
RE: ๐ฌ My Slim 2AA Battery Node
Hello, I have built a number of these sensor nodes and really like the generic design!
However I have run into trouble when trying to build a power meter with a photo sensor.
I am using the code from MySensors but also tried other sources but my problem is that the digital pin i am using (D3) dont drop enough for the sensor to treat it as digital 0 as it stays at 2.3 V with a 2 AA battery power attachedWhen trying the pulse sensor with external power it works perfect so it seems like D3 is floating which also is confirmed when I measure on D3 without the sensor attached. (approx 2.7V)
I have used this row in my sketch pinMode(DIGITAL_INPUT_SENSOR,INPUT_PULLUP);Any clues what I can try?
-
RE: ๐ฌ MyPulse Sensor
The electronics work perfect in the TH version but it seems like the enclosure is too small for it to fit.
I needed to carve a bit both on the bottom and lid to be able to mount them together -
RE: ๐ฌ MyPulse Sensor
Nice work! Can you please upload the STL file as well?
-
RE: Slim Node Si7021 sensor example
@Eawo Domoticz groups sensors after the order you present them in, see: https://forum.mysensors.org/topic/5132/ds18b20-ans-sht31-d-show-up-as-combined-sensors-on-domoticz/15
I send every 5 minutes and check the value before so that I only send if the value has changed
I have been running my sensor for nearly 2 months now and battery level has only decreased 1-2%
Make sure you use 1 MHz bootloader
-
RE: Pulse Power Meter: Sleep mode and clear last pulse count
@hek Thank you, you are absolutely correct!
I found a description on how to edit the SQLite table to remove old values
Now I think I am up and running
-
RE: Pulse Power Meter: Sleep mode and clear last pulse count
Yes, I am using Domoticz and have cleared the nodes & childs (Settings/Hardware/MySensorsGateway) from the tables but still it the deleted value is being reported back to the sensor at startup
-
RE: Pulse Power Meter: Sleep mode and clear last pulse count
@hek Thank you for the suggestion but I tried that with no luck
But I realized that you need to detach the interrupt when entering loop() and then attach it again in the end of the loop(). Then it seems like at least the receive() function is entered. However I still have troubles with the SLEEP mode and getting it to report kwh to the GW
Meanwhile I have been looking at This Example and it seems like its working better even if I have some conversion problems but I guess that it is due to an incorrect formula on how to calculate watts
One big problem though that you might know the solution to. How do I clear the gateway value that the sensor reads at startup (V_VAR1)?
I've been looking at This Link but I am not sure if that's the way to go?
-
RE: Pulse Power Meter: Sleep mode and clear last pulse count
@miljume said:
I have worked with this sensor for over a week now but still can't get it to work in sleep mode
So far I have noticed some strange things, please correct me if my assumptions are wrong
- It seems like
request(CHILD_ID_POWER, V_VAR1);
in setup() is not being run when in sleep mode - When that function is not executed, the boolean
pcReceived
is not set to true - When
pcReceived
is false the code never entersif (pcReceived && (SLEEP_MODE || sendTime))
where all the "magic" happens - Pulse counter gets updated (i.e. interrupt occurs) but as the code never enters the if statement where everything is calculated and sent to the GW things dont work
And I still havent figured out how to clear the V_VAR1 in the gateway ...
- It seems like
-
Pulse Power Meter: Sleep mode and clear last pulse count
Hello,
I have built a power meter that works just fine when I use sleep mode = false but that uses up the battery in no-time
As soon as I switch to true it stops sending values, I waited for one hour without any transfers and then I gave up
How is it supposed to work?
Another thing I can't figure out is how to clear the stored pulse count in the gateway, after the tryout is done I would like to start from scratch
Anyone that can help me with these two problems?
Attaching my code below
/** * 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 * * DESCRIPTION * Power Meter for S0 pulses * * */ // Enable debug prints to serial monitor //#define MY_DEBUG // Define a static node address, remove if you want auto address assignment //#deine MY_NODE_ID 3 // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your light sensor. (Only 2 and 3 generates interrupt!) #define PULSE_FACTOR 1000 // Nummber of blinks per KWH of your meeter #define SLEEP_MODE false // Watt-value can only be reported when sleep mode is false. #define MAX_WATT 10000 // Max watt value to report. This filetrs outliers. #define RELEASE "1.0" #include <MySensors.h> // Child sensor ID's //#define CHILD_ID_TEMP 1 #define CHILD_ID_POWER 2 // Sensor messages MyMessage wattMsg(CHILD_ID_POWER, V_WATT); MyMessage kwhMsg(CHILD_ID_POWER, V_KWH); MyMessage pcMsg(CHILD_ID_POWER, V_VAR1); // Global settings unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway. double ppwh = ((double)PULSE_FACTOR) / 1000; // Pulses per watt hour bool pcReceived = false; volatile unsigned long pulseCount = 0; volatile unsigned long lastBlink = 0; volatile unsigned long watt = 0; unsigned long oldPulseCount = 0; unsigned long oldWatt = 0; double oldKwh; unsigned long lastSend; boolean transmission_occured = false; int sendBattery = 0; // Storage of old measurements long lastBattery = -100; /**************************************************** * * Setup code * ****************************************************/ void setup() { Serial.begin(9600); Serial.print(F("Power Meter FW ")); Serial.print(RELEASE); Serial.flush(); Serial.flush(); Serial.println(F(" - Online!")); // Fetch last known pulse count value from gw request(CHILD_ID_POWER, V_VAR1); // Use the internal pullup to be able to hook up this sketch directly to an energy meter with S0 output // If no pullup is used, the reported usage will be too high because of the floating pin pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, RISING); lastSend = millis(); } void presentation() { sendSketchInfo("Power Meter", RELEASE); present(CHILD_ID_POWER, S_POWER); } /*********************************************** * * Main loop function * ***********************************************/ void loop() { unsigned long now = millis(); // Only send values at a maximum frequency or woken up from sleep bool sendTime = now - lastSend > SEND_FREQUENCY; if (pcReceived && (SLEEP_MODE || sendTime)) { // New watt value has been calculated if (!SLEEP_MODE && watt != oldWatt) { // Check that we dont get unresonable large watt value. // could hapen when long wraps or false interrupt triggered if (watt<((unsigned long)MAX_WATT)) { send(wattMsg.set(watt)); // Send watt value to gw } Serial.print("Watt:"); Serial.println(watt); oldWatt = watt; } // Pulse count has changed if (pulseCount != oldPulseCount) { send(pcMsg.set(pulseCount)); // Send pulse count value to gw //sendBattLevel(); double kwh = ((double)pulseCount / ((double)PULSE_FACTOR)); oldPulseCount = pulseCount; if (kwh != oldKwh) { send(kwhMsg.set(kwh, 4)); // Send kwh value to gw oldKwh = kwh; } } lastSend = now; } else if (sendTime && !pcReceived) { // No count received. Try requesting it again request(CHILD_ID_POWER, V_VAR1); lastSend = now; } if (SLEEP_MODE) { sleep(SEND_FREQUENCY); } } void onPulse() { if (!SLEEP_MODE) { unsigned long newBlink = micros(); unsigned long interval = newBlink - lastBlink; if (interval<10000L) { // Sometimes we get interrupt on RISING return; } watt = (3600000000.0 / interval) / ppwh; lastBlink = newBlink; } pulseCount++; } void receive(const MyMessage &message) { if (message.type == V_VAR1) { pulseCount = oldPulseCount = message.getLong(); Serial.print("Received last pulse count from gw:"); Serial.println(pulseCount); pcReceived = true; } } void sendBattLevel() { long vcc = readVcc(); Serial.print("VCC: ");Serial.println(vcc); if (vcc != lastBattery) { lastBattery = vcc; // Calculate percentage vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at long percent = vcc / 14.0; sendBatteryLevel(percent); transmission_occured = true; } } /******************************************* * * Internal battery ADC measuring * *******************************************/ long readVcc() { // 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__) ADcdMUX = _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 }
-
RE: ๐ฌ Power Meter Pulse Sensor
@flopp Thanks for the link but I still cant get anything in sleep mode
Now I have waited for over an hour with simulated blinks approx twice/second but so far the device havent reported one single time!
By the way, does anyone know how to reset the value stored in the GW?
After some testing the value get's quite high
-
RE: ๐ฌ Power Meter Pulse Sensor
@flopp Yes, that was my intention
But I wonder how often the sensor send data to the gateway in that mode i.e. how the mechanism works
I might not have waited long enough but it would be good to know what "long enough" is
-
RE: ๐ฌ Power Meter Pulse Sensor
Can someone please explain how the sleep mode works?
My sensor works like a charm when sleep mode is "false" but when changing to "true" i get nothing to the GW
Exactly the same setup, the only thing I changed is from "false" to "true"
-
RE: Slim Node Si7021 sensor example
Hello
I also have big problems with getting the node to send temp and hum values
It starts up and presents itself to the GW but then nothing happensI have tested the SI721 module with a simple arduino code and then it reads and prints both values just fine
My code is below, in practice its a version of Sensebender Micro code. I have changed the force transmit value to 1
Exactly as @clempat I have tried both 1MHz optiboot and 8MHz internal oscillator without any success/** * 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 - Thomas Bowman MC8rch * * DESCRIPTION * Default sensor sketch for Sensebender Micro module * Act as a temperature / humidity sensor by default. * * If A0 is held low while powering on, it will enter testmode, which verifies all on-board peripherals * * Battery voltage is as battery percentage (Internal message), and optionally as a sensor value (See defines below) * * * Version 1.3 - Thomas Bowman MC8rch * Improved transmission logic, eliminating spurious transmissions (when temperatuere / humidity fluctuates 1 up and down between measurements) * Added OTA boot mode, need to hold A1 low while applying power. (uses slightly more power as it's waiting for bootloader messages) * * Version 1.4 - Thomas Bowman MC8rch * * Corrected division in the code deciding whether to transmit or not, that resulted in generating an integer. Now it's generating floats as expected. * Simplified detection for OTA bootloader, now detecting if MY_OTA_FIRMWARE_FEATURE is defined. If this is defined sensebender automaticly waits 300mS after each transmission * Moved Battery status messages, so they are transmitted together with normal sensor updates (but only every 60th minute) * */ // Enable debug prints to serial monitor #define MY_DEBUG // Define a static node address, remove if you want auto address assignment //#deine MY_NODE_ID 3 // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <SPI.h> #include <MySensors.h> #include <Wire.h> #include <SI7021-master\SI7021.h> #include <RunningAverage.h> // Uncomment the line below, to transmit battery voltage as a normal sensor value #define BATT_SENSOR 199 #define RELEASE "1.4" #define AVERAGES 2 // Child sensor ID's #define CHILD_ID_TEMP 1 #define CHILD_ID_HUM 2 // How many milli seconds between each measurement #define MEASURE_INTERVAL 60000 // FORCE_TRANSMIT_INTERVAL, this number of times of wakeup, the sensor is forced to report all values to the controller #define FORCE_TRANSMIT_INTERVAL 1 // When MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes. // Between the forced transmissions a tranmission will only occur if the measured value differs from the previous measurement // HUMI_TRANSMIT_THRESHOLD tells how much the humidity should have changed since last time it was transmitted. Likewise with // TEMP_TRANSMIT_THRESHOLD for temperature threshold. #define HUMI_TRANSMIT_THRESHOLD 0.5 #define TEMP_TRANSMIT_THRESHOLD 0.5 SI7021 humiditySensor; // Sensor messages MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); #ifdef BATT_SENSOR MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE); #endif // Global settings int measureCount = 0; int sendBattery = 0; boolean isMetric = true; boolean highfreq = true; boolean transmission_occured = false; // Storage of old measurements float lastTemperature = -100; int lastHumidity = -100; long lastBattery = -100; RunningAverage raHum(AVERAGES); /**************************************************** * * Setup code * ****************************************************/ void setup() { Serial.begin(9600); Serial.print(F("Sensebender Micro FW ")); Serial.print(RELEASE); Serial.flush(); humiditySensor.begin(); Serial.flush(); Serial.println(F(" - Online!")); isMetric = getConfig().isMetric; Serial.print(F("isMetric: ")); Serial.println(isMetric); raHum.clear(); sendTempHumidityMeasurements(false); sendBattLevel(false); } void presentation() { sendSketchInfo("TempHum", RELEASE); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_HUM, S_HUM); #ifdef BATT_SENSOR present(BATT_SENSOR, S_POWER); #endif } /*********************************************** * * Main loop function * ***********************************************/ void loop() { measureCount++; sendBattery++; bool forceTransmit = false; transmission_occured = false; if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission forceTransmit = true; measureCount = 0; } sendTempHumidityMeasurements(forceTransmit); /* if (sendBattery > 60) { sendBattLevel(forceTransmit); // Not needed to send battery info that often sendBattery = 0; }*/ sleep(MEASURE_INTERVAL); } /********************************************* * * Sends temperature and humidity from Si7021 sensor * * Parameters * - force : Forces transmission of a value (even if it's the same as previous measurement) * *********************************************/ void sendTempHumidityMeasurements(bool force) { bool tx = force; si7021_env data = humiditySensor.getHumidityAndTemperature(); raHum.addValue(data.humidityPercent); float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0); float diffHum = abs(lastHumidity - raHum.getAverage()); Serial.print(F("TempDiff :"));Serial.println(diffTemp); Serial.print(F("HumDiff :"));Serial.println(diffHum); if (isnan(diffHum)) tx = true; if (diffTemp > TEMP_TRANSMIT_THRESHOLD) tx = true; if (diffHum > HUMI_TRANSMIT_THRESHOLD) tx = true; if (tx) { measureCount = 0; float temperature = (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0; int humidity = data.humidityPercent; Serial.print("T: ");Serial.println(temperature); Serial.print("H: ");Serial.println(humidity); send(msgTemp.set(temperature, 1)); send(msgHum.set(humidity)); lastTemperature = temperature; lastHumidity = humidity; transmission_occured = true; if (sendBattery > 60) { sendBattLevel(true); // Not needed to send battery info that often sendBattery = 0; } } } /******************************************** * * Sends battery information (battery percentage) * * Parameters * - force : Forces transmission of a value * *******************************************/ void sendBattLevel(bool force) { if (force) lastBattery = -1; long vcc = readVcc(); if (vcc != lastBattery) { lastBattery = vcc; #ifdef BATT_SENSOR float send_voltage = float(vcc) / 1000.0f; send(msgBatt.set(send_voltage, 3)); #endif // Calculate percentage vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at long percent = vcc / 14.0; sendBatteryLevel(percent); transmission_occured = true; } } /******************************************* * * Internal battery ADC measuring * *******************************************/ long readVcc() { // 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__) ADcdMUX = _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 }
-
RE: Ethernet gateway compile error
Thank's!
I downloaded the development version of the library and installed, seems to work fine and compiles without errors (except from the MY_LEDS_BLINKING_FEATURE which I removed)
-
RE: Ethernet gateway compile error
I only used the code that is written here: https://www.mysensors.org/build/ethernet_gateway. Have not changed anything at all
Could it be that I have a mixup between old and new library files from Mysensors (i.e. old mysensors.h)?
I didn't find a description on how to upgrade the library files for Mysensors so it might be that I did someting wrong
-
RE: Ethernet gateway compile error
Hello
I have used the version on the build page for ethernet gateway and used the last version of RF24 library for maniacbug together with Mysensors 2.0 library
But I still get a bunch of these errors when compiling
MySensors.h:261: In file included from EthernetGateway.ino:115: from RF24.cpp: 25:1: error: 'LOCAL' does not name a type LOCAL uint8_t MY_RF24_BASE_ADDR[MY_RF24_ADDR_WIDTH] = { MY_RF24_BASE_RADIO_ID } RF24.cpp: 26:1: error: 'LOCAL' does not name a type LOCAL uint8_t MY_RF24_NODE_ADDRESS = AUTO RF24.cpp: 28:1: error: 'LOCAL' does not name a type LOCAL void RF24_csn(bool level) { RF24.cpp: 32:1: error: 'LOCAL' does not name a type LOCAL void RF24_ce(bool level) { RF24.cpp: 36:1: error: 'LOCAL' does not name a type LOCAL uint8_t RF24_spiMultiByteTransfer(uint8_t cmd, uint8_t* buf, uint8_t len, bool aReadMode) { RF24.cpp: 60:1: error: 'LOCAL' does not name a type LOCAL uint8_t RF24_spiByteTransfer(uint8_t cmd) { RF24.cpp: 64:1: error: 'LOCAL' does not name a type LOCAL uint8_t RF24_RAW_readByteRegister(uint8_t cmd) { RF24.cpp: 70:1: error: 'LOCAL' does not name a type LOCAL uint8_t RF24_RAW_writeByteRegister(uint8_t cmd, uint8_t value) { RF24.cpp: 75:1: error: 'LOCAL' does not name a type LOCAL void RF24_flushRX(void) { RF24.cpp: 80:1: error: 'LOCAL' does not name a type LOCAL void RF24_flushTX(void) { RF24.cpp: 85:1: error: 'LOCAL' does not name a type LOCAL uint8_t RF24_getStatus(void) { RF24.cpp: 89:1: error: 'LOCAL' does not name a type LOCAL void RF24_setChannel(uint8_t channel) { RF24.cpp: 93:1: error: 'LOCAL' does not name a type LOCAL void RF24_setRetries(uint8_t retransmitDelay, uint8_t retransmitCount) { RF24.cpp: 97:1: error: 'LOCAL' does not name a type LOCAL void RF24_setAddressWidth(uint8_t width) { RF24.cpp: 101:1: error: 'LOCAL' does not name a type LOCAL void RF24_setRFSetup(uint8_t RFsetup) { RF24.cpp: 105:1: error: 'LOCAL' does not name a type LOCAL void RF24_setFeature(uint8_t feature) { RF24.cpp: 109:1: error: 'LOCAL' does not name a type LOCAL void RF24_setPipe(uint8_t pipe) { RF24.cpp: 113:1: error: 'LOCAL' does not name a type LOCAL void RF24_setAutoACK(uint8_t pipe) { RF24.cpp: 117:1: error: 'LOCAL' does not name a type LOCAL void RF24_setDynamicPayload(uint8_t pipe) { RF24.cpp: 121:1: error: 'LOCAL' does not name a type LOCAL void RF24_setRFConfiguration(uint8_t configuration) { RF24.cpp: 125:1: error: 'LOCAL' does not name a type LOCAL void RF24_setPipeAddress(uint8_t pipe, uint8_t* address, uint8_t width) { RF24.cpp: 129:1: error: 'LOCAL' does not name a type LOCAL void RF24_setPipeLSB(uint8_t pipe, uint8_t LSB) { RF24.cpp: 133:1: error: 'LOCAL' does not name a type LOCAL void RF24_setStatus(uint8_t status) { RF24.cpp: 136:1: error: 'LOCAL' does not name a type LOCAL void RF24_enableFeatures(void) { RF24.cpp: 140:1: error: 'LOCAL' does not name a type LOCAL void RF24_openWritingPipe(uint8_t recipient) { RF24.cpp: 147:1: error: 'LOCAL' does not name a type LOCAL void RF24_startListening(void) { RF24.cpp: 157:1: error: 'LOCAL' does not name a type LOCAL void RF24_stopListening(void) { RF24.cpp: 167:1: error: 'LOCAL' does not name a type LOCAL void RF24_powerDown(void) { RF24.cpp: 173:1: error: 'LOCAL' does not name a type LOCAL bool RF24_sendMessage( uint8_t recipient, const void* buf, uint8_t len ) { RF24.cpp: 208:1: error: 'LOCAL' does not name a type LOCAL uint8_t RF24_getDynamicPayloadSize(void) { RF24.cpp: 220:1: error: 'LOCAL' does not name a type LOCAL bool RF24_isDataAvailable() { RF24.cpp: 226:1: error: 'LOCAL' does not name a type LOCAL uint8_t RF24_readMessage( void* buf) { RF24.cpp: 235:1: error: 'LOCAL' does not name a type LOCAL void RF24_setNodeAddress(uint8_t address) { RF24.cpp: 245:1: error: 'LOCAL' does not name a type LOCAL uint8_t RF24_getNodeID(void) { RF24.cpp: 249:1: error: 'LOCAL' does not name a type LOCAL bool RF24_sanityCheck(void) { RF24.cpp: 256:1: error: 'LOCAL' does not name a type LOCAL bool RF24_initialize(void) { MyTransportNRF24.cpp:22: In file included from MySensors.h:262: from EthernetGateway.ino:115: from RF24.h: In function void setup() RF24.h: 121:6: error: redefinition of 'void setup() void setup() RF24.cpp:23: In file included from MySensors.h:261: from EthernetGateway.ino:115: from RF24.h:121: note void setup() previously defined here void setup() MyTransportNRF24.cpp:22: In file included from MySensors.h:262: from EthernetGateway.ino:115: from RF24.h: In function void loop() RF24.h: 125:6: error: redefinition of 'void loop() void loop() { RF24.cpp:23: In file included from MySensors.h:261: from EthernetGateway.ino:115: from RF24.h:125: note void loop() previously defined here void loop() { MySensors.h:262: In file included from EthernetGateway.ino:115: from MyTransportNRF24.cpp: In function bool transportInit() MyTransportNRF24.cpp: 44:25: error: 'RF24_initialize' was not declared in this scope return RF24_initialize() MyTransportNRF24.cpp: In function void transportSetAddress(uint8_t) MyTransportNRF24.cpp: 48:29: error: 'RF24_setNodeAddress' was not declared in this scope RF24_setNodeAddress(address) MyTransportNRF24.cpp: 49:22: error: 'RF24_startListening' was not declared in this scope RF24_startListening() MyTransportNRF24.cpp: In function uint8_t transportGetAddress() MyTransportNRF24.cpp: 53:24: error: 'RF24_getNodeID' was not declared in this scope return RF24_getNodeID() MyTransportNRF24.cpp: In function bool transportSend(uint8_t, const void*, uint8_t) MyTransportNRF24.cpp: 67:56: error: 'RF24_sendMessage' was not declared in this scope bool status = RF24_sendMessage( recipient, data, len ) MyTransportNRF24.cpp: In function bool transportAvailable() MyTransportNRF24.cpp: 74:36: error: 'RF24_isDataAvailable' was not declared in this scope bool avail = RF24_isDataAvailable() MyTransportNRF24.cpp: In function bool transportSanityCheck() MyTransportNRF24.cpp: 79:26: error: 'RF24_sanityCheck' was not declared in this scope return RF24_sanityCheck() MyTransportNRF24.cpp: In function uint8_t transportReceive(void*) MyTransportNRF24.cpp: 83:37: error: 'RF24_readMessage' was not declared in this scope uint8_t len = RF24_readMessage(data) MyTransportNRF24.cpp: In function void transportPowerDown() MyTransportNRF24.cpp: 94:17: error: 'RF24_powerDown' was not declared in this scope RF24_powerDown() MySensors.h:288: In file included from EthernetGateway.ino:115: from MySensorsCore.cpp: In function void _process() MySensorsCore.cpp: 39:15: error: 'ledsProcess' was not declared in this scope ledsProcess() MySensorsCore.cpp: In function void _infiniteLoop() MySensorsCore.cpp: 62:16: error: 'ledsProcess' was not declared in this scope ledsProcess() MySensorsCore.cpp: In function void _begin() MySensorsCore.cpp: 79:12: error: 'ledsInit' was not declared in this scope ledsInit() EthernetGateway.ino: In function void setup() EthernetGateway.ino: 121:6: error: redefinition of 'void setup() void setup() RF24.cpp:23: In file included from MySensors.h:261: from EthernetGateway.ino:115: from RF24.h:121: note void setup() previously defined here void setup() EthernetGateway.ino: In function void loop() EthernetGateway.ino: 125:6: error: redefinition of 'void loop() void loop() { RF24.cpp:23: In file included from MySensors.h:261: from EthernetGateway.ino:115: from RF24.h:125: note void loop() previously defined here void loop() { Error compiling project sources
Anyone that can tell me why?
Regards,
Mikael -
Can't access PiDome local server
Hello,
I installed the server on my RPI with Raspbian today and followed the steps in your guide
However when I try and access my server through http://<local ip>:8080 I only get "Website cannot be reached" and "ERR_CONNECTION_REFUSED"
Any hints?
Regards,
Mikael -
RE: DHT22 and DS18b20 on same node: DS shows up with Humidity now.
@zampedro Sounds perfect, is there any chance this change can be merged into the source of Domoticz?
-
RE: DHT22 and DS18b20 on same node: DS shows up with Humidity now.
@zampedro I have exactly the same problem
Could you please tell me more of how you modified Domoticz source?
This bug is really annoying!
Regards,
Mikael -
RE: DS18B20 and DHT22 in the same sensor and sketch
Thanks for a quick reply!
I tested this code tonight but have the same problem, two devices popup in Domoticz but the second one (with DS18B20) also reports humidity which i guess is received from DHT22
Not a very big problem if you know the setup but you could easily think that the humidity comes from the same measurement point as the DS18B20 which it dont
-
DS18B20 and DHT22 in the same sensor and sketch
Hi,
I have created a sensor with both a DHT22 and a DS18B20 which will be located in my bathroom with the main unit with the DHT22 inside the bathroom and the DS18B20 (cable mounted) will be located in my sauna
This seems to work fine but when I view the sensor in Domoticz it shows two devices with temp and humidity for both of them! I only want the DHT22 device to be temp & humidity and the other device to be temp only
Is there a way to do this in the code?
I have used the example sketches for Humidity and Temperature and put them together into one sketch so that I have one sensor with three child devices
Anyone that could give me a hint?
Regards,
Mikael